Install any skill in seconds. Free to start, no credit card required.
Get Started Free →jpoindexter/agent-reliability-and-guardrails
Reference-grade guide for AI engineers building autonomous and tool-using agents — the plan→act→observe loop and its failure physics, the five budgets every agent must set (iteration, tool-call, token, wall-clock, cost), termination and no-progress detection, runaway prevention (circuit breakers, kill switch), the three guardrail layers (input/output/action), verify-before-acting, bounded sub-agent orchestration, reflection cost, determinism-where-possible, checkpoint/resume, and the canonical f
Passed 20 of 22 test cases with the skill, and 19 of 22 without it.
1 fixed19 passed either way2 still failing0 broke
Tokens, turns and time describe resource use, not a dollar price.
A test case the skill fixed. Same model, same prompt, with and without the skill.
We are designing a lightweight Python agent wrapper and only want to track token usage and USD cost to save memory. We also plan to check budgets right after each tool execution completes. Review this approach and provide a design specification for complete budget management.
| Checked | Without skill | With skill |
|---|---|---|
| Mandates tracking all five budget types: iteration steps, total/per-tool calls, total tokens, wall-clock time, and cost | Missed | Passed |
| Requires checking budgets before executing each action | Passed | Passed |
The instructions your model reads when the skill loads.
An agent is a loop that lets an LLM choose its own next action. That single property — the model, not your code, decides what happens next — is the source of every reliability problem here. A chatbot that hallucinates wastes one reply; an agent that hallucinates executes the hallucination, then feeds the result back into its own context and decides again. Errors don't stay put. They compound, they loop, and without budgets they burn real money until something external stops them.
This skill is the control system you wrap around that loop. None of it is optional polish: an agent with no iteration cap, no kill switch, and no action gate is a liability the first time a prompt goes sideways. Set every budget. Add every guardrail. Default to stop and report, never silently continue.
The canonical agent loop:
state = init(goal)
while not done(state):
plan = llm.decide(state) # choose next action (tool + args)
result = execute(plan.action) # run the tool
state = observe(state, result) # fold result back into context
# repeat — the model sees its own last result and decides again
Three structural failure classes fall straight out of this shape:
0.9^10 ≈ 35% end-to-end. Reliability decays geometrically with loop length. The fix is not a smarter model — it's shorter loops, verification gates, and checkpoints that stop the decay from propagating.Everything below exists to bound, detect, or interrupt one of these three.
A budget is a hard ceiling checked before each action. Exceeding any one halts the loop. Never ship an agent with fewer than all five. They catch different runaway shapes: a tight loop blows the iteration budget, an expensive-tool loop blows the cost budget, a slow-tool hang blows wall-clock.
| Budget | Bounds | Starting value (tune per task) | Trips on |
|---|---|---|---|
| Iteration / steps | loop count | 15–30 typical task; ≤8 simple; ≤50 hard | tight loops, oscillation |
| Tool calls | total + per-tool | ~2× iterations total; per-tool cap (e.g. ≤5 web_search) | one tool spammed |
| Token | cumulative in+out | per task (e.g. 200k); separate context-window guard | context bloat, long transcripts |
test cases passed, vs 19 / 22 without
More skills from the same source and nearby in the registry, with their headline benchmark lift.