Approval Workflow Overview
When an agent proposes a tool execution that is marked as sensitive or falls outside current policy allowlists, thepalyrad daemon suspends the run and creates an ApprovalRecord crates/palyra-daemon/src/journal.rs#58-69. This record acts as a pending request that must be resolved by an authorized principal before the agent can continue.
High-Level Data Flow
The following diagram illustrates the lifecycle of an approval from tool proposal to execution. Diagram: Tool Approval Lifecycle Sources: crates/palyra-daemon/src/gateway.rs#77-82, crates/palyra-daemon/src/journal.rs#58-69, apps/web/src/chat/useChatRunStream.ts#159-161Decision Scopes and Persistence
Operators can choose the duration and breadth of an approval. These scopes are defined in theApprovalDecisionScope enum crates/palyra-daemon/src/journal.rs#57-59.
| Scope | Code Identifier | Description |
|---|---|---|
| Once | once | Valid only for the specific proposal_id currently requested apps/web/src/chat/chatShared.tsx#81. |
| Session | session | Valid for the current session_id for the remainder of the interaction apps/web/src/chat/chatShared.tsx#81. |
| Timeboxed | timeboxed | Valid across all sessions for a specific duration (TTL), typically 5 minutes apps/web/src/chat/chatShared.tsx#28. |
Decision Caching
The daemon maintains an internal cache of active approvals to minimize database lookups during high-frequency tool calls. The cache capacity is governed byAPPROVAL_DECISION_CACHE_CAPACITY crates/palyra-daemon/src/gateway.rs#102.
Sources: crates/palyra-daemon/src/gateway.rs#102, crates/palyra-daemon/src/journal.rs#57-59, apps/web/src/chat/chatShared.tsx#27-28
Implementation Entities
The HITL system is implemented across theJournalStore for persistence and the Gateway for real-time signaling.
Diagram: Approval Entity Relationship
Sources: crates/palyra-daemon/src/journal.rs#58-71, crates/palyra-daemon/src/gateway.rs#57-63
Key Functions
create_approval_record: Triggered by the orchestrator whenpalyra_policyreturns a decision requiring human intervention crates/palyra-daemon/src/gateway.rs#23.resolve_approval: Validates the operator’s decision and updates theJournalStorecrates/palyra-daemon/src/gateway.rs#58.tool_policy_snapshot: Captures the state of the policy engine at the time of the request to ensure auditability crates/palyra-daemon/src/gateway.rs#79.
Console Approval UI
The Web Console provides an interactive interface for managing pending approvals via theChatConsolePanel apps/web/src/chat/ChatConsolePanel.tsx#81.
UI Components
- ApprovalRequestControls: A specialized form component apps/web/src/chat/chatShared.tsx#141-221 that allows operators to:
- Select the Scope (once, session, timeboxed) apps/web/src/chat/chatShared.tsx#161-176.
- Provide a Reason for the audit log apps/web/src/chat/chatShared.tsx#189-199.
- Set a TTL for timeboxed approvals apps/web/src/chat/chatShared.tsx#177-188.
- Transcript Integration: Pending requests appear as
approval_requestentries in theChatTranscriptapps/web/src/chat/chatShared.tsx#88.
State Management
TheuseChatRunStream hook manages the local state of pending approvals using approvalDrafts apps/web/src/chat/ChatConsolePanel.tsx#146. When an operator clicks “Approve” or “Deny”, the decideInlineApproval function is called apps/web/src/chat/ChatConsolePanel.tsx#160, which transmits the decision via the ConsoleApiClient.
Sources: apps/web/src/chat/ChatConsolePanel.tsx#81-160, apps/web/src/chat/chatShared.tsx#141-221
CLI Approval Commands
Thepalyra CLI provides a set of commands for auditing and resolving approvals from the terminal. These commands are defined in the approvals module crates/palyra-cli/src/commands/approvals.rs.
Command Tree
palyra approvals list: Displays all pending and historical approval records.palyra approvals approve <id>: Grants permission for a specific record.palyra approvals deny <id>: Rejects a specific record.palyra approvals export: Exports the approval history in NDJSON format for external auditing crates/palyra-daemon/src/gateway.rs#111-113.
Constraints and Safety
- NDJSON Schema: Exports follow the
palyra.approvals.export.ndjson.v1schema crates/palyra-daemon/src/gateway.rs#111. - Pagination: Listing approvals is subject to
MAX_APPROVAL_PAGE_LIMIT(500 records) crates/palyra-daemon/src/gateway.rs#108. - Export Limits: Bulk exports are capped at
MAX_APPROVAL_EXPORT_LIMIT(5,000 records) crates/palyra-daemon/src/gateway.rs#109.