V0.8.0 process message debug #44

Merged
ton merged 23 commits from v0.8.0-process_message_debug into v0.8.0 2026-08-16 13:22:52 +00:00
3 changed files with 30 additions and 41 deletions
Showing only changes of commit 578e8f55bd - Show all commits
+1 -12
View File
@@ -57,7 +57,6 @@ mutable struct yiemAgent <: agent # High-level agent wrapper
maxRetryDelayMs::Union{Int64, Nothing} # Maximum delay between retries (ms)
parallelToolExecute::Bool # Default: false
agentEventSink::Function # agent emits its status via this function
_tool_store::Any # Reference to the toolStore for runtime registration
end
"""
@@ -82,17 +81,9 @@ on `inputChannel` and `followUpChannel` channels concurrently.
- `maxRetryDelayMs::Union{Int64, Nothing}`: Maximum delay between retries in milliseconds (default: `nothing`)
- `parallelToolExecute::Bool`: Run tool calls in parallel (default: `false`)
- `agentEventSink::Function`: Callback to receive agent events
- `tool_store::Union{Any, Nothing}`: toolStore for runtime tool registration (default: `nothing`)
# Returns
- A new `yiemAgent` instance with an active background task
# Examples
```julia
julia> store = toolStore(name="agent1")
julia> tools = loadTools(store, "src/tools")
julia> agent = yiemAgent(systemPrompt="You are a helpful assistant", model=my_model, tools=tools, llmCall=..., tool_store=store)
yiemAgent(agentState(...), Channel(...), Channel(...), Channel(...), ..., store)
"""
function yiemAgent(
toolsFolderPath::String,
@@ -104,14 +95,13 @@ function yiemAgent(
prepareContext::Function=prepareContext,
formatMsgForLLM::Function=formatMsgForLLM,
beforeToolCall::Function=beforeToolCall,
afterToolCall::Function, #WORKING
afterToolCall::Function=afterToolCall, #WORKING
# prepareNextTurn::Union{Function, Nothing}=nothing,
# prepareNextTurnWithContext::Union{Function, Nothing}=nothing,
sessionId::Union{String, Nothing}=nothing,
maxRetryDelayMs::Union{Int64, Nothing}=nothing,
parallelToolExecute::Bool=false,
agentEventSink::Function,
tool_store::Union{Any, Nothing}=nothing,
)
# Create channels: input (user -> agent), followUp (async queue), output (agent -> user)
inputChannel = Channel(16)
@@ -140,7 +130,6 @@ function yiemAgent(
maxRetryDelayMs,
parallelToolExecute,
agentEventSink,
tool_store,
)
# Spawn the background loop and attach it
+8 -8
View File
@@ -3,7 +3,7 @@ module utils
export clearhistory, availableWineToText, prepareContext, formatMsgForLLM, validateRequiredArgs,
validateToolArguments, _userMessageToOpenAI,
_assistantMessageToOpenAI, _toolResultMessageToOpenAI, _messageContentToBlocks,
beforeToolCall
beforeToolCall, afterToolCall
using UUIDs, Dates, DataStructures, HTTP, JSON
using GeneralUtils
@@ -221,7 +221,9 @@ function formatMsgForLLM(ctx::agentContext)::Dict{String, Any}
end
#TODO
function beforeToolCall(context::beforeToolCallContext, signal::abortSignal)::beforeToolCallResult
function beforeToolCall(context::beforeToolCallContext, signal::abortSignal
)::beforeToolCallResult
# final context check
# seek user approval via UI
@@ -232,14 +234,12 @@ function beforeToolCall(context::beforeToolCallContext, signal::abortSignal)::be
end
#TODO
function afterToolCall(context::beforeToolCallContext, signal::abortSignal)::beforeToolCallResult
# final context check
function afterToolCall(context::beforeToolCallContext, signal::abortSignal
)::Union{agentToolResult, Nothing}
# seek user approval via UI
# modify context.result if needed and return agentToolResult
# other check
return beforeToolCallResult(false, "N/A")
return nothing
end