Drop agent-run lease and add approval resume

The worker leaned on a lease plus a heartbeat goroutine and a stale
recovery sweep to reclaim runs from crashed workers. That machinery
raced with long LLM and tool calls and conflated graceful stops with
failures. Remove the lease columns, heartbeat, and stale recovery, and
rely on FOR UPDATE SKIP LOCKED for single-claim plus explicit state
transitions: a graceful suspend returns the run to PENDING and a crash
now leaves it RUNNING for manual recovery.

Treat an approval interruption as a known stop that parks the run in
AWAITING_APPROVAL, and add SubmitApproval to merge human decisions into
the checkpoint and requeue the run to PENDING. The decisions must cover
exactly the pending approvals, since a missing one would resume as an
implicit denial. Expose this through the submitAgentRunApproval
mutation.

Signed-off-by: Bryan Frimin <bryan@probo.com>
This commit is contained in:
Bryan Frimin
2026-06-08 14:51:12 +02:00
parent 98a8d90391
commit c14bacb157
9 changed files with 398 additions and 363 deletions

View File

@@ -58,3 +58,24 @@ type AgentRunEdge {
cursor: CursorKey!
node: AgentRun!
}
extend type Mutation {
submitAgentRunApproval(
input: SubmitAgentRunApprovalInput!
): SubmitAgentRunApprovalPayload!
}
input AgentRunApprovalDecisionInput {
toolCallId: String!
approved: Boolean!
reason: String
}
input SubmitAgentRunApprovalInput {
agentRunId: ID!
decisions: [AgentRunApprovalDecisionInput!]!
}
type SubmitAgentRunApprovalPayload {
agentRun: AgentRun!
}