fix(agent): emit parallel tool completion eagerly\n\ncloses #3503

This commit is contained in:
Mario Zechner
2026-04-22 00:15:56 +02:00
parent 6480b734c1
commit 759d551527
7 changed files with 105 additions and 57 deletions

View File

@@ -101,10 +101,10 @@ prompt("Read config.json")
Tool execution mode is configurable:
- `parallel` (default): preflight tool calls sequentially, execute allowed tools concurrently, and emit `tool_execution_end`, toolResult messages, and `turn_end.toolResults` in the order tool calls finish
- `parallel` (default): preflight tool calls sequentially, execute allowed tools concurrently, emit `tool_execution_end` as soon as each tool is finalized, then emit toolResult messages and `turn_end.toolResults` in assistant source order
- `sequential`: execute tool calls one by one, matching the historical behavior
In parallel mode, final tool lifecycle and tool-result artifacts follow tool completion order, not assistant source order. A later tool call may therefore finish before an earlier one, including when it is blocked during preflight.
In parallel mode, tool completion events follow tool completion order, but persisted toolResult messages still follow assistant source order.
The mode can be set globally via `toolExecution` in the agent config, or per-tool via `executionMode` on `AgentTool`. If any tool call in a batch targets a tool with `executionMode: "sequential"`, the entire batch executes sequentially regardless of the global setting.