[BUG] Agent-teams: iterm2 teammate spawn command is truncated when injected into a new terminal tab
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?
Hi,
tldr is agent teams mode with iterm2 fails when the settings are too long.
It cuts the command at exactly 1024 bytes, preventing the new iterm2 tab from being created successfully. When the full commands gets below 1024 bytes, it opens successfully.
This is problematic because some integrations run Claude Code through a wrapper script that automatically set up a bunch of environmnent flags onto Claude Code, which are not possible to be removed easily. This means that for all employees of big companies, the team feature in iterm2 cannot work out of the box.
Repro video:
https://github.com/user-attachments/assets/b0a87763-55b2-4798-8eec-ae4aeecbe78a
---
Summary
With experimental agent teams enabled (CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1), spawning a teammate opens a new iTerm2 tab and injects the full launch command as inline text. That command is very long (it embeds the entire --settings '{...}' JSON blob on the command line) and gets truncated mid-argument before the shell finishes reading it. Because the cut happens inside the single-quoted --settings value, the quote is never closed, so zsh drops to its cmdand quote> continuation prompt and waits forever. claude is never executed — the teammate silently fails to launch.
Separately, the injected command contains no --model flag, so a per-spawn model override (e.g. requesting a teammate on Haiku) is dropped — the teammate inherits the ambient/default model instead.
Environment
- Claude Code: 2.1.215 (Amazon toolbox binary)
- Binary: single-file Bun-compiled Mach-O arm64 (247 MB,
__BUNsegment) — not a plain Node script - OS: macOS 26.5.1 (arm64)
- Terminal: iTerm.app
- Shell: zsh 5.9
- Flags in the spawn env:
CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1,CLAUDE_CODE_USE_BEDROCK=1,AWS_REGION=us-west-2
Reproduction
- Launch Claude Code with a ton of settings / environment variables:
``sh``
CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1 claude --dangerously-skip-permissions --settings '{"teammateMode":"iterm2","HELLOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO1":"1","HELLOOOOOOOOOOOOOO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OOOOOOOOOOOOOOOOO52":"1"}'
- Ask the lead to spawn a teammate
> can you spawn a teammate that says hello (to test) - A new iTerm2 tab opens and an inline command is typed/pasted into it.
- Notice that the command is too big and is broken at 1024 bytes.
Observed
The injected command is cut off inside the --settings JSON. Example (two separate spawns — note the cut point moves, indicating a length/timing truncation, not fixed content):
env CLAUDECODE=1 CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1 ... \
/Users/<me>/.toolbox/tools/claude-code/2.1.215.559/claude \
--agent-id Greeter3@session-320aeb42 --agent-name Greeter3 \
--team-name session-320aeb42 --agent-color cyan \
--parent-session-id 5d548c73-... --agent-type general-purpose \
--dangerously-skip-permissions --effort high \
--settings '{"env":{"CLAUDE_CODE_USE_BEDROCK":"1",...,"CLAUDE_CODE_ENABLE_AUTO_MODE":"1","AW <-- TRUNCATED HERE
Another spawn truncated at ..."CLAUDE_CODE_ENABLE_AUTO_MODE":"1"," and yet another at ..."1","AWS_SDK_UA. The trailing % (zsh "no newline" marker) confirms the line ends mid-stream. The shell then shows:
cmdand quote>
cmdand quote>
…i.e. an unterminated single quote from the --settings '{... argument. claude never runs.
Notably, the injected command has no --model flag anywhere, so per-teammate model selection is silently ignored.
Impact
- New-tab teammate spawns fail entirely (shell hangs on an unterminated quote). The in-process teammate path is unaffected and works.
- Per-spawn model override for teammates does not take effect (no
--modelemitted).
Root cause (likely)
The teammate launch command is delivered by typing/pasting the entire command inline into the new terminal tab. The long --settings JSON pushes the line past a send-text length limit (iTerm2 injection), truncating it. Because the payload is single-quoted, any truncation leaves the quote open and wedges the shell.
Suggested fix
Don't inject a giant inline command. Write the long/volatile args to a temp file and inject a short command that reads them. Verified working locally:
Launcher (/tmp/spawn-teammate.sh) — the only thing injected into the tab is bash /tmp/spawn-teammate.sh:
#!/bin/zsh
set -e
source /tmp/teammate-vars.sh # short: agent-id/name/team/color/parent/type
SETTINGS_JSON="$(cat /tmp/teammate-settings.json)" # the long blob, off the command line
exec env CLAUDECODE=1 CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1 CLAUDE_CODE_USE_BEDROCK=1 \
AWS_REGION=us-west-2 CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1 \
DISABLE_ERROR_REPORTING=1 DISABLE_TELEMETRY=1 \
"$CLAUDE_BIN" \
--agent-id "$AGENT_ID" --agent-name "$AGENT_NAME" --team-name "$TEAM_NAME" \
--agent-color "$AGENT_COLOR" --parent-session-id "$PARENT_SESSION_ID" \
--agent-type "$AGENT_TYPE" --dangerously-skip-permissions --effort high \
--settings "$SETTINGS_JSON"
Running this short command in a fresh tab launched a real teammate that joined the team successfully — confirming the truncation is purely a function of inline-command length, and that moving the long payload to a file resolves it.
Alternatively: pass --settings as a file path (e.g. --settings-file <path>) instead of an inline JSON string, and always emit the requested --model flag.
Two bugs, to be clear
- Truncation / shell hang — inline injected spawn command is cut off, leaving an unterminated quote. (Primary.)
- Missing
--model— per-teammate model override is never emitted in the spawn command, so it's silently ignored.
What Should Happen?
Claude teammate should appear in a new iterm2 tab successfully
Error Messages/Logs
N/A
Steps to Reproduce
Add a bunch of flags to environment variables, ask Claude
spawn a teammate that says hello
Notice new iterm2 tab doesn't open claude.
Claude Model
Opus
Is this a regression?
No, this never worked
Last Working Version
_No response_
Claude Code Version
claude 2.1.217.573 (ASBX Claude Code, channel stable)
Platform
AWS Bedrock
Operating System
macOS
Terminal/Shell
iTerm2
Additional Information
_No response_
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗