System Overview
When thepalyrad orchestrator encounters a request that requires human-in-the-loop (HITL) intervention (determined by palyra-policy), it suspends the current RunStream and creates an ApprovalRecord in the JournalStore. The run remains in a Pending state until a decision is submitted via the gRPC ApprovalsService or the Web Console.
Key Entities
| Entity | Description | Code Reference |
|---|---|---|
ApprovalRecord | The persisted state of an approval request, including subject details and decision. | crates/palyra-daemon/src/journal.rs#604-630 |
ApprovalSubjectType | Categorization of the action being approved (Tool, Secret, Browser, etc.). | crates/palyra-daemon/src/journal.rs#570-580 |
DecisionScope | Defines the longevity of the approval (Once, Session, or Timeboxed). | crates/palyra-daemon/src/journal.rs#585-595 |
ApprovalResolveRequest | The payload sent by an operator to grant or deny an approval. | crates/palyra-daemon/src/journal.rs#720-735 |
Approval Subjects and Risk Levels
The system classifies approvals based on theApprovalSubjectType. This allows the UI to render specific prompts (e.g., showing the specific tool arguments or the secret name being requested).
Tool: Execution of a specific tool call (e.g.,shell_execute,filesystem_write).SecretAccess: Request to retrieve a value from theVault.BrowserAction: High-risk automation likeClickorTypeon sensitive domains.DevicePairing: Authorizing a new node or CLI to connect to the Gateway.
Risk Assessment
Each request is assigned anApprovalRiskLevel (crates/palyra-daemon/src/journal.rs#597-602), typically Low, Medium, or High. This level influences how prominently the request is displayed in the operator’s queue.
Sources: crates/palyra-daemon/src/journal.rs#570-602, crates/palyra-daemon/src/gateway.rs#78-81
Data Flow: From Tool Proposal to Approval Decision
The following diagram illustrates the transition from an LLM proposing a tool call to the system pausing for human intervention. Title: Tool Approval Sequence Sources: crates/palyra-daemon/src/gateway.rs#77-81, crates/palyra-daemon/src/journal.rs#63-71, crates/palyra-daemon/src/orchestrator.rs#77-80Decision Scopes and Persistence
Operators can choose how long an approval remains valid using theApprovalDecisionScope. This reduces “approval fatigue” by caching decisions.
Once: The decision applies only to the specificapproval_id.Session: The decision applies to all identical subjects within the currentOrchestratorSession.Timeboxed: The decision is valid globally for a specific duration (e.g., 1 hour), stored with a TTL.
Implementation in Gateway
TheGatewayRuntimeState maintains an APPROVAL_DECISION_CACHE_CAPACITY (crates/palyra-daemon/src/gateway.rs#102) to check for existing session-scoped or timeboxed approvals before creating a new record.
Sources: crates/palyra-daemon/src/journal.rs#585-595, crates/palyra-daemon/src/gateway.rs#102-115
Technical Implementation: gRPC and CLI
TheApprovalsServiceClient provides the interface for external tools to interact with the approval queue.
Key gRPC Methods
ListApprovals: Filters byprincipal,subject_type, ordecisionstatus. crates/palyra-cli/src/commands/approvals.rs#35-70GetApproval: Retrieves full context, including theApprovalPromptRecord. crates/palyra-cli/src/commands/approvals.rs#71-89ResolveApproval: Submits the human decision (Allow/Deny). crates/palyra-cli/src/commands/approvals.rs#136-163
CLI Usage
Thepalyra CLI implements the ApprovalsCommand (crates/palyra-cli/src/args/approvals.rs#4-61) to allow operators to manage the queue from the terminal.