Skip to main content
The Tool Protocol is the central mechanism for governing how agents interact with the host system and external services. It integrates budget tracking, cryptographic attestations, and a multi-layered authorization engine powered by Cedar Policy.

Tool Execution Lifecycle

The execution of a tool follows a strict sequence of validation, authorization, and attestation. This flow is managed primarily within process_run_stream_tool_proposal_event crates/palyra-daemon/src/application/run_stream/tool_flow.rs#53-101.

1. Proposal and Security Evaluation

When an agent proposes a tool call, the system first evaluates the security context using evaluate_tool_proposal_security crates/palyra-daemon/src/application/run_stream/tool_flow.rs#121-134. This checks if the tool is allowlisted and if it requires explicit user approval.

2. Authorization (Cedar Policy)

The daemon uses the palyra-policy crate to evaluate the request against Cedar policies. The core function evaluate_with_context crates/palyra-policy/src/lib.rs#217-218 constructs a Cedar request containing:

3. Approval Workflow

If a tool is marked as sensitive (e.g., process_exec or network), the policy engine may require an ApprovalDecision crates/palyra-daemon/src/application/approvals/mod.rs#32-64.

4. Execution and Attestation

Once authorized, the tool is dispatched to the appropriate runtime (Sandbox Process Runner or WASM Plugin). Upon completion, a ToolAttestation is generated crates/palyra-daemon/src/tool_protocol.rs#73-80. This record includes the execution_sha256 hash, the executor used, and the sandbox_enforcement level applied crates/palyra-daemon/src/tool_protocol.rs#75-80.

Tool Flow and Code Entity Mapping

The following diagram bridges the natural language concepts of “Request” and “Approval” to the specific Rust entities that handle them. Diagram: Tool Authorization and Execution Flow Sources: crates/palyra-daemon/src/application/run_stream/tool_flow.rs#53-101, crates/palyra-daemon/src/application/approvals/mod.rs#100-135, crates/palyra-daemon/src/tool_protocol.rs#73-80, crates/palyra-policy/src/lib.rs#217-218

Tool Capabilities and Metadata

Tools are categorized by their capabilities, which dictate the level of sandboxing and the policy constraints applied.
CapabilityPolicy NameDescription
ProcessExecprocess_execExecution of OS binaries/scripts.
NetworknetworkOutbound network access.
SecretsReadsecrets_readAccess to the Palyra Vault.
FilesystemWritefilesystem_writeModifying files within the workspace.
Sources: crates/palyra-daemon/src/tool_protocol.rs#47-64

ToolCallConfig and Budgeting

The ToolCallConfig crates/palyra-daemon/src/tool_protocol.rs#19-26 defines the runtime limits for a specific agent run: Sources: crates/palyra-daemon/src/tool_protocol.rs#19-26

Cedar Policy Implementation

Palyra uses a baseline Cedar policy set defined in DEFAULT_POLICY_SRC crates/palyra-policy/src/lib.rs#99-187.

Default Policy Rules

  1. Deny Sensitive: Forbids any action marked as sensitive if allow_sensitive_tools is false in the context crates/palyra-policy/src/lib.rs#100-105.
  2. Allow Read-Only: Permits safe actions like tool.list or daemon.status without extra checks crates/palyra-policy/src/lib.rs#107-118.
  3. Allowlisted Execution: Permits tool.execute only if the tool is in the allowlist and the principal/channel are authorized crates/palyra-policy/src/lib.rs#120-127.

Policy Context Construction

The PolicyRequestContext crates/palyra-policy/src/lib.rs#18-26 is populated before every evaluation. It includes dynamic flags such as is_allowlisted_tool and is_sensitive_action, which are derived from the ToolCallConfig and the requested tool’s ToolMetadata crates/palyra-daemon/src/tool_protocol.rs#66-70. Diagram: Policy Evaluation Data Flow Sources: crates/palyra-policy/src/lib.rs#18-38, crates/palyra-daemon/src/tool_protocol.rs#19-26, crates/palyra-daemon/src/tool_protocol.rs#66-70

Sandboxing and Enforcement Modes

When a tool requires ProcessExec, the run_constrained_process function crates/palyra-daemon/src/sandbox_runner.rs#147-151 applies the configured SandboxProcessRunnerPolicy crates/palyra-daemon/src/sandbox_runner.rs#81-93.

Egress Enforcement

The system supports three modes for network isolation:
  1. None: No network restrictions.
  2. Preflight: Validates requested hosts against an allowlist before execution but does not enforce at the OS level crates/palyra-daemon/src/sandbox_runner.rs#49.
  3. Strict: Uses Tier C backends (e.g., LinuxBubblewrap) to provide kernel-level network isolation crates/palyra-daemon/src/sandbox_runner.rs#50.

Tier C Backends

Tier C backends provide the highest level of isolation by leveraging platform-specific features: Sources: crates/palyra-daemon/src/sandbox_runner.rs#47-61, crates/palyra-daemon/src/sandbox_runner.rs#81-93, crates/palyra-sandbox/src/lib.rs#8-13