feat: support parallel tool calling

When ParallelToolCalls is enabled in AgentConfig and the LLM returns
2+ tool calls, execute them concurrently via errgroup. Results are
collected in original order for deterministic observe-phase behavior.

Sequential execution remains the default. Parallel mode is opt-in
per agent configuration to avoid side effects with stateful tools.

Refactors executeToolCalls into composable helpers (runToolCall,
executeSingleToolCall, executeToolCallsParallel) for testability.

Fixes #707
This commit is contained in:
Rene Zander
2026-03-29 06:42:02 +00:00
committed by lyingbug
parent 2a3cc92b99
commit 309fc7b42b
2 changed files with 228 additions and 129 deletions
+4
View File
@@ -54,6 +54,10 @@ type AgentConfig struct {
// The agent compresses older messages to stay within this limit,
// preserving tool_call/tool_result pairs.
MaxContextTokens int `json:"max_context_tokens,omitempty"`
// Whether to execute independent tool calls in parallel (default: false).
// When enabled and the LLM returns multiple tool calls, they run concurrently via errgroup.
ParallelToolCalls bool `json:"parallel_tool_calls,omitempty"`
}
// SessionAgentConfig represents session-level agent configuration