diff --git a/.story_kit/work/1_upcoming/172_bug_setup_command_failure_prevents_agent_from_starting_creating_unrecoverable_deadlock.md b/.story_kit/work/1_upcoming/172_bug_setup_command_failure_prevents_agent_from_starting_creating_unrecoverable_deadlock.md new file mode 100644 index 0000000..470f657 --- /dev/null +++ b/.story_kit/work/1_upcoming/172_bug_setup_command_failure_prevents_agent_from_starting_creating_unrecoverable_deadlock.md @@ -0,0 +1,35 @@ +--- +type: bug +title: Setup command failure prevents agent from starting, creating unrecoverable deadlock +--- + +# Bug 172: Setup command failure prevents agent from starting, creating unrecoverable deadlock + +## Description + +When an agent dies mid-edit and leaves the worktree in a non-compiling state, the retry loop deadlocks: + +1. Coder PTY dies mid-edit → worktree has broken build +2. Pipeline retries → calls `create_worktree` which calls `run_setup_commands` +3. `run_setup_commands` includes `pnpm run build`, which fails because the worktree has a build error +4. Setup failure propagates via `?` → agent never spawns → empty log → marked failed +5. Auto-assign retries → goto 2, forever + +The agent is the only thing that can fix the build error, but it can never start because the build error prevents it from starting. + +## Fix + +Make `run_setup_commands` non-fatal. Log a warning if any setup command fails, but don't prevent the agent from starting. The agent can run `pnpm install` / `pnpm build` itself if needed. + +## Key files + +- `server/src/worktree.rs:82` — `run_setup_commands` call on worktree reuse path (propagates error with `?`) +- `server/src/worktree.rs:98` — `run_setup_commands` call on fresh worktree path (propagates error with `?`) +- `server/src/worktree.rs:261` — `run_setup_commands` implementation + +## Acceptance Criteria + +- [ ] Setup command failures are logged as warnings, not fatal errors +- [ ] Agent PTY spawns even if setup commands fail +- [ ] Agent can still fix build errors in its worktree +- [ ] All tests pass