The ReAct Pattern
ReAct interleaves Reasoning and Acting, letting the Agent alternate between thinking and executing.
Implementation
def agent_loop(query, max_steps=5):
history = [{"role": "user", "content": query}]
for step in range(max_steps):
thought = llm.think(history, tools)
if thought.action == "answer":
return thought.content
result = execute_tool(thought.action, thought.input)
history.append({"role": "assistant", "content": f"Result: {result}"})
See AI Agent Research Status for background and Agent Framework Comparison for framework evaluation.