V0.8.0 async think loop #40
+12
-6
@@ -376,11 +376,17 @@ mutable struct yiemAgent <: agent # High-level agent wrapper
|
||||
|
||||
# Convert preprocessContext()'s new Vector{agentMessage} to LLM message format
|
||||
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..)
|
||||
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
|
||||
# to be converted into toolResults message
|
||||
@@ -389,7 +395,7 @@ mutable struct yiemAgent <: agent # High-level agent wrapper
|
||||
prepareNextTurnWithContext::Union{Function, Nothing} # Same but receives context
|
||||
sessionId::Union{String, Nothing} # Optional session identifier
|
||||
maxRetryDelayMs::Union{Int64, Nothing} # Maximum delay between retries (ms)
|
||||
toolExecution::toolExecutionMode # Default: run tool calls sequentially or in parallel
|
||||
parallelToolExecute::Bool # Default: false
|
||||
end
|
||||
|
||||
"""
|
||||
@@ -412,7 +418,7 @@ on `inputChannel` and `followUpChannel` channels concurrently.
|
||||
- `prepareNextTurnWithContext::Union{Function, Nothing}`: Same but receives context (default: `nothing`)
|
||||
- `sessionId::Union{String, Nothing}`: Optional session identifier (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
|
||||
- A new `yiemAgent` instance with an active background task
|
||||
@@ -437,7 +443,7 @@ function yiemAgent(
|
||||
prepareNextTurnWithContext::Union{Function, Nothing}=nothing,
|
||||
sessionId::Union{String, Nothing}=nothing,
|
||||
maxRetryDelayMs::Union{Int64, Nothing}=nothing,
|
||||
toolExecution=nothing,
|
||||
parallelToolExecute::Bool=false,
|
||||
)
|
||||
# Create channels: input (user -> agent), followUp (async queue), output (agent -> user)
|
||||
inputChannel = Channel(16)
|
||||
@@ -460,7 +466,7 @@ function yiemAgent(
|
||||
prepareNextTurnWithContext,
|
||||
sessionId,
|
||||
maxRetryDelayMs,
|
||||
toolExecution,
|
||||
parallelToolExecute,
|
||||
)
|
||||
|
||||
# Spawn the background loop and attach it
|
||||
|
||||
Reference in New Issue
Block a user