The Agent Loop
At its core, every LLM agent follows the same pattern:
Observe → Think → Act → Observe → ...
The difference between a chatbot and an agent is autonomy — agents decide what to do next without human intervention at each step.
Pattern 1: ReAct
The simplest effective pattern. The LLM alternates between reasoning and acting:
Thought: I need to find the user's order status
Action: query_database(order_id="12345")
Observation: Order shipped on March 1
Thought: I have the information, I can respond
Action: respond("Your order shipped on March 1")
Pattern 2: Plan-and-Execute
For complex tasks, separate planning from execution:
- Planner generates a high-level plan
- Executor handles each step
- Replanner adjusts when things go wrong
This mirrors how we actually solve problems — think first, then do.
Pattern 3: Multi-Agent
Multiple specialized agents collaborating:
- Researcher gathers information
- Coder writes and tests code
- Reviewer validates output
Choosing the Right Pattern
- Simple Q&A with tools → ReAct
- Multi-step workflows → Plan-and-Execute
- Complex open-ended tasks → Multi-Agent