Skip to main content
An autonomous agent that loops on a complex task can make hundreds of LLM calls before you notice. At $5–21/MTok for frontier models, a runaway loop can cost hundreds of dollars before a human intervenes. AgentGuard is PRYSM’s safety layer. It enforces spending constraints at the API level — not in your agent’s code, not in a client-side wrapper — so the caps hold regardless of how the agent calls the LLM.

The four controls

Per-request cap: X-Max-Cost-USD

Add one header to your OpenAI client and every call gets a hard cost ceiling:
What happens when the routed model would exceed the cap:
  1. PRYSM estimates cost before calling the provider (input tokens × rate + max_tokens × rate).
  2. If estimated cost > cap, PRYSM selects the cheapest live model that fits within the cap.
  3. If no model fits (extremely tight cap), PRYSM returns HTTP 402:
The auto-downgrade is transparent — your agent code doesn’t change. The prysm.routing.why field tells you what happened:

Per-agent cap in LangChain

Self-throttling agent loop

The X-Prysm-Budget-Remaining header is emitted on every authenticated response. Agents can read it and slow themselves down before hitting the monthly cap:

80% webhook

Set PRYSM_BUDGET_WEBHOOK_URL to receive a POST when your monthly spend crosses 80%:
Payload:
The webhook fires once per API key per billing cycle (deduplicated in-process; use Redis for multi-process deploys). Use it to:
  • Send Slack/email alerts to the dev team
  • Automatically switch agents to budget models
  • Pause non-critical background jobs

BRAIN.md: team-level defaults

Set AgentGuard defaults for your entire team without touching agent code:

CrewAI: per-agent + crew-total budget

Each agent has its own budget, enforced server-side. The researcher gets 0.05/step;thewritergets0.05/step; the writer gets 0.005; the fact-checker $0.001. No agent can accidentally overspend the others.

Summary: safe defaults for new agent deployments

Start conservative. Review your X-Prysm-Budget-Remaining trends after the first week and raise limits as you understand your agent’s spending patterns.