Quickstart
See SteerPlane stop a runaway agent in under five minutes, then protect your own.
Install
pip install steerplanenpm install steerplaneSee it stop a runaway agent
This example needs no API key and no LLM. It simulates three agents that go wrong, so you can see each stop in a few seconds.
Get the example
Download runaway_agent.py
from the repo, or copy the core of it:
from steerplane import SteerPlane
from steerplane.exceptions import CostLimitExceeded
sp = SteerPlane(agent_id="quickstart_agent")
try:
with sp.run(max_cost_usd=0.05, max_steps=100) as run:
for i in range(1, 101):
# An agent that keeps reading pages and never decides it is done.
run.log_step(f"read_page_{i}", tokens=1200, cost=0.008)
except CostLimitExceeded as e:
print(f"Stopped by SteerPlane: {e}")Run it
python runaway_agent.pyThe full example runs three agents. Each one is stopped:
=== 1. Cost limit: the agent keeps spending ===
Stopped by SteerPlane: [COST] Cost limit exceeded! Current: $0.0560, Limit: $0.0500. Run terminated.
=== 2. Loop: the agent repeats the same call ===
Stopped by SteerPlane: [LOOP] Loop detected! Repeating pattern ['search_orders'] found in last 8 actions. Run terminated.
=== 3. Denied action: the agent calls a blocked tool ===
Blocked by SteerPlane: [POLICY] Policy violation: Action 'drop_table_orders' matches deny pattern 'drop_*' [rule=deny:drop_*]If no SteerPlane API is running, you'll also see Running in offline mode (guards still active, no dashboard data). That's expected: the limits are enforced locally either way.
See the runs in the dashboard (optional)
From the root of the SteerPlane repo, start the API and dashboard, then run the example again:
docker compose upOpen http://localhost:3000. Each run shows as terminated, with its cost, steps and the reason it was stopped. See Self-hosting for details.
Protect your own agent
Add the @guard decorator to the function that runs your agent.
from steerplane import guard
@guard(
agent_name="support_bot",
max_cost_usd=10.00,
max_steps=50,
denied_actions=["delete_*", "drop_*"],
)
def run_support_agent():
agent.run() # your code, unchangedUsing LangChain, CrewAI, AutoGen or the OpenAI Agents SDK? Their integrations check limits before each model call and tool call. See Integrations.
Prefer zero code changes? Use the gateway proxy instead. Point your OpenAI
client at SteerPlane and every call is governed automatically. Using Node.js? See the
TypeScript SDK for the guard() and SteerPlane equivalents.