Add agent run supervisor worker

Poll-based supervisor that claims PENDING agent runs with FOR UPDATE
SKIP LOCKED, runs them with lease-based heartbeat, and handles
graceful shutdown. On infrastructure stop the row stays RUNNING so
stale recovery resets it to PENDING on restart; Restore picks up
from the last checkpoint. Heartbeat loss cancels execution without
committing a terminal status.

Signed-off-by: Aurélien Sibiril <81782+aureliensibiril@users.noreply.github.com>
This commit is contained in:
Aurélien Sibiril
2026-04-10 18:53:29 +02:00
parent 2f2b8fe6aa
commit e831ee3c63
4 changed files with 422 additions and 8 deletions

View File

@@ -35,7 +35,7 @@ type (
// Approval-interrupted checkpoints carry pending tool calls.
PendingToolCalls []llm.ToolCall `json:"pending_tool_calls,omitempty"`
PendingApprovals []llm.ToolCall `json:"pending_approvals,omitempty"`
ApprovalInput map[string]ApprovalResult `json:"approval_input,omitempty"`
ApprovalInput map[string]ApprovalResult `json:"approval_input,omitempty"` // keyed by tool call ID
// Nested agent-as-tool suspension: one entry per suspended inner agent.
AllToolCalls []llm.ToolCall `json:"all_tool_calls,omitempty"`