Building a multi-step reasoning agent with tool use
A ReAct agent on GPT-4 function calling that plans its own research, remembers across sessions, and checks its work before it answers.
Research takes several steps: split the question, search, decide what's relevant, combine it and write it up. One model call can't do that reliably, so I built an agent that plans the steps itself, using the ReAct pattern (reason, then act) on GPT-4 function calling.
Reason, act, look, repeat
ReAct interleaves thinking with tool calls, so the agent can change course based on what it just found instead of committing to a plan up front. It has tools to search the web, extract a page and manage citations. A typical question takes 5 to 10 tool calls.
Thought: I need recent work on speculative decoding.
Action: search_web("speculative decoding LLM optimization 2025")
Observation: [results]
Thought: The second result is a benchmark. I'll read it.
Action: extract_content(url_2)Two kinds of memory
A conversation buffer keeps one session coherent. A ChromaDB vector store keeps what the agent learned across sessions, which matters when you come back to a topic a week later.
Checking its own work
Without a check, an agent accepts its first result whatever the quality. So before it writes the report, it looks for gaps and contradictions, and if its sources disagree it goes back for more. That step made the reports noticeably more complete.
The interface streams each thought and tool call as it happens. Seeing the reasoning is what made me trust it, and it's the fastest way to catch it going wrong.