Agents & Tool Use
An agent is an LLM that can call functions. That single capability — calling code — turns a chatbot into a programmable system.
The loop
while not done:
1. LLM looks at conversation + available tools
2. LLM decides: respond, OR call a tool
3. If tool call: run it, append result to conversation
4. Else: return final answer
Why it's powerful
- Real data. The LLM can call
get_weather()instead of guessing. - Real actions. It can send an email, book a meeting, file a PR.
- Long horizons. It can run for hours, decomposing a goal into many tool calls.
Why it's dangerous
- Loops. Agents get stuck repeating themselves. Always set a step budget.
- Hallucinated tool calls. Validate every argument before executing.
- Cost explosion. Each step is another LLM call. A 50-step agent on a paid model isn't free.
Patterns
- ReAct (Reason + Act) — the OG pattern; the LLM verbalises its plan, then acts.
- Plan-and-Execute — generate the full plan up front, then execute deterministically.
- Multi-agent — multiple specialised agents (planner, coder, critic) that hand work off.
Most production agents are simpler than the hype. They usually have 3-5 tools and a tight loop budget.