Agent Teams (in-process mode): teammates systematically duplicated, causing 2x token usage

Resolved 💬 3 comments Opened Mar 10, 2026 by hatawong Closed May 11, 2026

Summary

When using Agent Teams (CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1) in in-process mode, the Lead systematically creates each teammate twice, causing every task to be fully executed 2x and doubling token consumption. The user has no visibility into this duplication.

Reproduction

Setup: Lead is instructed to sequentially create 3 teammates (restorer → auditor → evolver), each reading a prompt file, executing a task, and writing a report file.

Three rounds of experiments were conducted:

| Round | Dispatch Mode | Expected Subagents | Actual Subagents | User Interaction |
|---|---|---|---|---|
| 1 | SubAgent (no Agent Teams) | 3 | 4 (1 user-interrupted retry) | Yes |
| 2 | Agent Teams in-process | 3 | 7 | Possible |
| 3 | Agent Teams in-process | 3 | 6 | None — hands off keyboard entirely |

Round 3 Detail (human factor excluded)

6 subagent JSONL files found in the Leader session's subagents/ directory. Each role was created exactly twice:

| Role | Copy A (tool calls / JSONL size) | Copy B (tool calls / JSONL size) |
|---|---|---|
| Restorer | ~10 calls / ~153KB | ~11 calls / ~155KB |
| Auditor | ~42 calls / ~563KB | ~43 calls / ~566KB |
| Evolver | ~13 calls / ~287KB | ~14 calls / ~290KB |

Both copies of each role performed full execution (read prompt, read docs, write report) — not empty shells or communication stubs. The later copy overwrote the earlier copy's output file.

Token Impact

  • Round 1 (SubAgent, 4 agents): Leader 404KB + SubAgents 604KB = 1,008KB
  • Round 2 (Agent Teams, 7 agents): Leader 90KB + SubAgents 2,130KB = 2,220KB (2.2x)
  • Round 3 (Agent Teams, 6 agents): Similar to Round 2

Without duplication (3 agents instead of 6), estimated consumption would be ~900–1000KB, matching Round 1. The entire 2x overhead comes from duplicate teammate creation.

Key Characteristics

  1. User-invisible: In in-process mode, the user sees normal execution flow with no indication that each role ran twice
  2. Correct final output: The later copy overwrites the earlier copy's report file, so the final reports are correct
  3. Systematic, not random: Both Agent Teams rounds exhibited exact doubling; Round 1 (plain SubAgent mode) did not
  4. Not user-triggered: In Round 3, the user did not touch the keyboard at all during execution

Steps to Reproduce

  1. Enable CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1
  2. Start a session where the Lead creates a team and spawns teammates sequentially via the Agent tool (with team_name + name parameters)
  3. Each teammate should perform observable work (read files, write output)
  4. After completion, check the subagents/ directory in the Leader's session folder — each role will have 2 JSONL files instead of 1

Environment

  • Claude Code version: 2.1.72
  • OS: macOS Darwin 25.2.0
  • Terminal: iTerm2
  • teammateMode: Not explicitly set (defaults to auto, falls back to in-process)
  • Teammate creation: Lead uses TeamCreate to create the team, then Agent tool with team_name + name to spawn teammates

Additional Data

I have the full JSONL session files (Leader + all 6 subagent files from Round 3) available if helpful for debugging. Happy to share them.

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗