advanced Estimated learning time: 4 h

9.11 Cost control and production failure modes

Your agent cannot generate a surprise bill.

Before:08. Large Language Models

Production agents need financial governors: per-task and per-user token budgets, loop detection, step ceilings, cheaper-model routing, and a defined degradation path when a budget hits. It closes the agent module because autonomy without a ceiling is a liability, not a feature. The statistical trap is the tail — averages look fine while one pathological task runs away, and the hard ceiling exists for the run that the average never predicted.

Work through these

  • Token budgets per task and per user

    A limit on how much an agent may spend per task and per user, enforced rather than intended. Without it, one unusual input can consume an entire month's budget.

  • Loop detection and step ceilings

    Detecting when an agent is repeating itself, and capping the number of steps regardless. Loops are the normal failure mode, not an exotic one.

  • Caching and cheaper-model routing

    Reusing previous results, and sending simpler steps to a cheaper model, both cut cost substantially without changing what the agent can do. Routing is frequently the largest saving available.

  • Graceful degradation when the budget is hit

    When a limit is reached, returning partial work or a clear explanation beats stopping silently. Deciding this behaviour in advance is part of the design.

Sign in to keep your progress.

Free resources

Links last checked 29 Aug 2026.

Stuck here?

Ask a mentor. A real person answers, and they can see exactly which topic you're on. Usually within a couple of working days.

Checking your session…

Topics shown in module order.