[BUG] Agent tool with team_name returns err=True but still spawns agent, causing silent duplicate launches
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
When using the Agent tool with a team_name parameter, if the team registration step fails (e.g., due to a stale/mismatched team state), the tool returns err=True with "Team does not exist. Call spawnTeam first." — however the background agent process is actually spawned and running.
This causes the orchestrating model to correctly interpret the error as a failed launch and retry, resulting in N duplicate agents consuming quota simultaneously for the same task.
In one session, this caused 3× duplication of 3 impl tasks (9 agent runs instead of 3), consuming ~3× the expected Opus quota in a 6-minute window.
What Should Happen?
Either return success (agent launched, registration optional), or roll back the spawn if registration fails — but never return an error while silently leaving the agent running.
Error Messages/Logs
"Team does not exist. Call spawnTeam first."
Steps to Reproduce
- Create a team with TeamCreate
- Launch background agents via Agent tool with team_name set
- If team state goes stale mid-session, subsequent Agent calls return err=True but still spawn
- Model retries → duplicate agents run concurrently
Claude Model
Opus
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
2.1.92
Platform
Google Vertex AI
Operating System
Ubuntu/Debian Linux
Terminal/Shell
VS Code integrated terminal
Additional Information
_No response_
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗