Pre-execution security for Temporal.io AI agents using Predicate Authority.
Temporal.io is a popular workflow orchestration platform for building reliable, distributed applications. When building AI agents with Temporal, activities often perform sensitive operations—database mutations, API calls, file system access, or shell commands. The Predicate Temporal interceptors provide a zero-trust security gate that blocks unauthorized activities before they execute.
Temporal workflows orchestrate complex, long-running processes. Activities within these workflows can:
Without pre-execution authorization, a compromised or malicious activity payload could:
DELETE FROM orders WHERE 1=1)rm -rf /)The Predicate Temporal interceptor sits in the activity execution pipeline and blocks unauthorized actions before any code runs.
┌─────────────────────────────────────────────────────────────────┐
│ Temporal Worker │
│ ┌─────────────┐ ┌─────────────────────┐ ┌─────────────┐ │
│ │ Workflow │───▶│ Predicate Interceptor│───▶│ Activity │ │
│ │ │ │ │ │ │ │
│ │ dispatch │ │ 1. Extract action │ │ execute │ │
│ │ activity │ │ 2. Call sidecar │ │ (if OK) │ │
│ │ │ │ 3. Allow or Deny │ │ │ │
│ └─────────────┘ └─────────────────────┘ └─────────────┘ │
│ │ │
│ ▼ │
│ ┌─────────────────────┐ │
│ │ Predicate Sidecar │ │
│ │ - Policy eval │ │
│ │ - Mandate signing │ │
│ │ - Audit logging │ │
│ └─────────────────────┘ │
└─────────────────────────────────────────────────────────────────┘
POST /v1/authorize with action = activity nameSee Predicate Authority block dangerous Temporal activities in real-time:
Run it yourself:
git clone https://github.com/PredicateSystems/predicate-temporal-python
cd predicate-temporal-python/examples/demo
./start-demo-native.shRequirements: Python 3.11+, Temporal CLI
The demo shows 4 scenarios:
| Scenario | Result | Policy Rule |
|---|---|---|
| Legitimate order processing | ✅ ALLOWED | allow-safe-activities |
| Delete order attack | ❌ BLOCKED | deny-delete-operations |
| Admin override attack | ❌ BLOCKED | deny-admin-operations |
| Drop database attack | ❌ BLOCKED | deny-drop-operations |
The interceptor requires the Predicate Authority Sidecar daemon. The sidecar handles policy evaluation and mandate signing locally—no data leaves your infrastructure.
See the Sidecar and Operations guide for detailed setup instructions.
Quick start with Docker:
docker run -d -p 8787:8787 ghcr.io/predicatesystems/predicate-authorityd:latestOr download the binary:
# macOS (Apple Silicon)
curl -fsSL https://github.com/PredicateSystems/predicate-authority-sidecar/releases/latest/download/predicate-authorityd-darwin-arm64.tar.gz | tar -xz
chmod +x predicate-authorityd
./predicate-authorityd --port 8787 --policy-file policy.jsonVerify it's running:
curl http://localhost:8787/health
# {"status":"ok"}| Language | Package | Install Command |
|---|---|---|
| Python | predicate-temporal | pip install predicate-temporal |
| TypeScript | @predicatesystems/temporal | npm install @predicatesystems/temporal |
from temporalio.worker import Worker
from predicate_temporal import PredicateInterceptor
from predicate_authority import AuthorityClient
# Initialize the Predicate Authority client
ctx = AuthorityClient.from_env()
# Create the interceptor
interceptor = PredicateInterceptor(
authority_client=Create a policy file that defines allowed and denied activities:
{
"rules": [
{
"name": "allow-safe-activities",
"effect": "allow",
"principals": ["temporal-worker"],
"actions": ["process_order", "send_notification", "fetch_data"],
"resources": ["*"]
},
{
"name": "deny-dangerous-activities",
"effect": "deny",
"principals": ["*"],
"actions": ["delete_*", "drop_*", "admin_*", "rm_*"],
"resources": ["*"]
}
]
}Starter policy packs: The sidecar repository includes ready-to-use policy templates for common use cases.
Policy evaluation order:
| SDK | Repository | License |
|---|---|---|
| Python | temporal-predicate-py | MIT |
| TypeScript | temporal-predicate-typescript | MIT |