Add timeout fallback for dead agents (gt-2hzl4)

- Add checkStaleAgents() to detect agents reporting "running" but not updating
- Add markAgentDead() to update agent bead state to "dead"
- Integrate stale agent check into heartbeat cycle
- DeadAgentTimeout set to 15 minutes

This is a safety mechanism for agents that crash without updating their state.
The daemon now marks them as dead so they can be restarted.

Also fixes duplicate AgentFields declaration - now uses beads.go version with
ParseAgentFieldsFromDescription alias in fields.go.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Steve Yegge
2025-12-28 01:55:52 -08:00
parent a1715fa91f
commit 597c6b8071
3 changed files with 96 additions and 95 deletions

View File

@@ -185,6 +185,10 @@ func (d *Daemon) heartbeat(state *State) {
// 4. Process lifecycle requests
d.processLifecycleRequests()
// 5. Check for stale agents (timeout fallback - gt-2hzl4)
// Agents that report "running" but haven't updated in too long are marked dead
d.checkStaleAgents()
// Update state
state.LastHeartbeat = time.Now()
state.HeartbeatCount++