Log inBook a Demo
BuildSeniorData / MLAuto-graded

Build a ReAct loop that reasons then acts

An assistant must parse its own written reasoning, act on it, and recognize a final answer, or it loops forever.Strip away the frameworks and almost every tool-using agent is the same small loop: the model reasons, picks an action, you run that action as a tool, you feed the result back, and it reasons again until it declares itself done. That is the ReAct loop, and writing a correct one by hand is the most clarifying thing you can do to understand agents. The one in react_agent.py is broken. Make it parse actions, feed observations back, terminate properly, and survive malformed model output.
40 min
python

You're done when

  • The loop parses the action name and its argument out of the model's output.
  • The observation from running a tool is fed back into the next step.
  • A final answer is recognised, extracted, and terminates the loop.
  • Malformed action output is recovered from rather than crashing the run.
  • The loop respects its maximum step count instead of running indefinitely.

What it measures

Agent engineeringImplementing the reason-act-observe cycle correctly, including how the loop decides it is finished.
Context engineeringThreading observations back into the model's context so each step builds on the last.
Robustness to model outputTreating a malformed action as expected — models produce them — and recovering instead of failing the run.

Your environment

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

Start this lab

40 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