Skip to content

[BUG] Team agent teammates don't inherit [1m] context window variant from leader (v2.1.80) #36670

Closed as not planned

Description

@anascleaning

Bug Description

Team agent teammates (spawned via TeamCreate + Agent with team_name) inherit the leader's model ID (claude-opus-4-6) but NOT the [1m] context window variant. The leader runs on claude-opus-4-6[1m] (1M context), but spawned teammates resolve to claude-opus-4-6 (200k context).

This is distinct from #32368 (model ID inheritance, fixed in v2.1.72) — the model ID inherits correctly, but the context window modifier is stripped.

Steps to Reproduce

  1. Start Claude Code on Max plan — /model shows "Default (recommended) — Opus 4.6 with 1M context" selected
  2. Configure ~/.claude/settings.json:
{
  "model": "opus[1m]",
  "env": {
    "CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS": "1",
    "CLAUDE_CODE_SUBAGENT_MODEL": "opus[1m]",
    "ANTHROPIC_DEFAULT_OPUS_MODEL": "claude-opus-4-6[1m]"
  }
}
  1. Create a team: TeamCreate
  2. Spawn a teammate: Agent with team_name parameter
  3. In the teammate's pane, run /model

Expected Behavior

Teammate's /model shows option 1: "Default (recommended) — Opus 4.6 with 1M context" ✔

Actual Behavior

Teammate's /model shows option 5: "Opus 4.6 — claude-opus-4-6" selected (200k, no 1M)

The teammate's system prompt confirms: "You are powered by the model named Opus 4.6. The exact model ID is claude-opus-4-6." — no [1m] suffix.

Notes

  • Standalone subagents (no team_name) DO correctly inherit opus[1m] via CLAUDE_CODE_SUBAGENT_MODEL — their system prompt shows claude-opus-4-6[1m]
  • Team teammates spawned via TeamCreate + Agent(team_name=...) do NOT pick up CLAUDE_CODE_SUBAGENT_MODEL, model, or ANTHROPIC_DEFAULT_OPUS_MODEL for the [1m] variant
  • The model ID itself inherits correctly (teammates get claude-opus-4-6, not a different model) — only the [1m] context modifier is lost
  • v2.1.72 changelog says "Fixed team agents to inherit the leader's model" — this fixed the model ID but not the context window variant

Environment

  • Claude Code: v2.1.80
  • Plan: Claude Max
  • OS: macOS (Darwin 25.3.0, M5 Max)
  • Terminal: iTerm2 with tmux teammate mode
  • Leader model: claude-opus-4-6[1m] (confirmed via /model → option 1)

Related Issues

Activity

  1. added
    bug
    has repro
    platform:macos
    on Mar 20, 2026
  2. anascleaning commented on Mar 20, 2026

    @anascleaning
    Author

    Additional Finding

    After removing ALL model-related env vars and settings from ~/.claude/settings.json (no model, no CLAUDE_CODE_SUBAGENT_MODEL, no ANTHROPIC_DEFAULT_OPUS_MODEL), Claude Code v2.1.80 still appends --model claude-opus-4-6 to the teammate spawn command.

    The spawn command observed:

    cd /Users/.../project && env CLAUDECODE=1 CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1 \
      /Users/.../.local/share/claude/versions/2.1.80 \
      --agent-id model-final-check@model-test-final \
      --agent-name model-final-check \
      --team-name model-test-final \
      --agent-color blue \
      --parent-session-id <id> \
      --agent-type code-searcher \
      --dangerously-skip-permissions \
      --model claude-opus-4-6    <-- always appended, always strips [1m]
    

    Manual test confirms the fix: when --model claude-opus-4-6 is manually removed from the spawn command, the teammate starts with Default (option 1 in /model picker = Opus 4.6 with 1M context on Max plan).

    Root cause: The teammate spawn logic reads the parent's resolved model ID but strips the [1m] context window modifier before passing it via --model. The fix should either:

    1. Preserve the [1m] suffix: --model claude-opus-4-6[1m]
    2. Or omit --model entirely when the parent is on Default, letting the teammate inherit Default naturally

    This is not a configuration issue — no user-side settings can work around it.

  3. Butanium commented on Mar 25, 2026

    @Butanium

    Still experiencing this on v2.1.x — teammates spawn with 200k context even though the leader session runs opus[1m]. Would love to see this fixed!

    🤖 Generated with Claude Code

  4. anascleaning commented on Mar 26, 2026

    @anascleaning
    Author

    Workaround: CLI Source Patch (until officially fixed)

    Since no user-side configuration can fix this (as noted above), I've been running a post-install CLI patch that intercepts the agent spawn points and appends [1m] when the model is claude-opus-4-6.

    Why env vars don't work

    The parent session resolves the model ID before spawning the child process. So even with:

    • ANTHROPIC_DEFAULT_OPUS_MODEL=claude-opus-4-6[1m]
    • CLAUDE_CODE_SUBAGENT_MODEL=opus[1m]
    • model: "opus[1m]" in settings.json

    ...the parent still passes --model claude-opus-4-6 (no [1m]) to the teammate spawn command. The env vars help the parent session but don't propagate to child processes through the spawn path.

    The patch

    Save as ~/bin/patch-claude-1m.sh and run after every npm install -g @anthropic-ai/claude-code:

    #!/bin/bash
    # Patch Claude Code CLI to pass [1m] context to agent spawns
    # Must re-run after every Claude Code update
    
    CLI="/opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js"
    # Linux users: adjust path, typically /usr/lib/node_modules/...
    
    if [ ! -f "$CLI" ]; then
        echo "CLI not found at $CLI"; exit 1
    fi
    
    cp "$CLI" "${CLI}.orig"  # Backup
    
    python3 -c "
    import re
    
    with open('$CLI', 'r') as f:
        content = f.read()
    
    # Find agent spawn patterns where --model is passed and append [1m]
    # The minified CLI passes model like: --model \${func([varName])}
    patched = content.replace(
        'claude-opus-4-6\"',
        'claude-opus-4-6[1m]\"'
    )
    
    # Count replacements
    diff = len(patched) - len(content)
    if diff == 0:
        # Try alternate pattern for newer versions
        patched = re.sub(
            r'(model[\"\\x27]?:\s*[\"\\x27]claude-opus-4-6)([\"\\x27])',
            r'\1[1m]\2',
            content
        )
        diff = len(patched) - len(content)
    
    if diff == 0:
        print('No patterns found — CLI format may have changed')
        exit(1)
    
    with open('$CLI', 'w') as f:
        f.write(patched)
    
    print(f'Patched (delta: {diff} chars)')
    "
    echo "Done ✓ — verify with: grep -c '1m' $CLI"

    Caveats

    • Fragile — operates on minified JS. Variable names and string patterns change between versions.
    • Must re-run after every Claude Code update (npm install -g @anthropic-ai/claude-code).
    • Verify after patching: spawn a teammate and check its system prompt for claude-opus-4-6[1m][1m] (the model ID line). If you see plain claude-opus-4-6, the patch didn't match.
    • This is a workaround, not a fix. The proper fix is for the spawn logic to preserve the [1m] suffix (or omit --model when parent is on Default).

    Impact

    With the patch applied, agent teammates get 1M context — which is significant for complex multi-file tasks. Without it, teammates hit the 200K wall and lose context on large codebases.

    @Butanium this should work for your setup too — adjust the CLI path for your platform.

  5. jonleung commented on Apr 5, 2026

    @jonleung

    Configuration workaround confirmed on v2.1.92 — no binary patching needed:

    1. Add `"teammateDefaultModel": null` to `~/.claude.json`
    2. Run `/model opus[1m]` in the lead session (NOT "Default (recommended)")
    3. Don't pass `model` parameter when spawning teammates

    Teammates correctly get 1M context in tmux after this. Credit to @Reasonably (#34421) for discovering this approach. Full details and test matrix on #34421.

  6. oconnorjoseph commented on Apr 21, 2026

    @oconnorjoseph

    Running into the same [1m]-stripping on team teammates on our end at BluMint. When our leader (running claude-opus-4-7[1m]) spawns a teammate via Agent({team_name: ...}), the teammate's system prompt reports claude-opus-4-7 with no [1m] suffix — confirmed via self-introspection in the spawned agent. The model ID inherits but the context-window modifier is lost, matching exactly what you observed on v2.1.80.

    This clusters with #45169, #51254, and #40929 around subagent model-config plumbing — different entry points (Agent tool, team spawn, subagent frontmatter, env var) all fail to preserve the [1m] variant. Would very much appreciate a cohesive fix across the subagent spawn paths.

  7. added
    stale
    on May 13, 2026
  8. kcarriedo commented on May 17, 2026

    @kcarriedo

    This bites in a particularly nasty way because the symptom is silent — the teammate hits 200k, compacts, and the lead synthesizes the compacted result not realizing it was working with 1/5 the window it was supposed to have. The output looks fine until you cross-check what the teammate actually had access to.

    A quick diagnostic if it's useful to the team triaging this: after spawning, ask the teammate to print process.env.CLAUDE_MODEL (or whatever the effective model env var is in the teammate's process) — if the [1m] suffix is being stripped at spawn time vs. resolved later, this should show it directly without needing to trigger compaction.

    For people hitting this in the meantime: explicitly passing the model with the [1m] suffix in the Agent tool call (rather than relying on inheritance) does propagate correctly in our testing. Ugly, but it's a reliable workaround until the inheritance path is fixed — you just have to remember to update every teammate-spawn site when you swap models.

    The deeper architectural question this raises: when a team lead's effective context budget differs from teammates', "synthesize results" becomes lossy in a way that's invisible to the user. Worth surfacing teammate context size in the team status output even after this is fixed, since the same asymmetry can show up via other paths (e.g. teammates spawned with --model overrides).

  9. removed
    stale
    on May 17, 2026
  10. added
    stale
    on Jun 2, 2026
  11. github-actions commented on Jun 17, 2026

    @github-actions

    Closing for now — inactive for too long. Please open a new issue if this is still relevant.

  12. github-actions commented on Aug 19, 2026

    @github-actions

    This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.

  13. locked as resolved and limited conversation to collaborators on Aug 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:agentsbughas reproplatform:macosstale

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions