close
Skip to content

feat: support parallel tool calling#835

Merged
lyingbug merged 1 commit intoTencent:mainfrom
renezander030:feat/707-parallel-tool-calls
Mar 30, 2026
Merged

feat: support parallel tool calling#835
lyingbug merged 1 commit intoTencent:mainfrom
renezander030:feat/707-parallel-tool-calls

Conversation

@renezander030
Copy link
Copy Markdown
Contributor

Summary

  • 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

Changes

  • internal/types/agent.go: add ParallelToolCalls bool config field
  • internal/agent/act.go: refactor executeToolCalls into composable helpers (runToolCall, executeSingleToolCall, executeToolCallsParallel) for parallel support and testability

Design decisions

  • Best-effort strategy: a failing tool does not cancel siblings, partial results are collected
  • Event emission (tool-hint) happens inside each goroutine for real-time UI progress; result/exec events are emitted in original order after all goroutines complete
  • Uses golang.org/x/sync/errgroup (already in go.mod)
  • No behavioral change when ParallelToolCalls is false (default)

Test plan

  • Sequential mode: verify identical behavior with ParallelToolCalls: false
  • Parallel mode: configure 2+ independent tools, verify concurrent execution and correct result ordering
  • Failure handling: one tool timeout/error should not affect other tool results

Fixes #707

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 Tencent#707
@lyingbug lyingbug merged commit 309fc7b into Tencent:main Mar 30, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: 并行工具调用

2 participants