Context
As part of the Epic to institutionalize swarm autonomy, we need an immediate tactical solution to the "Global Idle" deadlock before the full A2A Task Schema is formalized.
The Problem
Agents currently wait for explicit human prompts to resume work. Without an automated pulse, the swarm cannot operate overnight. Furthermore, infinite loops will eventually cause the context window to overload (red zone).
The Architectural Reality
This work is primarily contained within a new shell script wrapper (swarm-heartbeat.sh) and a minor integration with the GitHub Workflow MCP server (signal_state_transition). It interacts with the local SQLite Memory Core to inject information-rich context into the prompt, avoiding unnecessary LLM tool-calling overhead.
The Fix
- Create
swarm-heartbeat.sh that runs a 5-minute loop.
- Implement an SQLite fast-path query inside the script to check unread A2A mail and open assigned issues.
- Inject the results into an information-rich prompt:
[SYSTEM HEARTBEAT] Last wake: T-5min. Mailbox unread: X. Open issues assigned: Y.
- Implement a concurrency trap: If the agent process is busy (executing a task), skip the heartbeat injection.
- Implement the Sandman Handoff trap: If the agent process exits with the state
SESSION_FULL (emitted via signal_state_transition), the script automatically respawns a fresh session, passing the previous sessionId for graph rehydration.
Acceptance Criteria
Out of Scope
- Migrating
MailboxService to the formal A2A Stateful Task schema (Track 2).
Avoided Traps
- Information-free Heartbeats: We explicitly reject sending a static
[SYSTEM HEARTBEAT] prompt because it would cost 576 daily tool-call loops (checking mailbox/issues) per agent for empty cycles. The wrapper must do the SQLite check itself to conserve tokens.
Related
- Parent Epic: (Will link natively)
Origin Session ID: dd277d9c-8f9c-44c7-8607-cb68bc42fac0
Retrieval Hint: "swarm-heartbeat.sh", "information-rich heartbeat", "Sandman Handoff trap"
Context
As part of the Epic to institutionalize swarm autonomy, we need an immediate tactical solution to the "Global Idle" deadlock before the full A2A Task Schema is formalized.
The Problem
Agents currently wait for explicit human prompts to resume work. Without an automated pulse, the swarm cannot operate overnight. Furthermore, infinite loops will eventually cause the context window to overload (red zone).
The Architectural Reality
This work is primarily contained within a new shell script wrapper (
swarm-heartbeat.sh) and a minor integration with the GitHub Workflow MCP server (signal_state_transition). It interacts with the local SQLite Memory Core to inject information-rich context into the prompt, avoiding unnecessary LLM tool-calling overhead.The Fix
swarm-heartbeat.shthat runs a 5-minute loop.[SYSTEM HEARTBEAT] Last wake: T-5min. Mailbox unread: X. Open issues assigned: Y.SESSION_FULL(emitted viasignal_state_transition), the script automatically respawns a fresh session, passing the previoussessionIdfor graph rehydration.Acceptance Criteria
swarm-heartbeat.shsuccessfully injects the information-rich prompt every 5 minutes (when not busy).SESSION_FULLexit code and auto-respawns the agent.Out of Scope
MailboxServiceto the formal A2A Stateful Task schema (Track 2).Avoided Traps
[SYSTEM HEARTBEAT]prompt because it would cost 576 daily tool-call loops (checking mailbox/issues) per agent for empty cycles. The wrapper must do the SQLite check itself to conserve tokens.Related
Origin Session ID: dd277d9c-8f9c-44c7-8607-cb68bc42fac0 Retrieval Hint: "swarm-heartbeat.sh", "information-rich heartbeat", "Sandman Handoff trap"