From cdea53e2217a2bf0b768a14e1d27f83c55c57607 Mon Sep 17 00:00:00 2001 From: mayor Date: Sun, 11 Jan 2026 23:10:34 -0800 Subject: [PATCH] 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 --- internal/cmd/done.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/internal/cmd/done.go b/internal/cmd/done.go index bf6b8bbc..f934e50c 100644 --- a/internal/cmd/done.go +++ b/internal/cmd/done.go @@ -438,7 +438,18 @@ func updateAgentStateOnDone(cwd, townRoot, exitType, _ string) { // issueID unus // BUG FIX (gt-vwjz6): Close hooked beads before clearing the hook. // Previously, the agent's hook_bead slot was cleared but the hooked bead itself // stayed status=hooked forever. Now we close the hooked bead before clearing. - if agentBead, err := bd.Show(agentBeadID); err == nil && agentBead.HookBead != "" { + // + // BUG FIX (hq-i26n2): Check if agent bead exists before clearing hook. + // Old polecats may not have identity beads, so ClearHookBead would fail. + // gt done must be resilient - missing agent bead is not an error. + agentBead, err := bd.Show(agentBeadID) + if err != nil { + // Agent bead doesn't exist - nothing to clear, that's fine + // This happens for polecats created before identity beads existed + return + } + + if agentBead.HookBead != "" { hookedBeadID := agentBead.HookBead // Only close if the hooked bead exists and is still in "hooked" status if hookedBead, err := bd.Show(hookedBeadID); err == nil && hookedBead.Status == beads.StatusHooked {