AiTechWorlds
AiTechWorlds
An AI agent is a system where an LLM doesn't just respond to a single prompt — it takes a sequence of actions to accomplish a goal, using tools, making decisions, and adapting based on results. Understanding the main architectural patterns is the foundation for building agents that work reliably.
A basic LLM call is: input → LLM → output. Done.
An agent is: goal → LLM decides action → executes action → observes result → LLM decides next action → ... → goal achieved.
The key additions:
When these combine, you get emergent capability: the agent can accomplish tasks that couldn't be done with a single prompt.
ReAct is the most common single-agent pattern. The LLM alternates between reasoning (thinking out loud) and acting (using a tool):
Thought: I need to find the current stock price of Apple.
Action: search("Apple AAPL stock price today")
Observation: AAPL is trading at $192.35 as of 2:15 PM EST.
Thought: Now I have the price. The user asked how it compares to last year.
Action: search("Apple AAPL stock price one year ago")
Observation: A year ago, AAPL was trading around $178.
Thought: I have both values. I can calculate the change.
Final answer: Apple (AAPL) is currently trading at $192.35, up approximately 8% from $178 a year ago.
The "Thought" steps are the LLM's internal reasoning — they make the decision-making transparent and improve accuracy. The LLM sees its own reasoning, which helps it stay on track.
Best for: Research tasks, information retrieval, tasks requiring a sequence of lookups
The agent creates a plan upfront, then executes each step:
User: Research the top 3 competitors to our product and write a comparison report.
Planning phase:
1. Search for our product category and main competitors
2. Gather pricing information for each competitor
3. Find customer reviews for each competitor
4. Analyze the data and identify key differentiators
5. Write the comparison report
Execution phase:
[Execute each step sequentially, with each step's output feeding into the next]
Plan-and-execute is better for complex, multi-part tasks where you want a defined structure before execution begins.
Best for: Long research tasks, multi-step document creation, complex workflows
Multiple agents with specialized roles, coordinated by an orchestrator:
Orchestrator Agent
├── Research Agent (browses the web, finds information)
├── Coding Agent (writes and executes code)
├── Writing Agent (generates polished prose)
└── Review Agent (checks for errors and quality)
The orchestrator breaks the task, delegates to specialists, and synthesizes results. Each specialist is independently prompted and can use different models/tools.
Best for: Complex tasks that benefit from specialization, tasks where parallel execution helps, production systems where each role has distinct tool requirements
The agent critiques and improves its own output:
Generate → Critique → Revise → [optional: Critique again] → Final output
Step 1: Generate initial response Step 2: "Review your previous response. What's missing? What could be wrong? What could be improved?" Step 3: Revise based on the critique
This pattern is particularly effective for writing quality, code correctness, and analysis depth. The LLM catching its own mistakes is surprisingly powerful.
Best for: High-quality writing, code generation, analysis where you want to check reasoning
All agent architectures share a common execution loop:
while not task_complete:
# 1. Observe: what is the current state?
observation = get_current_state()
# 2. Think: what should I do next?
action = llm.decide(goal, observation, history)
# 3. Act: execute the chosen action
result = execute_action(action)
# 4. Update: record what happened
history.append((action, result))
# 5. Check: is the task complete?
task_complete = check_completion(result, goal)
Understanding this loop helps you debug agents — when something goes wrong, it's usually in one of these five steps.
Single agents are simpler to build and debug. Multi-agent systems can parallelize work and specialize, but coordination overhead adds complexity.
Start single-agent. Add agents only when the single agent clearly can't handle the task effectively.
More autonomy = more potential value, more potential for unintended actions. The right level depends on:
What tools you give an agent defines what it can do. Common tools:
Start with the minimum tools needed for the task.
How the agent remembers:
Agents add complexity and cost. Don't use them when a simple prompt works:
| Use Simple LLM | Use Agent |
|---|---|
| Single-step response (write an email) | Multi-step workflow (research → analyze → write) |
| Static information needed | Real-time or external information needed |
| Deterministic path | Adaptive decision-making needed |
| Low stakes, high volume | Higher stakes, variable tasks |
Next lesson: The agent core loop — implementing the reasoning-acting-observing cycle.
Get this course's notes on Telegram!
Free cheat sheets, summaries & practice exercises