Agent = runtime( AI model + prompts + tools + memory + guardrails + planning skills )
The TAO cycle (Thought-Action-Observation) is the workflow of an artificial
intelligence agent. It allows agents to dynamically adjust their responses,
improve understanding, and improve the accuracy of the results
| THOUGHT Type | Example |
|---|---|
| Planning | "I'll break the task into 3 steps: find booking → check policies → update" |
| Analysis | "Based on the API error, the issue is in the date format" |
| Self-reflection | "My previous answer was too generic" |
Step-by-step reasoning before answering.
Single generation.
«Let's think step by step.»
Alternating Think ↔ Act ↔ Observe.
Suitable for tool-use tasks
Built into the model during training
(o1, DeepSeek R1).
<think>...</think> — self-reflection.
| Characteristic | CoT | ReAct | Reasoning (o1) |
|---|---|---|---|
| Step-by-step logic | Yes | Yes | Yes |
| External tools | No | Yes | Optional |
| Plan correction | No | Yes (Observation) | Internal |
| Where defined | Prompt | Prompt | Model training |
| Best for | Logic, math | Tool-based tasks | Complex planning |
| Cost | Low | Medium (N calls) | High (reasoning tokens) |
| Format | Description | Example |
|---|---|---|
| JSON Agent | Action as a JSON object | {"action": "search_flights", ...} |
| Function-calling | Native model format | Messages with tool_calls |
| Code Agent | Executable code generation | results = search_flights(...) |
| Observation Type | Example |
|---|---|
| API Data | {"flights": [...], "count": 3} |
| System Error | {"error": "rate_limit_exceeded", "retry_after": 30} |
| Confirmation | {"status": "booking_confirmed", "id": "BK-12345"} |
| User Input | "Yes, book this flight" |
from pydantic import BaseModel
class SubTask(BaseModel):
agent_name: str
description: str
priority: int
class Plan(BaseModel):
subtasks: list[SubTask]
structured_llm = llm.with_structured_output(Plan)
plan = structured_llm.invoke(
"Break the rebooking task into subtasks"
)
# plan.subtasks -> [SubTask(agent_name="flight", ...), ...]
| Single-Agent | Multi-Agent | |
|---|---|---|
| Strengths | Simplicity, no coordination, fewer resources |
Complex tasks, specialization, parallelism, fault tolerance |
| Weaknesses | Limited by context, confused with many tools |
Coordination overhead, debugging complexity |
| When to choose | Simple tasks (2–5 tools) |
Many tools, diverse expertise |
| Criterion | Hierarchical | Decentralized | Centralized | Shared Pool |
|---|---|---|---|---|
| Task complexity | High | Medium-High | Low-Medium | Medium |
| Fault tolerance | Medium | High ★ | Low | Medium |
| Scalability | Medium | High ★ | Low | High ★ |
| Ease of debugging | High ★ | Low | High ★ | Medium |
| Predictability | High ★ | Low | High ★ | Medium |
Agent ↔ Tool
Analogy: USB-C — a universal
adapter for connecting AI
to tools
Anthropic, Nov 2024
Agent ↔ Agent
Analogy: Wi-Fi Direct — direct
communication between devices
Google, Apr 2025
| Category | Problem | Example |
|---|---|---|
| Resource Intensity | Each agent = LLM call. 3 agents × 5 iterations = 15+ calls |
Cost, latency |
| Error Accumulation | One agent's error amplifies down the chain |
A found the wrong flight → B booked it |
| Debugging | Hard to tell which agent failed in a long chain |
Need tracing of every step |
| Anti-pattern | Problem | Solution |
|---|---|---|
| MAS for a simple task | Overhead > benefit | Start with single-agent |
| 10+ agents at once | Impossible to debug | Incrementally: 2–3 → validate |
| No critic in critical domains |
Errors reach the user |
Always use Critic for critical data |
| All agents on expensive models | Expensive and slow | Small models for simple agents |
| No tracing | Impossible to debug | Log every TAO step |
| Type | Modality | Example Tasks |
|---|---|---|
| Vision | Images, Video stream | UI analysis, document OCR, visual QA |
| Voice | Audio | Voice assistants, call centers |
Notebook for this intensive: