feat(agent): let custom agents opt into parallel tool execution - #2716
Open
hjxccc wants to merge 1 commit into
Open
feat(agent): let custom agents opt into parallel tool execution#2716hjxccc wants to merge 1 commit into
hjxccc wants to merge 1 commit into
Conversation
AgentEngine.executeToolCalls already branches to executeToolCallsParallel when AgentConfig.ParallelToolCalls is set, and that branch is fully implemented (errgroup, ordered result collection, best-effort siblings). But nothing ever set the flag: buildAgentConfig copies CustomAgentConfig into the runtime AgentConfig field by field, and this field was missing from both structs' bridge. The gate therefore always read the zero value, making executeToolCallsParallel unreachable for every custom agent. Add ParallelToolCalls to CustomAgentConfig and map it in buildAgentConfig. Defaults to false: tools are not required to be side-effect free, so agents saved before this option existed must keep running their tools sequentially. Enabling concurrency for them silently would be a behavior change rather than a fix.
Author
|
友好 ping 一下 🙏 CI 全绿、无冲突。 一句话: 默认 false,存量智能体行为不变——工具不保证无副作用,所以必须显式 opt-in。 |
sakitam-fdd
added a commit
to sakitam-fdd/WeKnora
that referenced
this pull request
Aug 21, 2026
Port Tencent#2716 onto the current fork staging branch using GitHub's three-way merge.
sakitam-fdd
added a commit
to sakitam-fdd/WeKnora
that referenced
this pull request
Aug 21, 2026
Port Tencent#2716 after current-main three-way validation.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
AgentEngine.executeToolCallsalready branches toexecuteToolCallsParallelwhenAgentConfig.ParallelToolCallsis set (internal/agent/act.go:230), and that branch is fully implemented — errgroup, results collected in original order, siblings not cancelled on individual failure.But nothing ever sets the flag.
buildAgentConfigcopiesCustomAgentConfiginto the runtimeAgentConfigfield by field, and this field was missing from the bridge, so the gate always read the zero value:That single hit is
chat.Options.ParallelToolCalls(a*boolon the outbound LLM request) — a different struct.types.AgentConfig.ParallelToolCallshas no assignment anywhere, which makesexecuteToolCallsParallelunreachable for every custom agent.This PR adds
ParallelToolCallstoCustomAgentConfigand maps it inbuildAgentConfig, so the existing engine capability becomes reachable.Defaults to false. Tools are not required to be side-effect free, and agents that depend on tools observing each other's writes must keep running them sequentially. Turning concurrency on for already-saved agents would be a behaviour change rather than a fix, so opting in is explicit.
Type of Change
Related Issue
None — found while reading the agent execution path.
Testing
Go 1.26.0,
CGO_ENABLED=1:gofmt -l internal/types/custom_agent.go internal/application/service/session_agent_qa.go internal/application/service/agent_parallel_tool_calls_config_test.go— no outputgo vet ./internal/types/ ./internal/application/service/— cleango test ./internal/application/service/ -run ParallelToolCalls -count=1 -v— 3 cases passNew coverage mirrors the existing
agent_memory_config_test.go, which guards the same class of defect (a field silently absent frombuildAgentConfig's field-by-field copy):TestAgentConfigCarriesTheParallelToolCallsPreference— opted in / opted out both propagate.TestAgentConfigDefaultsParallelToolCallsOff— an agent that never set the field stays sequential.The focused packages were validated. Full-repository
make testwas not run; the change is two field additions plus their unit tests.Checklist
git diff --check origin/main...HEADpassesgo vetfor the changed packages)Screenshots / Recordings
Not applicable; backend-only change. No frontend toggle is included — the field is settable through the existing agent config API. Happy to add a UI control in the agent editor if maintainers would like it in the same PR.