|
1 | | -# AgentPatterns Examples |
| 1 | +# AgentPatterns Examples: Runnable AI Agent Patterns in Python |
2 | 2 |
|
3 | | -Runnable code examples that accompany articles on [agentpatterns.tech](https://www.agentpatterns.tech). |
| 3 | +Production-style and beginner-friendly **AI agent examples** that map directly to the guides on [agentpatterns.tech](https://agentpatterns.tech). |
4 | 4 |
|
5 | | -This repository is a practical companion to the main project: each article can include a small, focused example you can run locally and adapt for your own use cases. |
| 5 | +If you want to learn how to build agents with real execution loops, tool boundaries, routing, and safety checks, this repo is the fastest way to run and inspect working code. |
6 | 6 |
|
7 | | -## What lives here |
| 7 | +## Why this repository |
8 | 8 |
|
9 | | -- `examples/` contains article-aligned examples. |
10 | | -- Each example is grouped by topic, then by language/runtime. |
11 | | -- Examples are intentionally minimal: clear logic, fast setup, easy to remix. |
| 9 | +- Learn by running real code, not pseudo-code. |
| 10 | +- Move from simple loops to advanced multi-step agent patterns. |
| 11 | +- Reuse minimal, clean implementations in your own projects. |
| 12 | +- Follow examples that are aligned with concrete docs and architecture explanations. |
12 | 13 |
|
13 | | -## Current structure |
| 14 | +## Available examples |
| 15 | + |
| 16 | +### Agent Patterns (Core Block) |
| 17 | + |
| 18 | +The most important block of the site and the main architecture layer for production agents. |
| 19 | + |
| 20 | +| Example | Focus | Local path | Article | |
| 21 | +| --- | --- | --- | --- | |
| 22 | +| ReAct Agent | `Think -> Act -> Observe` with budgets | `examples/react-agent/python` | https://agentpatterns.tech/en/agent-patterns/react-agent | |
| 23 | +| Routing Agent | Delegate to best specialist route | `examples/routing-agent/python` | https://agentpatterns.tech/en/agent-patterns/routing-agent | |
| 24 | +| Task Decomposition Agent | `Plan -> Execute -> Combine` workflow | `examples/task-decomposition-agent/python` | https://agentpatterns.tech/en/agent-patterns/task-decomposition-agent | |
| 25 | + |
| 26 | +### Foundations |
| 27 | + |
| 28 | +| Example | Focus | Local path | Article | |
| 29 | +| --- | --- | --- | --- | |
| 30 | +| Write Your First Agent | First loop (`Act -> Check -> Retry`) | `examples/write-your-first-agent/python` | https://agentpatterns.tech/en/start-here/write-your-first-agent | |
| 31 | +| Tool Calling Basics | Basic tool execution loop | `examples/tool-calling-basics/python` | https://agentpatterns.tech/en/foundations/tool-calling-basics | |
| 32 | +| Tool Calling | Tool + action restrictions (policy boundary) | `examples/tool-calling/python` | https://agentpatterns.tech/en/foundations/tool-calling | |
| 33 | +| LLM Limits in Agents | Validation, citations, confidence, handoff | `examples/llm-limits-agents/python` | https://agentpatterns.tech/en/foundations/llm-limits-agents | |
| 34 | + |
| 35 | +## Project structure |
14 | 36 |
|
15 | 37 | ```text |
16 | 38 | examples/ |
17 | 39 | write-your-first-agent/ |
18 | 40 | python/ |
| 41 | + tool-calling-basics/ |
| 42 | + python/ |
| 43 | + tool-calling/ |
| 44 | + python/ |
| 45 | + llm-limits-agents/ |
| 46 | + python/ |
| 47 | + react-agent/ |
| 48 | + python/ |
| 49 | + routing-agent/ |
| 50 | + python/ |
| 51 | + task-decomposition-agent/ |
| 52 | + python/ |
| 53 | +``` |
| 54 | + |
| 55 | +## Quick start |
| 56 | + |
| 57 | +### 1) Choose an example |
| 58 | + |
| 59 | +```bash |
| 60 | +EXAMPLE=react-agent |
| 61 | +cd examples/$EXAMPLE/python |
19 | 62 | ``` |
20 | 63 |
|
21 | | -## Quick start (Python example) |
| 64 | +### 2) Install and run |
22 | 65 |
|
23 | 66 | ```bash |
24 | | -cd examples/write-your-first-agent/python |
25 | 67 | python3 -m venv .venv |
26 | 68 | source .venv/bin/activate |
27 | 69 | pip install -r requirements.txt |
28 | 70 | export OPENAI_API_KEY="sk-..." |
29 | 71 | python main.py |
30 | 72 | ``` |
31 | 73 |
|
32 | | -## Relation to agentpatterns.tech |
| 74 | +## Prerequisites |
| 75 | + |
| 76 | +- Python 3.10+ (3.11+ recommended) |
| 77 | +- `OPENAI_API_KEY` environment variable |
| 78 | +- macOS/Linux shell commands above (adapt activation/export commands on Windows) |
| 79 | + |
| 80 | +## How this maps to agentpatterns.tech |
| 81 | + |
| 82 | +- **Docs** explain when and why to use each agent pattern. |
| 83 | +- **This repo** shows runnable implementations of those exact patterns. |
| 84 | +- Each example folder includes its own README with direct links to related concepts. |
| 85 | + |
| 86 | +## License |
33 | 87 |
|
34 | | -- Articles explain concepts and patterns. |
35 | | -- This repo provides runnable implementations for those materials. |
36 | | -- As new articles are published, matching examples are added here. |
| 88 | +MIT |
0 commit comments