This commit is contained in:
2026-08-07 15:47:27 +07:00
parent 4df1043032
commit 02e93cae57
2 changed files with 39 additions and 16 deletions
+35 -12
View File
@@ -1,6 +1,29 @@
module type
export agentContext, yiemAgent,
run_agent, take_response, follow_up, stop_agent
module type
export Timestamp,
# Abstract types
messageContent, agentMessage, agent,
# Model types
modelCost, llmModel, llmUsage,
# Message content types
textContent, imageContent,
# Message types
userMessage, assistantMessage, toolResultMessage,
# Tool types
agentTool,
# Context types
agentContext, agentState, agentToolCall, prepareNextTurnContext,
# Loop & execution types
agentLoopConfig, abortSignal, agentToolResult,
assistantMsgCtx, afterCtx,
# Event types
toolExecStartEvent, toolExecUpdateEvent, toolExecEndEvent,
# Agent
yiemAgent,
# Tool call lifecycle types
preparedToolCall, immediateOutcome, executedOutcome, finalizedOutcome,
agentToolCallBatch,
# Functions (defined elsewhere)
run_agent, take_response, follow_up, stop_agent
using Dates, UUIDs, DataStructures, JSON, NATS, Base.Threads
@@ -597,7 +620,7 @@ carrying the full context through the call chain.
struct preparedToolCall
tool::agentTool # The resolved tool definition from the context
toolCall::agentToolCall # The original tool call from the assistant
args::any # Validated (and coerced) argument values
args::Any # Validated (and coerced) argument values
end
"""
@@ -615,7 +638,7 @@ corrected arguments after a validation failure.
# Fields
- `result::agentToolResult`: The pre-computed tool result
- `isError::bool`: Whether this outcome represents an error
- `isError::Bool`: Whether this outcome represents an error
# Examples
```julia
@@ -634,7 +657,7 @@ immediateOutcome(
"""
struct immediateOutcome
result::agentToolResult # The pre-computed tool result
isError::bool # Whether this outcome represents an error
isError::Bool # Whether this outcome represents an error
end
"""
@@ -649,7 +672,7 @@ whether to transform it or replace it entirely.
# Fields
- `result::agentToolResult`: The tool's execution result
- `isError::bool`: Whether execution raised an error
- `isError::Bool`: Whether execution raised an error
# Examples
```julia
@@ -668,7 +691,7 @@ executedOutcome(
"""
struct executedOutcome
result::agentToolResult # The tool's execution result
isError::bool # Whether execution raised an error
isError::Bool # Whether execution raised an error
end
"""
@@ -689,7 +712,7 @@ and swappable.
# Fields
- `toolCall::agentToolCall`: The original tool call reference
- `result::agentToolResult`: The final tool result (post-afterToolCall)
- `isError::bool`: Whether the call failed or was blocked
- `isError::Bool`: Whether the call failed or was blocked
# Examples
```julia
@@ -703,7 +726,7 @@ finalizedOutcome(tc, agentToolResult(content, details, usage, true), false)
struct finalizedOutcome
toolCall::agentToolCall # The original tool call reference
result::agentToolResult # The final tool result (post-afterToolCall)
isError::bool # Whether the call failed or was blocked
isError::Bool # Whether the call failed or was blocked
end
"""
@@ -749,8 +772,8 @@ agentToolCallBatch(toolResultMessage[], false)
```
"""
struct agentToolCallBatch
messages::vector{toolResultMessage} # Tool result messages for this batch
terminate::bool # Whether the batch should terminate the loop
messages::Vector{toolResultMessage} # Tool result messages for this batch
terminate::Bool # Whether the batch should terminate the loop
end
+4 -4
View File
@@ -29,10 +29,10 @@ julia> YiemAgent.clearhistory(agent)
```
"""
function clearhistory(a::T) where {T<:agent}
empty!(a.chathistory)
empty!(a.memory["shortmem"])
empty!(a.memory["events"])
a.memory["chatbox"] = ""
# empty!(a.chathistory)
# empty!(a.memory["shortmem"])
# empty!(a.memory["events"])
# a.memory["chatbox"] = ""
end