- Extract src/lib/agent/ bounded context with types, registry, messaging - Add comments_count to BeadIssue for SSE comment detection - Create batch endpoints for mail/reservations APIs - Add memory validation to session-preflight - Remove unused empty dirs (mockup, sessions, timeline) - Move stashes to docs/references, gitignore them
3.8 KiB
Agent State and Liveness
This reference explains how agents report live status in BeadBoard using bd agent and bd slot.
Why This Exists
Two things must always be visible:
- Current execution state (idle, working, blocked, done, etc.)
- Current work attachment (which bead the agent is actively hooked to)
If either signal is missing, orchestration quality drops.
State Model (ZFC)
Use bd agent state <agent-bead-id> <state> with these values:
idle: no current task, waiting for assignmentspawning: session boot and environment checks in progressrunning: agent process is healthy and activeworking: agent is actively executing claimed bead workstuck: blocked and requires external interventiondone: finished current assignment and ready to close outstopped: clean shutdown or deliberate pausedead: missed heartbeat long enough to be considered dead (Witness timeout path)
Command Examples for State Transitions
Session start:
bd agent state bb-silver-scribe spawning
bd agent state bb-silver-scribe running
Work claim:
bd update beadboard-123 --status in_progress --assignee bb-silver-scribe
bd slot set bb-silver-scribe hook beadboard-123
bd agent state bb-silver-scribe working
Blocked condition:
bd agent state bb-silver-scribe stuck
bd mail send --to cobalt-ridge --bead beadboard-123 --category BLOCKED --subject "Waiting on schema" --body "Need migration direction before continuing."
Work completion:
bd agent state bb-silver-scribe done
bd slot clear bb-silver-scribe hook
Session end:
bd agent state bb-silver-scribe stopped
Inspect current state:
bd agent show bb-silver-scribe
Heartbeats
Use bd agent heartbeat <agent-bead-id> to refresh last_activity without changing state.
bd agent heartbeat bb-silver-scribe
Daemon agents (persistent processes):
- Normal work: every 5 minutes
- High-risk long operations: every 2-3 minutes
- Immediately before long test/build phases
- Immediately after recovering from interruptions
LLM agents (Claude Code, turn-based):
- At turn start (when picking up work)
- Immediately before long-running commands
- Inter-turn silence is expected and not a health signal
Witness Death Timeout
If heartbeats are missed long enough, the Witness/monitoring path can treat the agent as dead and surface dead state.
Operational interpretation:
stale: heartbeat lag is visible, but agent may recoverevicted: prolonged lag, high confidence agent is unhealthyidle/dead: no reliable active signal remains
Agent-side rule:
- If you are alive and still executing, heartbeat before anyone has to guess.
Current status: The Witness enforcement layer is not yet running. Heartbeats are recorded in
last_activityand visible in the BeadBoard dashboard but are not currently auto-enforced. Agents will not be auto-markeddead. Daemon implementation is a future epic.
Slot Operations (Current Work Attachment)
The hook slot links an agent bead to the active task bead.
Show slots:
bd slot show bb-silver-scribe
Attach current work:
bd slot set bb-silver-scribe hook beadboard-123
Detach on completion or handoff:
bd slot clear bb-silver-scribe hook
Important slot constraints:
hookis single-cardinality; clear before replacing- stale hooks create misleading UI and should be cleared promptly
BLOCKED Signal Standard
When blocked:
- Set state to stuck (
bd agent state ... stuck) - Send explicit BLOCKED coordination event (
bd mail send --category BLOCKED ...) - Keep heartbeat active while waiting
- Resume with
running/workingonce unblocked
This sequence ensures both machine-readable telemetry and human-readable intervention context.