update
This commit is contained in:
+11
-5
@@ -377,11 +377,17 @@ mutable struct yiemAgent <: agent # High-level agent wrapper
|
|||||||
# Convert preprocessContext()'s new Vector{agentMessage} to LLM message format
|
# Convert preprocessContext()'s new Vector{agentMessage} to LLM message format
|
||||||
formatMsgForLLM::Function
|
formatMsgForLLM::Function
|
||||||
|
|
||||||
llmCall::Function # Actually invoke the LLM to get a completion response
|
# Actually invoke the LLM to get a completion response. The LLM response comes back as an
|
||||||
|
# assistantMessage whose content is an array of content blocks.
|
||||||
|
# Each block has a type — "text", "thinking", or "toolCall".
|
||||||
|
# The code filters for type === "toolCall" blocks, then passes them to executeToolCalls().
|
||||||
|
llmCall::Function
|
||||||
|
|
||||||
# Callback invoked before executing a tool call (ask for user permission/confirmation/abort, etc..)
|
# Callback invoked before executing a tool call (ask for user permission/confirmation/abort, etc..)
|
||||||
beforeToolCall::Union{Function, Nothing}
|
beforeToolCall::Union{Function, Nothing}
|
||||||
|
|
||||||
|
executeToolCalls::Function # execute tool calls
|
||||||
|
|
||||||
# Callback invoked after executing a tool call to sanitize tools output so the output is ready
|
# Callback invoked after executing a tool call to sanitize tools output so the output is ready
|
||||||
# to be converted into toolResults message
|
# to be converted into toolResults message
|
||||||
afterToolCall::Union{Function, Nothing}
|
afterToolCall::Union{Function, Nothing}
|
||||||
@@ -389,7 +395,7 @@ mutable struct yiemAgent <: agent # High-level agent wrapper
|
|||||||
prepareNextTurnWithContext::Union{Function, Nothing} # Same but receives context
|
prepareNextTurnWithContext::Union{Function, Nothing} # Same but receives context
|
||||||
sessionId::Union{String, Nothing} # Optional session identifier
|
sessionId::Union{String, Nothing} # Optional session identifier
|
||||||
maxRetryDelayMs::Union{Int64, Nothing} # Maximum delay between retries (ms)
|
maxRetryDelayMs::Union{Int64, Nothing} # Maximum delay between retries (ms)
|
||||||
toolExecution::toolExecutionMode # Default: run tool calls sequentially or in parallel
|
parallelToolExecute::Bool # Default: false
|
||||||
end
|
end
|
||||||
|
|
||||||
"""
|
"""
|
||||||
@@ -412,7 +418,7 @@ on `inputChannel` and `followUpChannel` channels concurrently.
|
|||||||
- `prepareNextTurnWithContext::Union{Function, Nothing}`: Same but receives context (default: `nothing`)
|
- `prepareNextTurnWithContext::Union{Function, Nothing}`: Same but receives context (default: `nothing`)
|
||||||
- `sessionId::Union{String, Nothing}`: Optional session identifier (default: `nothing`)
|
- `sessionId::Union{String, Nothing}`: Optional session identifier (default: `nothing`)
|
||||||
- `maxRetryDelayMs::Union{Int64, Nothing}`: Maximum delay between retries in milliseconds (default: `nothing`)
|
- `maxRetryDelayMs::Union{Int64, Nothing}`: Maximum delay between retries in milliseconds (default: `nothing`)
|
||||||
- `toolExecution`: Default tool execution mode (sequential or parallel) (default: `nothing`)
|
- `parallelToolExecute::Bool`: Run tool calls in parallel (default: `false`)
|
||||||
|
|
||||||
# Returns
|
# Returns
|
||||||
- A new `yiemAgent` instance with an active background task
|
- A new `yiemAgent` instance with an active background task
|
||||||
@@ -437,7 +443,7 @@ function yiemAgent(
|
|||||||
prepareNextTurnWithContext::Union{Function, Nothing}=nothing,
|
prepareNextTurnWithContext::Union{Function, Nothing}=nothing,
|
||||||
sessionId::Union{String, Nothing}=nothing,
|
sessionId::Union{String, Nothing}=nothing,
|
||||||
maxRetryDelayMs::Union{Int64, Nothing}=nothing,
|
maxRetryDelayMs::Union{Int64, Nothing}=nothing,
|
||||||
toolExecution=nothing,
|
parallelToolExecute::Bool=false,
|
||||||
)
|
)
|
||||||
# Create channels: input (user -> agent), followUp (async queue), output (agent -> user)
|
# Create channels: input (user -> agent), followUp (async queue), output (agent -> user)
|
||||||
inputChannel = Channel(16)
|
inputChannel = Channel(16)
|
||||||
@@ -460,7 +466,7 @@ function yiemAgent(
|
|||||||
prepareNextTurnWithContext,
|
prepareNextTurnWithContext,
|
||||||
sessionId,
|
sessionId,
|
||||||
maxRetryDelayMs,
|
maxRetryDelayMs,
|
||||||
toolExecution,
|
parallelToolExecute,
|
||||||
)
|
)
|
||||||
|
|
||||||
# Spawn the background loop and attach it
|
# Spawn the background loop and attach it
|
||||||
|
|||||||
Reference in New Issue
Block a user