Best practiceRunning agents
Cap what an agent can spend, call and run
OWASP ASI02OWASP ASI08OWASP LLM10
A hijacked or runaway agent keeps going until something stops it: OpenAI's evaluation agents took about 17,600 actions in Hugging Face's systems over four days before they were contained. Stolen AI keys are used to run up bills their owners pay. Caps on cost, calls and run time turn an open-ended incident into a bounded one.
What to do
- Set ceilings on cost, rate and tokens for every agent and every API key, with automatic revocation or throttling when one is exceeded.
- Cap how long one run lasts and how many tool calls it makes, with timeouts, and stop it at the cap instead of letting it retry.
- Put quotas, progress caps and circuit breakers between planning and execution, and throttle or pause the agent when its commands spread fast or look unusual.
- Watch spend and call volume per agent and per key, so a loop or a stolen key shows up in hours rather than on the invoice.