Skip to main content
The Tool Execution & Sandbox System is the security boundary of Palyra. It ensures that any action requested by an LLM (a “tool call”) is validated against user policies, executed within a restricted environment, and audited with cryptographic attestations. This system bridges the gap between natural language intent and safe code execution.

System Architecture

The execution pipeline follows a strict Decide → Approve → Execute flow. When an orchestrator receives a tool call request, it passes through the tool_protocol.rs logic which coordinates with the Policy Engine and the Sandbox Runner.

Tool Execution Flow

The following diagram illustrates how a tool call moves from the GatewayService through the safety checks to final execution. Sources: crates/palyra-daemon/src/tool_protocol.rs#210-215, crates/palyra-daemon/src/tool_protocol.rs#335-345, crates/palyra-policy/src/lib.rs#211-215

3.1 Tool Protocol & Approval Flow

The tool_protocol.rs module defines the contract for tool execution. Every tool call is assigned a ToolAttestation palyra-daemon/src/tool_protocol.rs#73-80, which includes a SHA-256 hash of the execution results and details about the sandbox enforcement used. If a tool is marked as “sensitive” or involves capabilities like ProcessExec or Network palyra-daemon/src/tool_protocol.rs#46-52, the system triggers an approval flow. This requires a human operator to grant permission via the Web Console or CLI before the execute_tool_call function palyra-daemon/src/tool_protocol.rs#446-450 is invoked. For details, see Tool Protocol & Approval Flow. Sources: crates/palyra-daemon/src/tool_protocol.rs#1-150, crates/palyra-daemon/src/tool_protocol.rs#446-550

3.2 Policy Engine (Cedar)

Palyra uses the Cedar Policy Language (via the palyra-policy crate) to define fine-grained access control. The engine evaluates a PolicyRequest palyra-policy/src/lib.rs#11-15 against a set of store policies.
Policy ComponentDescription
PrincipalThe identity requesting the tool (e.g., a specific user or device) palyra-policy/src/lib.rs#36-38.
ActionThe operation being performed (e.g., tool.execute, memory.search) palyra-policy/src/lib.rs#108-115.
ResourceThe target of the action (e.g., a specific skill or tool name).
ContextMetadata such as channel_id, device_id, and capabilities palyra-policy/src/lib.rs#18-26.
For details, see Policy Engine (Cedar). Sources: crates/palyra-policy/src/lib.rs#1-180

3.3 Sandbox Tiers & Process Runner

Execution safety is enforced through tiered sandboxing provided by sandbox_runner.rs and the palyra-sandbox crate. The system also enforces an Interpreter Denylist palyra-daemon/src/sandbox_runner.rs#30-44 (preventing direct execution of shells like bash or pwsh) and strict Egress Enforcement Modes palyra-daemon/src/sandbox_runner.rs#47-51 to prevent data exfiltration. For details, see Sandbox Tiers & Process Runner. Sources: crates/palyra-daemon/src/sandbox_runner.rs#25-60, crates/palyra-sandbox/src/lib.rs#1-100

3.4 WASM Plugin System & Skills

The most secure way to extend Palyra is through Skills. Skills are packaged as WebAssembly (WASM) modules and executed by the wasm_plugin_runner.rs using wasmtime. The WASM environment is “deny-by-default.” Plugins can only access host functions (like networking or filesystem) if explicitly granted in the skill.toml manifest and allowed by the WasmPluginRunnerPolicy palyra-daemon/src/tool_protocol.rs#115-127. This provides Tier-A isolation, where the code has no direct access to the host OS. For details, see WASM Plugin System & Skills. Sources: crates/palyra-daemon/src/tool_protocol.rs#173-185, crates/palyra-daemon/src/wasm_plugin_runner.rs#1-50

Child Pages