claude-code - 💡(How to fix) Fix [BUG] Agent tool with team_name returns err=True but still spawns agent, causing silent duplicate launches [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#48227Fetched 2026-04-15 06:29:36
View on GitHub
Comments
1
Participants
2
Timeline
6
Reactions
0
Author
Participants
Timeline (top)
labeled ×5commented ×1

Error Message

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. 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

Code Example

"Team does not exist. Call spawnTeam first."
RAW_BUFFERClick to expand / collapse

Preflight Checklist

  • I have searched existing issues and this hasn't been reported yet
  • This is a single bug report (please file separate reports for different bugs)
  • 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

  1. Create a team with TeamCreate
  2. Launch background agents via Agent tool with team_name set
  3. If team state goes stale mid-session, subsequent Agent calls return err=True but still spawn
  4. 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

extent analysis

TL;DR

The Agent tool should be modified to either return success when the agent is launched but team registration fails, or roll back the spawn if registration fails, to prevent duplicate agents from consuming quota simultaneously.

Guidance

  • Investigate the Agent tool's error handling to determine why it returns an error while still spawning the agent process when team registration fails.
  • Consider modifying the Agent tool to catch the "Team does not exist" error and either return success or roll back the spawn, as described in the "What Should Happen?" section.
  • Review the orchestrating model's retry logic to ensure it can handle cases where the Agent tool returns success even if team registration fails.
  • Verify that the modified Agent tool behaves correctly in scenarios where team registration fails, to prevent duplicate agents from being spawned.

Example

No code snippet is provided, as the issue does not include sufficient code details.

Notes

The root cause of the issue appears to be related to the Agent tool's error handling and the orchestrating model's retry logic. However, without more information about the Agent tool's implementation, it is difficult to provide a more specific solution.

Recommendation

Apply a workaround by modifying the Agent tool to handle team registration failures correctly, as this is likely to be a more immediate solution than waiting for a potential fix in a future version.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

claude-code - 💡(How to fix) Fix [BUG] Agent tool with team_name returns err=True but still spawns agent, causing silent duplicate launches [1 comments, 2 participants]