[BUG] Agent tool spawns 7 named teammates for a single routine task; nested spawning burns 77% of 5h limit in <1 hour
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?
Claude Code v2.1.207, Opus 4.8, Max 5x plan, macOS.
CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS enabled.
A multi-step task issued 7 Agent tool calls. Six were plain subagents with
explicit cheap models (Explore/Haiku, general-purpose/Haiku, /Sonnet) and
behaved fine.
The 7th call passed a name parameter ("gate-impl"), which makes it a
teammate rather than a subagent. Two things then went wrong:
- Its agent type (
flutter-app-developer) had notools:restriction in its
definition, so it silently inherited spawn-capable tools (Agent/Task/
SendMessage) — and recursively spawned agents of its own.
- It had no
model:set, so it inherited Opus for every nested agent.
There is no recursion-depth cap, no fan-out cap, and no warning before an
agent tree consumes a large share of the session limit.
Session log evidence:
grep -c '"name":"Agent"' -> 7
grep -c 'TaskCreate|TaskUpdate|SendMessage' -> 57
wc -l -> 1577
du -h -> 7.0M
Result: ~77% of the 5-hour limit and ~8% of the weekly limit consumed in under
one hour. Second occurrence in two weeks. Quota is not recoverable.
What Should Happen?
- Hard recursion-depth cap on agent spawning (default 1). A spawned agent
should not be able to spawn further agents unless explicitly opted in.
- Omitting
tools:in an agent definition should NOT silently grant
spawn-capable tools (Agent/Task/SendMessage). Spawn tools should be
opt-in, not inherited by default.
- A guardrail before an agent tree consumes a large fraction of the session
or weekly limit — warn, or require confirmation, rather than silently
burning through it.
- Ideally: a fan-out cap, and a visible running cost indicator while an
agent tree is active.
Error Messages/Logs
Steps to Reproduce
- Enable agent teams:
~/.claude/settings.json
{ "env": { "CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS": "1" } }
- Define an agent WITHOUT a
tools:restriction and WITHOUT amodel:field.
.claude/agents/impl-agent.md
---
name: impl-agent
description: Implements application code.
---
You implement code. Report files changed and test results.
(No tools: -> inherits all tools, including Agent/Task/SendMessage.
No model: -> inherits the main session model, i.e. Opus.)
- Start a session on Opus 4.8 and give it a multi-step task large enough that
it decides to delegate — e.g. "investigate these two repos, plan a fix,
file the tickets, then implement the fix in a worktree."
- Let the lead delegate. It will issue several plain subagent calls (fine),
and at least one Agent call that passes a name parameter — which makes
that one a teammate rather than a subagent.
- Observe: the named teammate, having inherited spawn-capable tools, spawns
further agents of its own. There is no depth cap and no fan-out cap.
- Inspect the session log:
SESSION=$(ls -t ~/.claude/projects//.jsonl | head -1)
grep -c '"name":"Agent"' "$SESSION" # -> 7
grep -c 'TaskCreate\|TaskUpdate\|SendMessage' "$SESSION" # -> 57
wc -l "$SESSION" # -> 1577
du -h "$SESSION" # -> 7.0M
The Agent call with a name field is the one that cascades:
{"subagent_type":"flutter-app-developer","name":"gate-impl","prompt":"..."}
The other six carry an explicit cheap model (haiku/sonnet) and no name,
and they behave correctly.
- Check /cost or the limit indicator: ~77% of the 5-hour limit and ~8% of the
weekly limit gone in under an hour.
Claude Model
Opus
Is this a regression?
No, this never worked
Last Working Version
_No response_
Claude Code Version
2.1.207
Platform
Other
Operating System
macOS
Terminal/Shell
Other
Additional Information
Agent definitions in use (.claude/agents/):
- flutter-app-developer : no
tools:, nomodel:<- the one that cascaded - (others: Explore, Plan, general-purpose — built-in, behaved correctly)
The six well-behaved Agent calls each passed an explicit cheap model
(haiku / sonnet) and NO name parameter. The single cascading call passedname: "gate-impl" and no model.
Two independent contributing factors, either of which alone would have
limited the damage:
(a) name param promotes the call to a teammate, which retains spawn tools
(b) omitting tools: in the agent definition grants Agent/Task/SendMessage
Not a one-off: a comparable runaway burn occurred the previous week on an
earlier 2.1.x, though I did not capture logs at the time.
Full session log available (7.0MB); can provide the 7 Agent invocations
as a redacted excerpt on request.
This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗