Log inBook a Demo
BuildMidData / MLAuto-graded

Cap an agent's steps and retry flaky tools

Rewards the instinct to put limits on automation: a cap on attempts, sensible retries, an honest partial result.A tool-using agent is just a loop: ask the model what to do, and it either calls a tool or answers. That loop is fine in a notebook and dangerous in production — it can spin forever burning budget, and one flaky tool call takes the whole run down with it. The agent.py here has no limits at all. Add the three controls that separate a demo from something you would actually leave running: a hard step budget, retries when a tool fails transiently, and an honest partial answer when it runs out of road.
35 min
python

You're done when

  • The agent stops at its maximum step count instead of looping forever.
  • When the budget is exhausted it returns a structured partial result rather than raising or returning nothing.
  • A tool that fails intermittently is retried rather than ending the run.
  • The number of retries actually attempted matches what was asked for — no silent extra attempts, no skipped ones.
  • When a tool keeps failing, the agent degrades gracefully instead of crashing.
  • The underlying error is surfaced to the caller rather than swallowed.

What it measures

Agent engineeringKnowing which controls an autonomous loop needs before it can be trusted to run unattended, and where each one belongs in the loop.
AI workflow designChoosing what should happen at the limits — what a truthful partial result looks like, and when retrying helps versus when it just burns budget.
Operational judgementPutting a ceiling on automation by instinct, and reporting honestly when that ceiling is hit.

Your environment

Terminal + editorA full shell in the browser
Claude CodePre-authenticated, no key setup
Isolated microVMYours alone, wiped afterwards

Start this lab

35 min
Start labYou'll sign in to Anthropos to start. The lab opens in a private cloud workspace with Claude Code ready to use.
AI Labs is part of Anthropos Workforce. Not on your plan yet? Book a demo