Security Specification

CrewAI Cost Capping, Loop Termination & Swarm Delegation Security

CrewAI coordinates role-based autonomous agents with built-in task delegation (allow_delegation=True). While powerful, unbounded delegation creates a compounding security surface: a "Researcher" and "Writer" agent can enter mutual ping-pong delegation spirals, while prompt injection in external search results can compromise the entire swarm.

The Production Incident
Unbounded delegation cascade: 2 agents exchanged 84 micro-tasks overnight
Token consumption: 1,420,000 tokens ($42.60) before external task completion

The Fix: Swarm-Level Atomic Budget Enforcement

Instead of relying on in-process Python token counting, route all outbound LLM calls through Oridio. Oridio tracks collective token consumption across all crew members synchronously at Layer 7, enforcing strict monetary caps and role-based MCP tool scopes.

# Python: CrewAI with Synchronous Swarm Wallet
import os
from crewai import Agent, Crew, Task

# 1. Direct LLM traffic through Oridio Zero-Trust Gateway
os.environ["OPENAI_API_BASE"] = "https://proxy.oridio.org/v1"
os.environ["OPENAI_API_KEY"] = "ord_live_..."

# 2. Attach Swarm ID and hard financial ceilings via standard headers
researcher = Agent(
  role="Market Researcher",
  goal="Analyze competitor pricing",
  allow_delegation=True,
  verbose=True
)

Wire-Level Rejection Contract

The moment total swarm token expenditure reaches your preset threshold, Oridio severs the network socket instantly with an explicit HTTP 402 Payment Required:

HTTP/1.1 402 Payment Required
{ "error": "SWARM_BUDGET_EXHAUSTED", "swarm_id": "crew_financial_ops", "allocated_budget_usd": 25.00, "consumed_usd": 25.004, "action": "EGRESS_SEVERED", "resets_at": "2026-10-11T00:00:00Z" }

Pair with Two-Gate Tool RBAC to restrict tools accessible during delegation, or configure Real-Time Token Budgeting across multiple swarms.

Installation & Setup

Oridio can be integrated either as a drop-in HTTP proxy without modifying your agent codebase, or via our official language bindings for programmatic telemetry and fine-grained Wasm triggers.

$pip install oridio-python && npm install @oridio/sdk
Step 1: Set Proxy Base URL

Route OpenAI/Anthropic SDK client requests through https://proxy.oridio.org/v1.

Step 2: Add Auth Header

Supply your Oridio Master Key via header X-Oridio-Auth: ord_live_....

Architecture & Deep Dive

The Oridio security runtime operates as an out-of-band Layer 7 data plane. Rather than relying on non-deterministic LLM-as-a-judge prompts, security constraints are compiled into Ahead-Of-Time (AOT) WebAssembly binaries evaluated at bare-metal speeds.

Near-Native Wasm
< 0.7ms

P50 evaluation overhead per token packet.

Fail-Closed SLA
99.99%

Global Anycast edge proxy availability.

State Locking
Redlock

Distributed Redis mutex for swarms.

Zero Egress Leakage Guarantee: When a policy trips or a prompt injection signature is detected, Oridio severs the network socket instantly before any data traverses to the upstream provider.

Sample Code & Implementation

from oridio import OridioClient
from langgraph.graph import StateGraph

# Initialize Oridio Edge Gateway client
client = OridioClient(api_key="ord_live_7x9k2m...")

# Wrap your state graph with zero-trust proxy
graph = StateGraph(AgentState)
secure_graph = client.wrap_graph(
    graph,
    budget_limit_usd=50.00,
    pii_redaction=True,
    anomaly_detection=True
)

Interactive Runtime Playground

Edge Mode: Active
{"agent": "finance-bot", "query": "Transfer SSN 000-12-3456"}
{"agent": "finance-bot", "query": "Transfer SSN [REDACTED_SSN]"}(0.7ms p50)

Frequently Asked Questions

Oridio compiles security policies into Ahead-of-Time (AOT) WebAssembly running directly on global proxy edge nodes. Standard regex and token evaluation adds less than 1 millisecond (p50: 0.7ms, p99: < 5ms).

Need help integrating?

Our runtime engineering team can help pair on your agent topology.

Contact support@oridio.org