update
This commit is contained in:
+6
-36
@@ -834,39 +834,6 @@ function finalizeExecutedToolCall(
|
||||
return finalizedOutcome(prep.toolCall, result, isError)
|
||||
end
|
||||
|
||||
"""
|
||||
emitToolExecutionEnd(finalized, emit)
|
||||
|
||||
Emits the `toolExecutionEnd` event with the finalized outcome,
|
||||
signalling to listeners that the tool call has completed.
|
||||
|
||||
This event is part of the tool execution lifecycle:
|
||||
`toolExecutionStart` → (zero or more `toolExecutionUpdate` events) →
|
||||
`toolExecutionEnd`. Listeners (such as the TUI or logging systems)
|
||||
use this lifecycle to track individual tool calls. The event carries
|
||||
the final result so listeners have all the data they need without
|
||||
requiring external state lookups.
|
||||
|
||||
# Arguments
|
||||
- `finalized::finalizedOutcome`: The finalized outcome to report
|
||||
- `emit::Function`: Event emitter
|
||||
|
||||
# Notes
|
||||
- Part of a three-event lifecycle per tool call
|
||||
- Carries the complete result so listeners need no external lookups
|
||||
|
||||
# Examples
|
||||
```julia
|
||||
# Emits a single event; returns nothing
|
||||
emitToolExecutionEnd(finalized, emit)
|
||||
# (emit receives toolExecEndEvent("call_1", "search_wine", result, false))
|
||||
```
|
||||
"""
|
||||
function emitToolExecutionEnd(finalized::finalizedOutcome, emit::Function)
|
||||
emit(toolExecEndEvent(finalized.toolCall.id, finalized.toolCall.name,
|
||||
finalized.result, finalized.isError))
|
||||
end
|
||||
|
||||
# ── sequential execution ────────────────────────────────────────
|
||||
|
||||
"""
|
||||
@@ -945,7 +912,8 @@ function executeToolCallsSequential(
|
||||
finalized = finalizeExecutedToolCall(context, assistantMsg, prep, executed, config, signal)
|
||||
end
|
||||
|
||||
emitToolExecutionEnd(finalized, emit)
|
||||
emit(toolExecEndEvent(finalized.toolCall.id, finalized.toolCall.name,
|
||||
finalized.result, finalized.isError))
|
||||
push!(messages, createToolResultMessage(finalized))
|
||||
push!(finalizedCalls, finalized)
|
||||
|
||||
@@ -1032,13 +1000,15 @@ function executeToolCallsParallel(
|
||||
|
||||
if prep isa immediateOutcome
|
||||
finalized = finalizedOutcome(tc, prep.result, prep.isError)
|
||||
emitToolExecutionEnd(finalized, emit)
|
||||
emit(toolExecEndEvent(finalized.toolCall.id, finalized.toolCall.name,
|
||||
finalized.result, finalized.isError))
|
||||
push!(entries, finalized)
|
||||
else
|
||||
task = task() do
|
||||
executed = executePreparedToolCall(prep, signal, emit)
|
||||
finalized = finalizeExecutedToolCall(context, assistantMsg, prep, executed, config, signal)
|
||||
emitToolExecutionEnd(finalized, emit)
|
||||
emit(toolExecEndEvent(finalized.toolCall.id, finalized.toolCall.name,
|
||||
finalized.result, finalized.isError))
|
||||
return finalized
|
||||
end
|
||||
schedule(task)
|
||||
|
||||
Reference in New Issue
Block a user