Agent Auth Gateway v1.0

Guides / 7 min read

How to Add Spend Guardrails to the OpenAI Agents SDK

Published 2026-11-14 · Reviewed 2026-11-14 · By the Ingenious AI team

The OpenAI Agents SDK gives you guardrails that validate inputs and outputs, handoffs that move work between agents, and runs that keep going until the work is done. What it does not give you is a dollar figure anywhere in that loop.

The short answer

Treat SDK guardrails as validation, not as a budget. Add the money controls at the call path: every model and tool call passes an authorisation check carrying the agent's identity and an estimated cost, against per-agent daily and monthly ceilings. Cap each run as well as each agent — handoffs mean a single run can spend under several identities — and route tool calls with external side effects to approval. The SDK decides what the agent does next; the gateway decides whether it is allowed to pay for it.

Check your own setup as you read: run the free Spend Guard self-check or test a policy in the playground — five minutes, no signup, and the gaps it names map to the controls below.

Worked example: the triage agent whose handoffs hid the bill

Casa Verde Hotels, a fictional 40-room independent group, built a guest-message triage agent on the Agents SDK: a triage agent handed booking questions to a reservations agent and complaints to a service agent. Each agent looked cheap in isolation — none exceeded $8 on any day in the provider view the team watched. What nobody totalled was the run: a single confusing guest thread was handed off 340 times in one night as each agent decided another owned it, generating 2,180 model calls and $74.60 for one conversation.

The fix kept every handoff and added two ceilings. Each run now carries a $3 budget: the call that would cross it is refused and the thread is escalated to the front desk with a summary. Each agent keeps a daily cap — triage $12, reservations $20, service $15 — so a busy day across many threads still stops before it becomes a bill. In the first month the run cap fired 11 times, every one a genuine handoff loop, at an average stopped cost of $2.91 instead of the $74.60 the first loop reached.

Guardrails validate; they do not ration

Input and output guardrails answer 'is this allowed content, in the right shape'. They run alongside the agent's work and can trip a run, but they know nothing about cumulative spend, and a run can pass every guardrail while spending a fortune doing legitimate-looking work. Keep them — they are good at their job — and stop expecting them to do a budget's job. Rationing needs state: a running total per agent and per run, updated on every call, which lives naturally in the authorisation layer rather than in validation hooks.

Budget the run, not only the agent

Handoffs break per-agent accounting: a run is a relay, and its total cost is the sum across every agent it visited. If you only cap agents, a pathological run distributes its spend so no single cap fires — exactly what happened at Casa Verde, where three agents each stayed under $8 while one thread cost $74.60. Give every run a budget identity of its own, decremented on each call regardless of which agent makes it, and escalate the run to a human when the budget ends.

Tool calls are where side effects and spend meet

Model calls cost tokens; tool calls can cost money and change the world — sending the email, charging the card, booking the room. Route tool calls through the same authorisation check with their own estimated costs, and put the irreversible ones behind approval regardless of cost. A $0.02 tool call that refunds the wrong guest is a bigger incident than a $40 model loop, and your policy should be able to say so.

Trace ids make the audit log readable

Carry the SDK's run and trace identifiers into every authorisation request. When finance or an incident review asks what happened, you can then walk one thread from first call to refusal, across every handoff, in order, with the policy decision recorded at each step. Without that threading, multi-agent incidents dissolve into three separate logs and a meeting.

A worked sizing exercise for your first run budget

Take your last hundred completed runs and price them honestly, including every handoff. Sort them. The median is your normal; the 95th percentile is your generous; anything beyond three times the 95th percentile is almost certainly a malfunction rather than a workload. Set the run budget between the second and third of those numbers, and log every run that reaches even half of it for the first month — those near-misses are your calibration data, showing whether real work is creeping toward the line or the line sits safely above it. Do the same per agent for daily caps. Teams that skip this exercise tend to pick round numbers, and round numbers are how a $3 problem becomes a $300 one while every individual figure looked reasonable.

Five actions to add spend guardrails to an Agents SDK app

  1. Keep SDK guardrails for validation, and add a separate per-call authorisation check that carries identity and estimated cost.
  2. Set per-agent daily and monthly ceilings for every agent in the system, including orchestrators.
  3. Give every run its own budget, decremented across all handoffs, with escalation to a human when it ends.
  4. Route irreversible tool calls to approval regardless of their dollar cost.
  5. Pass run and trace ids into the authorisation log so one thread can be reconstructed end to end.

Source note and related guides

Figures in the worked example are illustrative, drawn from a fictional company created for this guide; the controls, failure patterns and procedures described are the gateway's documented behaviour — see the Agent Auth Gateway documentation and the policy patterns in allowlists vs denylists, spend caps and the agent kill switch. Reviewed by the Ingenious AI team, 2026-11-14.

Sources

  • OpenAI API documentation — Rate limits and spend limits, on how provider-side usage and spend limits are defined at organization and project level: platform.openai.com, 2026
  • NIST AI Risk Management Framework (AI RMF 1.0), the voluntary framework for managing AI risk across design, development and use: nist.gov, 2023
  • OWASP Top 10 for Large Language Model Applications, the OWASP GenAI Security Project's risk list for LLM and agent systems: owasp.org, 2025

Frequently asked questions

Do OpenAI Agents SDK guardrails limit spend?

No. Guardrails validate inputs and outputs and can trip a run on content or shape. They hold no running total and cannot refuse a call because an agent or a run has spent too much. Budgets need a stateful check in the call path.

How do handoffs affect agent budgets?

A run that hands off spends under several agent identities, so per-agent caps alone can all stay green while one run burns heavily. Budget the run itself, across every handoff, as well as each agent.

What should a run budget be?

Start from your real runs: take the 95th-percentile cost of a completed run and set the budget near twice it. Casa Verde's normal threads cost well under a dollar, so a $3 run budget caught loops without touching real work.

Which tool calls should need approval?

The irreversible and external ones — sending, paying, booking, deleting — regardless of cost. Cheap calls can do expensive damage; approval policy should key on reversibility, not only price.

Where does the spend check live if I use the SDK?

In the path of the calls themselves: wrap model and tool calls so each is authorised with the agent identity, run id and estimated cost before it executes, and refused when a ceiling would be crossed.

Governing agents in production?

Spend caps, approval queues, policy simulation, burn forecasting, and step-up lockdowns — all built into the gateway. Free tier to start. Or test policies in the playground with no signup.

Share this: X Facebook LinkedIn WhatsApp
← How to Control Spend in AutoGen Multi-Ag… All guides How to Give Every AI Agent Its Own API K… →