docs(agent): clarify parallel tool ordering closes #3468

This commit is contained in:
Mario Zechner
2026-04-20 22:35:43 +02:00
parent c40efa9bab
commit 7b1599058b
3 changed files with 10 additions and 3 deletions

View File

@@ -2,6 +2,10 @@
## [Unreleased]
### Changed
- Clarified parallel tool execution ordering docs to specify that final tool lifecycle and tool-result artifacts are emitted in tool completion order.
## [0.67.68] - 2026-04-17
## [0.67.67] - 2026-04-17

View File

@@ -101,9 +101,11 @@ prompt("Read config.json")
Tool execution mode is configurable:
- `parallel` (default): preflight tool calls sequentially, execute allowed tools concurrently, emit final `tool_execution_end` and `toolResult` messages in assistant source order
- `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
- `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.
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.
The `beforeToolCall` hook runs after `tool_execution_start` and validated argument parsing. It can block execution. The `afterToolCall` hook runs after tool execution finishes and before `tool_execution_end` and final tool result message events are emitted.

View File

@@ -30,7 +30,7 @@ export type StreamFn = (
*
* - "sequential": each tool call is prepared, executed, and finalized before the next one starts.
* - "parallel": tool calls are prepared sequentially, then allowed tools execute concurrently.
* Final tool results are still emitted in assistant source order.
* Final tool lifecycle and tool-result artifacts are emitted in tool completion order.
*/
export type ToolExecutionMode = "sequential" | "parallel";
@@ -185,7 +185,8 @@ export interface AgentLoopConfig extends SimpleStreamOptions {
/**
* Tool execution mode.
* - "sequential": execute tool calls one by one
* - "parallel": preflight tool calls sequentially, then execute allowed tools concurrently
* - "parallel": preflight tool calls sequentially, then execute allowed tools concurrently;
* final tool lifecycle and tool-result artifacts are emitted in tool completion order
*
* Default: "parallel"
*/