Interleave reasoning with tool calls until the agent can answer.
flowchart TD
Q([question]) --> T[THOUGHT]
T --> D{need a tool?}
D -->|yes| ACT[ACTION: tool :: input]
ACT --> OBS[OBSERVATION from tool]
OBS --> T
D -->|no| F[FINAL answer]
When to use — the single most important single-agent pattern. Any time an agent needs to look something up, calculate, call an API, or check a result before answering.
Communication style — a loop between the model and its tools. The
"protocol" is the text contract: ACTION: <tool> :: <input> and
FINAL: <answer>. (Real deployments use native tool-calling JSON; the text
form here keeps the loop visible.)
Watch out for — infinite loops (always cap max_steps), and malformed
tool calls. Tools return errors as observations so the agent can recover.
python run.py react -i "What is 144 / 12 + 7?"