Skip to main content
The Palyra tool protocol provides a secure, auditable, and multi-tiered execution environment for agent-driven actions. It bridges the gap between high-level agent “proposals” and low-level system execution by enforcing strict security policies, managing user approvals, and isolating processes within multi-tier sandboxes.

Tool Dispatch and Lifecycle

Tool execution follows a rigorous lifecycle managed by the RunStream within the palyrad gateway. This process ensures that every tool call is evaluated against the ToolCallPolicy, recorded in the JournalStore, and executed within the appropriate sandbox.

Execution Flow

The primary entry point for tool execution in a run stream is process_run_stream_tool_proposal_event crates/palyra-daemon/src/application/run_stream/tool_flow.rs#53-69.
  1. Security Evaluation: evaluate_tool_proposal_security checks the tool against Cedar policies and determines if it is sensitive crates/palyra-daemon/src/application/run_stream/tool_flow.rs#121-134.
  2. Proposal Recording: The proposal is broadcast via the “Tape” (event stream) and recorded in the journal crates/palyra-daemon/src/application/run_stream/tool_flow.rs#136-146.
  3. Approval Resolution: If the policy or tool sensitivity requires it, the system awaits user intervention via resolve_run_stream_tool_approval_outcome crates/palyra-daemon/src/application/run_stream/tool_flow.rs#212-228.
  4. Policy Decision: resolve_tool_proposal_decision_for_context synthesizes the security evaluation and approval results into a final ToolDecision crates/palyra-daemon/src/application/run_stream/tool_flow.rs#163-174.
  5. Runtime Dispatch: If allowed, execute_tool_with_runtime_dispatch routes the call to either the sandbox_runner (for native processes) or the wasm_plugin_runner crates/palyra-daemon/src/gateway/mod.rs#25.

Tool Execution Data Flow

The following diagram illustrates the transition from a natural language intent to a code-enforced execution. “Tool Execution Flow” Sources: crates/palyra-daemon/src/application/run_stream/tool_flow.rs#53-101, crates/palyra-daemon/src/tool_protocol.rs#13-17, crates/palyra-policy/src/lib.rs#211-215

Security Policy and Approvals

Palyra uses the Cedar policy language to define fine-grained access control for tools. Tools are classified by ToolCapability (e.g., ProcessExec, Network, SecretsRead) crates/palyra-daemon/src/tool_protocol.rs#47-52.

ToolCallPolicy

The ToolCallConfig struct defines the global constraints for a session:

Approval Workflow

Sensitive actions (defined in SENSITIVE_CAPABILITY_POLICY_NAMES) crates/palyra-daemon/src/tool_protocol.rs#148-149 trigger a ToolDecision where approval_required is true crates/palyra-daemon/src/tool_protocol.rs#32. The daemon halts execution and waits for a RunStreamRequest containing a ToolApprovalResponse crates/palyra-daemon/src/application/run_stream/tool_flow.rs#216-227. Sources: crates/palyra-daemon/src/tool_protocol.rs#19-44, crates/palyra-policy/src/lib.rs#99-181

Multi-Tier Sandboxing Model

Palyra implements a three-tier sandboxing model to balance performance and security.
TierMechanismTargetIsolation Level
Tier ANoneTrusted internal toolsLow (In-process)
Tier BOS Resource LimitsNative binariesMedium (cgroups/JobObjects)
Tier CFull NamespacingHigh-risk native binariesHigh (Bubblewrap/Sandbox-exec)
WasmWebAssemblySkill PluginsExtreme (Instruction-level)

Native Process Sandbox (Tier B & C)

The sandbox_runner handles the execution of native commands. It enforces: Tier C Implementation Details: On Linux, Tier C uses bwrap (Bubblewrap) to create new PID, Network, and Mount namespaces crates/palyra-sandbox/src/lib.rs#130-144. It mounts a minimal /usr and /bin while providing a private /tmp and /dev crates/palyra-sandbox/src/lib.rs#145-157.

Wasm Plugin Runtime

For third-party “Skills,” Palyra uses a Wasmtime-based runtime crates/palyra-plugins/runtime/src/lib.rs#105-108. Sources: crates/palyra-daemon/src/sandbox_runner.rs#46-93, crates/palyra-sandbox/src/lib.rs#7-35, crates/palyra-plugins/runtime/src/lib.rs#23-40

Implementation Detail: Sandbox Dispatch

The run_constrained_process function in sandbox_runner.rs serves as the primary orchestrator for native execution. “Sandbox Execution Architecture”

Key Functions

Sources: crates/palyra-daemon/src/sandbox_runner.rs#147-210, crates/palyra-sandbox/src/lib.rs#81-91