AI Agents Tutorial with Examples.
AI agents tutorial: autonomous agent systems with ReAct, tool-calling, memory, multi-agent orchestration and production agent patterns.
Architecture at a glance
Click any box to open the lesson that teaches it
AI agent architecture at a glance
goal → plan → act (tool call) → observe → repeat → answer
How it fits together (8 steps)
- An agent starts from a goal and a plan. The plan is parsed as data and validated before anything runs, and the agent replans when a step fails.
- Each step acts through a tool call — the tool_use / tool_result loop — then reads the result back as an observation, the ReAct pattern of thought, action and observation.
- That loop repeats until the model gives a final answer, or a step cap and a repeat check stop it, as intro.md's runaway-loop example shows.
- What the agent draws on: memory that survives a session, a RAG agent that rephrases and searches again until the evidence clears a relevance bar, a token-budgeted context, and tools exposed over MCP with their schemas and errors.
- Scaling out: an orchestrator fans work out to several subagents in parallel, and a long-running agent survives a crash through checkpoints and idempotency keys.
- Before it ships: replies are schema-validated, graded on outcome and trajectory over many runs, and checked against prompt injection and excessive agency.
- Destructive tool calls wait on a human: an agent loop over MCP tools gates deletes on approval, checked by the agent or enforced by the server through elicitation.
- Then build something real: the projects page runs from a calculator agent to a multi-agent debate system.
Beginner
Start here — no prior experience needed
AI Agents Learning Roadmap
A structured path from building your first tool-using agent to orchestrating multi-agent systems that plan, remember, and self-correct.
Introduction to AI Agents
What makes an AI agent: tools, the ReAct loop of thought, action and observation, step caps that stop runaway loops, and memory that survives sessions.
Intermediate
For developers with core concepts down
AI Agent Planning Patterns
Plans as validated data, plan-then-execute with replanning on failure, parallel steps from a dependency graph, and checking results before acting.
AI Agent Memory Systems
Sliding windows that forget, fact summaries that don't, a SQLite store that persists across sessions, pinned memories, and deletion, all as runnable code.
An Agent Loop Over MCP Tools, With Human Approval
Build an agent loop on MCP: discover tools, validate a plan, run read-only tools freely, gate destructive ones on approval, and use several MCP servers.
Advanced
Production-grade patterns for experienced engineers
Multi-Agent Systems
Orchestrators and subagents in runnable Python: parallel fan-out, partial failures, parsing a model's plan safely, and approval gates for risky tool calls.
RAG Agents
An agent loop that searches, reads, rephrases and searches again, keeps weak matches out, verifies its citations and says so when the docs don't answer.
Agent Evaluation
Grade agents on outcome and process, measure pass rates over repeated runs, test safety under pressure, and audit logged trajectories.
Autonomous Agent Workflows
Make long agent runs safe to crash and rerun: checkpoints, idempotent side effects, timeouts on parallel calls, approval gates and spending budgets.
AI Agents Projects
Projects that build real autonomous agents — from single-tool agents to multi-agent systems that plan, execute, and self-correct.
Also part of AI Agents
Taught in other topics. Each link opens the lesson in its home topic.
LLM Tool Use and Function Calling
Tool schemas, argument validation, the tool_use/tool_result loop, error recovery, parallel calls and approval gates, all run against a scripted model.
Structured Outputs in Production
Why 'return JSON only' isn't enough, and how schema validation plus a retry loop turns a flaky text model into a reliable data source.
LLM Context Engineering
Fit system prompt, history, documents and tool results into a token budget, cite sources, chunk by heading and trim tool output, all as runnable Python.
LLM Security Beyond Guardrails
Indirect prompt injection, excessive agency, and insecure output handling — the OWASP-style risks that survive input/output guardrails.
MCP: Your First Server and Client
Build a Model Context Protocol server with one tool in Python, call it from a scripted client over stdio and in memory, and see why stdout is off limits.
MCP Tools: Schemas, Results and Errors
See the inputSchema MCP builds from Python type hints, return structured output, and tell tool errors from protocol errors, all with real printed results.
Elicitation, Sampling and Roots (Multi Round-Trip Requests)
Let an MCP server ask the client for input mid-call: elicitation, sampling and roots via multi round-trip requests, with scripted callbacks.