Skip to content

Commit cdea53e

Browse files
steveyeggeclaude
andcommitted
fix(done): make gt done resilient to missing agent beads
If the agent bead doesn't exist when gt done tries to clear the hook, return early instead of failing. This happens for polecats created before identity beads existed. gt done must be resilient and forgiving - the important thing is work gets submitted to merge queue, not that cleanup succeeds. Fixes: hq-i26n2 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent b0f377f commit cdea53e

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

internal/cmd/done.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,18 @@ func updateAgentStateOnDone(cwd, townRoot, exitType, _ string) { // issueID unus
438438
// BUG FIX (gt-vwjz6): Close hooked beads before clearing the hook.
439439
// Previously, the agent's hook_bead slot was cleared but the hooked bead itself
440440
// stayed status=hooked forever. Now we close the hooked bead before clearing.
441-
if agentBead, err := bd.Show(agentBeadID); err == nil && agentBead.HookBead != "" {
441+
//
442+
// BUG FIX (hq-i26n2): Check if agent bead exists before clearing hook.
443+
// Old polecats may not have identity beads, so ClearHookBead would fail.
444+
// gt done must be resilient - missing agent bead is not an error.
445+
agentBead, err := bd.Show(agentBeadID)
446+
if err != nil {
447+
// Agent bead doesn't exist - nothing to clear, that's fine
448+
// This happens for polecats created before identity beads existed
449+
return
450+
}
451+
452+
if agentBead.HookBead != "" {
442453
hookedBeadID := agentBead.HookBead
443454
// Only close if the hooked bead exists and is still in "hooked" status
444455
if hookedBead, err := bd.Show(hookedBeadID); err == nil && hookedBead.Status == beads.StatusHooked {

0 commit comments

Comments
 (0)