1. Action Statuses
Actions represent individual API calls intercepted or logged during an agent session.Stored Action Statuses
The database stores one of six status values on each action:The CLEARED Status Flow
When an action is explicitly configured with requiresApproval in wrap():
- The SDK logs the action as
PENDING_APPROVAL(before-execution approval). - A reviewer approves the request via dashboard or API.
- The backend transitions the action to
CLEARED. - The SDK receives
APPROVEDfrom polling, executes the local SDK call, and sendsPATCH /sessions/:id/actions/:actionIdwithstatus: SUCCESS(transitioning action toSUCCESS). - If local execution fails, the approved action stays
CLEARED(neverSUCCESS, never rolled back automatically). The SDK logs a separate failed action (status: FAILED), andGET /approvalsmarks the approved action asunconfirmed: trueafter 1 hour if execution is not confirmed.
2. Session Statuses
Sessions group actions and track overall agent execution.Stored Session Statuses
The database persists one of five raw session statuses:Derived Display Statuses
When querying sessions (GET /sessions or GET /sessions/:id), the backend dynamically computes a displayStatus based on action states in priority order:
3. Rollback Rules
The following rules govern session rollback behavior across AgentRein:- Caller Authorization: Agent callers may trigger rollback only on
ACTIVEsessions. Operator callers may trigger rollback on sessions with stored statusACTIVE,FAILED,COMPLETED, orABANDONED. - Required Actions: A session can only be rolled back if it has at least one action with status
SUCCESS. Sessions already inREVERTEDdisplay status cannot be rolled back. - Sandbox Behavior: Rolling back a sandbox session converts all
SUCCESSandPENDING_APPROVALactions in bulk toROLLED_BACKin a single transaction; no real compensation logic runs. - Execution Chain: Rollback iterates backwards through executed
SUCCESSactions. If an individual undo operation fails, the rollback chain halts immediately. - Declined Rollback Approval: If a reviewer declines a rollback approval request, the action’s undo status is set to
DECLINEDwhile its execution status remainsSUCCESS(preserving its side-effects), and the overall session status becomesFAILED. - Pending and Cleared Actions: Actions in
PENDING_APPROVALorCLEAREDstatus are never rolled back; if rollback completes while such actions remain, the parent session status is left unchanged.
4. Approval Requests
Approval requests track human-in-the-loop review operations.Approval Statuses
Approval Purposes
- Before-Execution Approval: Pre-execution gate created when an action is declared in
requiresApproval. Approval transitions action toCLEARED. Rejection transitions action toFAILEDand triggers session rollback. - After-Execution Approval: Post-execution gate created after-the-fact when a standard logged action matches a policy with
REQUIRE_APPROVAL. Approval updates action toSUCCESS. Rejection triggers single-action rollback. - Rollback Approval: Gate created during action rollback when an action’s compensation configuration specifies
requireApproval: true. Approval resumes compensation execution, while rejection sets the action’s undo status toDECLINEDand transitions the parent session toFAILED.
Approval Fields & Unconfirmed Flag
GET /approvals returns an array of objects containing the following fields: approvalId, actionId, apiName, operationType, sessionId, agentId, payloadSummary, requestedAt, timeoutAt, timeRemaining, status, resolvedAt, resolvedBy, reason, actionStatus, and unconfirmed.
unconfirmed: trueif the action is currentlyCLEAREDand was approved over 1 hour ago without the SDK confirming execution.