BuildSeniorData / MLAuto-graded
Build a ReAct loop that reasons then acts
Make an agent loop parse each action, call the matching tool, return the final answer and stop at a step limit.Most tool-using agents come down to one small loop: the model picks an action, you run it as a tool, you show it the result, and it goes again until it gives a final answer.run_react(task, model, tools, max_steps) in react_agent.py should be that loop, but today it never reaches an answer. Make it parse each Action: name[arg] line, pass tool results back as observations, return the Final Answer:, cope with bad model output, and stop at max_steps.40 min
python
You're done when
- Each
Action: name[arg]line is parsed into the right tool name and argument. - The result of each tool call is shown to the model on the next turn.
- When the model writes a
Final Answer:, the loop returns that value and stops. - A malformed action or an unknown tool doesn't crash the run: the model gets an error observation and can try again.
- If no final answer comes, the loop stops after
max_stepsturns and returnsMAX_STEPS_EXCEEDED.
What it measures
Loop controlWhether the loop calls the right tools in order and knows when it is finished.
Feeding results backHow tool results reach the transcript so each turn builds on the last one.
Handling bad outputWhat the loop does when the model writes an action it can't parse or names a tool that doesn't exist.
Your environment
Terminal + editorA full shell in the browser
Coding agentAlready signed in, no API key to set up
Isolated workspaceOnly yours, wiped when you finish
Start this lab
40 min
Start labYou'll need to sign in to Anthropos first. The lab opens in a private cloud workspace with your coding agent ready to use.AI Labs is part of Anthropos Workforce. Not on your plan yet? Book a demo