Home / CrewAI

Stop runaway CrewAI agents in real time

CrewAI 1.x routes LLM calls through provider classes and wraps execution in retry loops, so naive guards silently no-op. AgentBrake patches the real provider call path plus ToolUsage, and raises a BaseException the retry loop can't catch — verified live against a real crew.kickoff().

$pip install agentbrake-sdk
GitHub

One line to wire it in

from agentbrake import CrewAIBrake

# right before crew.kickoff()
CrewAIBrake(max_cost_usd=3.00, repeat_tool_limit=5).install()

CrewAI runaway patterns it catches

PatternHow it stops
Identical-tool loopsLoop detector patches ToolUsage and trips after N identical tool calls in a row.
Cost blowoutsPer-instance token-delta accounting from each provider call drives a live cost ceiling.
Retry-swallowed brakesCrewAI wraps execution in except-Exception retry loops. AgentBrakeError is a BaseException, so it sails past them and actually halts crew.kickoff().
Provider driftCrewAI 1.x routes calls through a provider factory; AgentBrake patches the real provider classes, not the dead LLM.call entry point.

Add the brake to your CrewAI agent

One line of code. Open source. Works on LangChain 1.x, CrewAI 1.x, and the classic AgentExecutor.

$pip install agentbrake-sdk
Star on GitHub

Frequently asked questions

Does the brake really stop a CrewAI crew?
Yes. A live run on real OpenAI confirmed it halts crew.kickoff(). CrewAI's retry loop used to swallow the brake; AgentBrakeError is now a BaseException, so it can't be caught by the framework's except Exception.
When do I call install()?
Right before crew.kickoff(), after your agents and LLMs are constructed — CrewAI lazy-loads provider classes, so installing late guarantees they're patched.
How accurate is the cost ceiling?
It reads real token usage the provider reports. Loop, step, tool-call and duration limits are exact regardless.