Skip to content

fix(agents): route spawn tool to target agent#2790

Open
bogdanovich wants to merge 1 commit intosipeed:mainfrom
bogdanovich:fix/spawn-target-agent-routing
Open

fix(agents): route spawn tool to target agent#2790
bogdanovich wants to merge 1 commit intosipeed:mainfrom
bogdanovich:fix/spawn-target-agent-routing

Conversation

@bogdanovich
Copy link
Copy Markdown

Summary

  • pass the spawn tool's optional agent_id through to sub-turn execution
  • run the child turn with the requested agent's model, tools, workspace, skills, and injected files
  • return an explicit error when the requested target agent does not exist
  • mark background spawn sub-turns as critical so they can continue after the parent turn finishes

Problem

The spawn tool already exposes an agent_id parameter and validates it with the configured allowlist, but the actual sub-turn execution ignored the target agent. The child turn was created from the parent/default agent instead, so spawn(agent_id: "...") could acknowledge the target while still running with the wrong agent configuration.

That breaks multi-agent setups where agents intentionally have different tools, workspaces, skills, or models.

Fix

This PR adds AgentID to the tool/agent sub-turn config path and resolves the target agent inside spawnSubTurn. If no agent_id is provided, behavior remains unchanged: the child turn uses the parent agent and falls back to the default agent.

Validation

go test ./pkg/tools ./pkg/agent -run 'TestSpawnTool|TestSubTurn|TestSpawn|SubTurn'
go test ./pkg/tools ./pkg/agent

@afjcjsbx
Copy link
Copy Markdown
Collaborator

afjcjsbx commented May 7, 2026

Hello! Thanks for the PR. In the meantime, #2531 (#2531) was merged, your pull request now has merge conflicts. Could you please perform a rebase to resolve them? 🙏

@bogdanovich bogdanovich force-pushed the fix/spawn-target-agent-routing branch from 813ede3 to b3c1fd7 Compare May 7, 2026 20:33
@bogdanovich
Copy link
Copy Markdown
Author

I updated this PR branch on top of the latest upstream/main and resolved the subturn conflict so the target-agent routing change applies cleanly again.

Validation rerun on the rebased branch:

  • go test ./pkg/tools -run TestSpawn -count=1
  • go test ./pkg/agent -run SubTurn -count=1

The branch should no longer be in a conflicting state.

@bogdanovich bogdanovich force-pushed the fix/spawn-target-agent-routing branch from b3c1fd7 to 1615c02 Compare May 8, 2026 06:11
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.

2 participants