What is a Policy?
A policy says: “When this type of action happens, do this.” Every tool call is evaluated against your policies to determine the outcome:How Policies Work
When a tool call comes in, Latch:- Classifies the action (read, write, execute, send, etc.)
- Finds matching policies based on upstream, tool, and action class
- Applies the most specific policy that matches
- Logs the decision to the audit log
Default Behavior
If no policies match, Latch defaults to Allow. We recommend adding explicit rules for high‑risk actions (execute/submit/send external) based on your risk tolerance.Creating a Policy
- Go to Policy Rules in the dashboard
- Click Create Rule
- Configure:
Example: Block All Shell Commands
Example: Require Approval for External Emails
Example: Allow Reads on Filesystem
Policy Precedence
When multiple policies could match, the most specific policy wins:Example
You have these policies:- “Allow all reads” (Action Class: READ, no upstream/tool)
- “Deny reads on secrets upstream” (Action Class: READ, Upstream: secrets)
- “Allow read_public_key tool” (Tool: read_public_key, Upstream: secrets)
read_public_key call on the secrets upstream:
- Policy 3 wins (most specific: tool + upstream)
read_private_key call on the secrets upstream:
- Policy 2 wins (upstream-specific beats global)
read_file call on the filesystem upstream:
- Policy 1 wins (only matching policy)
Scoping Policies
Policies can be scoped at different levels:Approval Workflow
When a policy requires approval:- The tool call pauses
- You receive a notification (dashboard, Telegram, etc.)
- You review the action and its arguments (redacted)
- You approve or deny
- If approved, the client retries with a one‑time token (some clients, like OpenClaw, can auto‑resume after approval by polling the approval status)
Approval Tokens
- Single-use: Each approval is valid for one retry only
- Argument-bound: The retry must have the exact same arguments
- Time-limited: Tokens expire after a configurable period
LLM-Evaluated Policies
LLM‑evaluated policies (“Smart Rules”) run before deterministic rules. Always scope Smart Rules to a specific tool and/or upstream when possible.
When to Use LLM-Evaluated Policies
Standard policies work great for exact matches:- Block tool
delete_file - Require approval for action class
EXECUTE
- “Block searches for sensitive files like .env, passwords, or SSH keys”
- “Require approval for any operation that could expose credentials”
- “Deny requests targeting directories outside the project”
Creating an LLM-Evaluated Policy
- Go to Policies in the dashboard
- Click Create Rule
- Toggle on LLM-Evaluated
- Set the Effect (Allow, Deny, or Require Approval)
- Write your Condition in plain English
- Optionally scope to a specific Upstream or Tool
Example Conditions
Block sensitive file access:How LLM Evaluation Works
- A tool call comes in (e.g.,
grep_searchwithtarget: "~/") - Latch checks if any LLM-evaluated policies are in scope
- For each policy, the LLM evaluates: “Does this tool call match the condition?”
- If matched, the policy’s effect is applied
- The LLM’s reasoning is logged for auditing
Writing Good Conditions
Be specific:Configuration
LLM-evaluated policies use GPT-4o-mini. SetOPENAI_API_KEY in your environment:
OPENAI_API_KEY is not set, LLM policies fall back to keyword matching — less accurate but still catches common cases.
Performance Considerations
- LLM evaluation adds ~200-500ms latency per policy
- Policies are evaluated in parallel when multiple apply
- Only policies in scope (matching upstream/tool) are evaluated
- Use standard policies for simple exact matches (faster, deterministic)
Examples by Use Case
Development Security:Best Practices
- Start restrictive: Begin with “Require Approval” and relax as you trust the setup
- Use action classes first: They’re faster and deterministic
- Use LLM policies for complex conditions: When action classes aren’t enough
- Scope narrowly: Apply policies to specific upstreams/tools when possible
- Name descriptively: Good names make the audit log easier to read
- Review regularly: Check the audit log to see how policies are being applied