Guide

Autonomy is a dial, not a boolean. Moving up a level without evals and budgets is how demos become incidents. Moving down a level when metrics are flat is mature engineering.

Concept

Before you start: an agent chooses tools until a goal is met or a budget runs out. Human-in-the-loop means a person must approve, edit or take over before the system proceeds.

Levels

LevelBehaviorExample
0Single model callClassify intent
1Fixed workflowExtract → validate → draft
2Tool loop, read-onlyResearch with search
3Tool loop, gated writesFile a ticket after approval
4Long-running durable agentOvernight coding with sandboxes

Recover, then escalate

Agents that cannot recover are demos.

  • Structured tool errors the model can act on. See tool use.
  • Verification after risky actions: re-read the file, re-query the order, run the test suite.
  • Self-correction with new information: "The tests failed; fix the code" plus the failure log. Not "try again" with no new signal.
  • Escalation: after N failed recoveries, hand off to a human with a summary of attempts.

Do not let the agent "verify" by asking itself if it did a good job. Prefer code assertions, schemas, tests and retrieval.

Human checkpoints that show up in real products: approve the plan before tools run; approve each destructive tool call; approve the final outbound message; take over on low confidence or a policy flag. Show the proposed action, the rationale and a diff or preview. Blanket "Allow all" defeats the control. Timeouts should fail safe (no action), not fail open.

Failure modes

FailureWhat you seeMitigation
LoopsSame tool and args repeatedFingerprint calls; break after 2 to 3 duplicates
Goal driftBusy work unrelated to the askRestate the goal each turn; todo list; max steps
Tool misuseWrong tool or invented argsBetter schemas; evals; fewer tools
Cost blowupsToken spikes, huge retrieval dumpsBudgets; truncate results; cheaper model for routine steps
Silent liesConfident answer without toolsForce tools for factual domains; cite observations
Context bloatQuality drops as the transcript growsCompact; summarize; reset from a state store

Observe every step: prompt version, tool calls, latencies, token counts, stop reason. You cannot debug an agent from the final paragraph alone. LLMOps patterns apply directly.

A research agent in the source averaged 12 tool calls and $0.40 per query. A loop detector plus a 6-step cap cut that to $0.11.

Common mistakes

  • Level 4 autonomy on "Where is my order?" High volume, known path, write tools. Use a workflow.
  • Verification with no external signal. The model will grade itself generously.
  • Fail-open timeouts that send the email when the approver is offline.

Check yourself

  1. A refund tool can fire without a click. Which level is too high? Level 3 or 4 writes without a gate. Refunds need approval.
  2. The agent says it ran the tests and they passed. What do you trust? The test runner's output in the observation, not the claim in the thought.

Key takeaways

  • Pick an autonomy level on purpose. Default down when metrics are flat.
  • Recover with structured errors and external verification. Escalate after repeated failure.
  • Cap loops. Detect identical tool calls. Restate the goal.
  • Human checkpoints and trajectory logs are architecture, not polish.

Further learning

Agents (Chip Huyen)Intelligent agents are considered by many to be the ultimate goal of AI. The classic book by Stuart Russell and Peter Norvig, Artificial Intelligence: A Modern Approach (Prentice Hall, 1995), defines the field of AI r…Chip Huyen

Barry Zhang (Anthropic) on when agents are worth the cost:

How We Build Effective Agents: Barry Zhang, AnthropicAI Engineer

The runtime that makes long runs survivable is agent infrastructure.