Team agents fail to start: tmux send-keys race condition with shell initialization
Summary
When spawning team agents via Teammate tool, the agent processes fail to start because tmux send-keys sends the command before the shell (zsh) in the newly created tmux pane has finished initializing.
Steps to Reproduce
- Start Claude Code
- Use the
Teammatetool to spawn a team (spawnTeam) - Use the
Tasktool withteam_nameto spawn teammates - Observe the tmux panes created for each teammate
Expected Behavior
Each tmux pane should execute the agent command and start the Claude Code agent process.
Actual Behavior
The tmux panes are created and the command text appears in each pane, but the command is never actually executed. The shell prompt (~ >) appears immediately, indicating the shell became interactive but the command was not processed. The agent processes never start.
Screenshot showing the issue (3 agent panes all showing the command text but dropped to shell prompt):
── zsh ──
n-research --agent-name geography-researcher --team-name japan-research --agent-color blue --parent-session-id cc486c6d-c672-4b07-835e-fc03eb419c4b --agent-type general-purpose --model haiku
~ > 08:35:40
All 3 panes show the same pattern: command text displayed but not executed.
Root Cause Analysis
Looking at the binary source, the flow is:
tmux split-windowcreates a new panetmux send-keysimmediately sends the agent command + Enter
There appears to be no delay or readiness check between creating the pane and sending keys. When using zsh (which loads .zshrc, plugins, etc.), the shell initialization takes time. The send-keys arrives before zsh is ready to accept input, so the keystrokes are either lost or displayed without execution.
Suggested Fix
Options:
- Add a small delay (e.g.,
sleep 0.5) betweensplit-windowandsend-keys - Use
tmux split-window "command"to pass the command directly as part of pane creation (this runs the command as the pane's initial process) - Poll for shell readiness before sending keys (e.g., check if the pane has a prompt)
Environment
- Claude Code version: 2.1.32
- OS: macOS (Darwin 25.2.0)
- Shell: zsh
- tmux: installed via Homebrew
This issue has 13 comments on GitHub. Read the full discussion on GitHub ↗