From 71a31899761d04eaad513c76f07267dfc96b3feb Mon Sep 17 00:00:00 2001 From: Dave Date: Fri, 27 Feb 2026 10:19:07 +0000 Subject: [PATCH] story-kit: create 231_bug_agent_silently_disappears_when_worktree_creation_fails --- ...disappears_when_worktree_creation_fails.md | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 .story_kit/work/1_upcoming/231_bug_agent_silently_disappears_when_worktree_creation_fails.md diff --git a/.story_kit/work/1_upcoming/231_bug_agent_silently_disappears_when_worktree_creation_fails.md b/.story_kit/work/1_upcoming/231_bug_agent_silently_disappears_when_worktree_creation_fails.md new file mode 100644 index 0000000..db1cc02 --- /dev/null +++ b/.story_kit/work/1_upcoming/231_bug_agent_silently_disappears_when_worktree_creation_fails.md @@ -0,0 +1,31 @@ +--- +name: "Agent silently disappears when worktree creation fails" +--- + +# Bug 231: Agent silently disappears when worktree creation fails + +## Description + +When `start_agent` spawns its background task and worktree creation fails (e.g. stale branch conflict from a previous worktree at a different path), the agent entry is silently removed from the pool. No ERROR log is written, the UI just shows the agent as idle, and the story sits in current with no agent. The failure is only observable by noticing the agent never appeared. + +## How to Reproduce + +1. Have a story (e.g. 218) with a branch that's already checked out in a worktree outside .story_kit/worktrees/ (e.g. /private/tmp/story-218-worktree) +2. Call start_agent for that story +3. start_agent returns pending successfully +4. Background task tries to create worktree, git fails with "branch already used by worktree at ..." +5. PendingGuard or the error handler removes the agent from the pool + +## Actual Result + +Agent silently disappears from the pool. No ERROR log line. UI shows agent as idle. Story stuck in current with no agent. + +## Expected Result + +Worktree creation failure should: 1) Log an ERROR with the git error message, 2) Surface the failure in the UI (agent card shows error state), 3) Ideally attempt to recover (e.g. prune stale worktrees or force-checkout) + +## Acceptance Criteria + +- [ ] Worktree creation failures are logged at ERROR level with the full error message +- [ ] The agent shows a failed/error state in the UI instead of disappearing +- [ ] The AgentEvent::Error broadcast is persisted in the agent's event_log so the UI can display it