Skip to content
B
BIPASHA.DEV
system boot — v1.0
$ initializing bipasha.dev0%
click or press any key to skip ↵
All posts
AIApr 11, 2026·1 min read

Agent Loops That Don't Run Away: Budgets, Critics, and Guardrails

Autonomous agents are great until they spend $400 in a loop. Bounded autonomy is a design discipline, not an afterthought.

B

Bipasha Bhattacharjee

Software Engineer

An agent that can call tools is an agent that can call them forever. The first thing I add to any agent graph is a budget.

Budgets first

Before a single tool runs, cap the loop on three axes: max steps, max tokens, and max wall-clock. A runaway agent should fail loudly and cheaply, not silently and expensively.

typescript
const budget = { steps: 0, maxSteps: 8, deadline: Date.now() + 30_000 };

while (budget.steps < budget.maxSteps && Date.now() < budget.deadline) {
  const step = await planner.next(state);
  if (step.done) break;
  state = await execute(step);
  budget.steps++;
}

Add a critic

The second thing I add is a critic — a separate pass that asks 'is this actually done, and is it correct?' before the result escapes the loop. The generator is optimistic; the critic is paid to be skeptical.

A demo needs a generator. Production needs a generator and a critic that can veto it.

Guardrails

  • Validate every tool output against a schema — never parse free text downstream.
  • Gate irreversible actions (payments, emails, deletes) behind explicit confirmation.
  • Log the full trace so any run can be replayed and debugged.

Together they convert an impressive demo into something you can put in front of production traffic without losing sleep.

#Agents#LLMs#Reliability
Share

Keep reading

Enjoyed this?

Get new notes on systems and AI in your inbox.