Repository navigation
Description
Summary
The first agent in a pack — always the master (e.g. specifier) that reads the board card and drives handoffs — intermittently never starts. Its agent process never launches; the tmux pane is left at the shell prompt with the launch command typed but not executed (and sometimes mangled into a broken continuation line). Because the master is dead, no card is read and every downstream role idles forever waiting for a handoff. To the operator, ./swarm + Open Project simply "does nothing."
Root cause
launch-role! in swarmforge/scripts/swarmforge.bb sends the launch command with a single tmux send-keys <command> "Enter":
(sh "tmux" "-S" (:tmux-socket ctx) "send-keys" "-t"
(tmux-agent-target display (:tmux-pane-base-index ctx) session)
command "Enter")The master's pane is the first shell on a cold tmux server. With a non-trivial prompt (starship / powerlevel10k / any async zsh prompt), the prompt is still initializing when send-keys fires, so the keystrokes land during a prompt redraw: the trailing Enter is swallowed (and occasionally a character is dropped, producing an unterminated-quote continuation line). Roles at index ≥ 1 start on a now-warm server and reliably succeed — which is why only the master fails.
Because the timing depends on prompt init of a cold server, no fixed delay is reliable — SWARMFORGE_AGENT_START_DELAY_MS reduces the frequency but does not eliminate it. (It also guards the delay with (when (pos? index) ...), so the master gets no delay at all.)
Reproduction
- Shell with a non-instant prompt (zsh + starship/p10k).
./swarm, then Open Project.- Inspect the master pane:
tmux -S <socket> list-panes -t swarmforge-<master> -F '#{pane_current_command}'→zsh(should be the agent, e.g.claude).- No agent process for that role; other roles are running.
- The pane shows the full launch command sitting un-executed (or a broken continuation line).
- Manually sending
Enter/ re-running the command in the now-initialized shell launches the agent and it reads the card — confirming the command is correct; only its delivery at cold boot was lost.
Fix (adaptive, self-healing)
Send the command and its Enter as separate keystrokes, then verify the agent actually took over the pane (pane_current_command is no longer a shell) and re-send if not — up to a retry cap. This adapts to any prompt speed instead of guessing a delay. Also delay before every role (including index 0) so the cold master shell gets the same head start.
New env knobs: SWARMFORGE_AGENT_LAUNCH_RETRIES (default 8), SWARMFORGE_AGENT_ENTER_DELAY_MS (default 400).
Verification
With the patch, a cold ./swarm + Open Project launched all four roles with pane_current_command = <agent> (no zsh left behind), the master (specifier) read the board card, dry-checked it, and handed off to coder (card moved specifier → coder lane), which then began working — i.e. the full pipeline flows on the first try.
Environment
- macOS (Darwin), zsh with an async prompt (starship/p10k)
- Babashka v1.13.219, tmux 3.x
- Agent backend: Claude Code v2.1.252
- Affected: any pack whose first role is the master (observed on the four-pack)
PR with the fix: to follow.
Activity
Add pane-block watchdog (unclebob#69), launch-race retry (unclebob#67)…