Team agents fail to start: tmux send-keys race condition with shell initialization

Resolved 💬 13 comments Opened Feb 5, 2026 by ikeda-tomoya-swx Closed Mar 25, 2026

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

  1. Start Claude Code
  2. Use the Teammate tool to spawn a team (spawnTeam)
  3. Use the Task tool with team_name to spawn teammates
  4. 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:

  1. tmux split-window creates a new pane
  2. tmux send-keys immediately 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) between split-window and send-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

View original on GitHub ↗

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