An agent = LLM + tools + a loop that lets the LLM decide when to use them.
A chain = predetermined sequence of LLM calls and tools.
The distinction matters because agents trade determinism for flexibility. They handle queries you didn't enumerate; they cost more, fail in ways chains don't, and require different evaluation.
ReAct (Reason + Act, Yao et al. 2022)
The pattern that defined modern agents:
Thought: I need to find the population of Paris and Tokyo to compare them.
Action: search("population of Paris")
Observation: 2.1M
Thought: Now Tokyo.
Action: search("population of Tokyo")
Observation: 13.9M
Thought: I have both numbers. I can answer.
Final Answer: Tokyo has ~6.6× the population of Paris.
ReAct is just chain-of-thought + tool calls in a loop. Modern function-calling APIs subsume it; you rarely write the ReAct prompt by hand anymore. The pattern survives because the loop structure does.
When agents win over chains
- Multi-hop questions where the next step depends on the previous result.
- Queries where the right tool is unknown at design time.
- Tasks that benefit from self-correction (retry, rewrite, escalate).
When chains win over agents
- The task structure is known and stable.
- Latency budget is tight — chains are deterministic and cacheable.
- Reliability matters more than coverage — chains don't loop, don't hallucinate tool calls.
The seven failures of bad agents
- Loops — repeats the same action with no progress.
- Hallucinated tools — calls a tool that doesn't exist.
- Hallucinated arguments — calls a real tool with invented data.
- Step-skipping — final answer before gathering evidence.
- Premature termination — stops on partial info.
- Cost explosion — 30 tool calls on a question that needed 3.
- Drift — wanders off-task on long horizons.
The three-line agent contract
Every production agent needs:
- A hard iteration cap (typically 5-10).
- A termination condition beyond "model says done" — task-specific.
- Trajectory logging — every (state, action, observation) tuple.
Without these, you have a research demo, not a system.