A library and a living textbook — real LLM outputs, provider-agnostic, deterministic-picker discipline throughout, and a comparative benchmark leaderboard that ranks every architecture against every relevant task.这是一个库,也是一本动态教科书——包含真实的 LLM 输出、与提供商无关的架构、贯穿始终的确定性选择器(deterministic-picker)准则,以及一个将每种架构与相关任务进行对比的基准测试排行榜。
| ARCHITECTURES | PASSING TESTS | BENCHMARK TASKS | LLM PROVIDERS | MOCKED RUNS |
A single Python library that packages every major agentic AI pattern from the literature as a runnable Architecture class with a uniform contract. Each pattern ships with a fully executed Jupyter notebook whose theory is written against the captured run — not synthetic examples. The library is multi-provider (Nebius, OpenAI, Anthropic, Groq, Ollama, Together, Fireworks, Mistral, Google) and built on top of LangGraph state machines.这是一个单一的 Python 库,它将文献中所有主要的智能体 AI 模式封装为具有统一接口的可运行 Architecture 类。每种模式都附带一个完整执行的 Jupyter notebook,其理论基于实际运行结果而非合成示例编写。该库支持多家提供商(Nebius、OpenAI、Anthropic、Groq、Ollama、Together、Fireworks、Mistral、Google),并基于 LangGraph 状态机构建。
The central technical discipline of the repository is the deterministic-picker pattern — every LLM-as-Scorer surface has the LLM commit to categorical features (booleans, enums) and lets Python compose the deciding signal. This is the universal escape from the LLM-as-Scorer flat-band pathology, applied in 13 of 35 architectures; 9 more are architecturally immune by design.本仓库的核心技术准则为“确定性选择器”模式——每个作为评分器的 LLM 界面都会让 LLM 提交分类特征(布尔值、枚举),并由 Python 代码组合出最终决策信号。这是规避“LLM 作为评分器”时出现性能平坦化病态问题的通用方案,已应用于 35 种架构中的 13 种;另外 9 种架构在设计上天然免疫此类问题。
pip install "agentic-architectures[nebius,faiss,tavily]"from agentic_architectures import get_llm
from agentic_architectures.architectures import Reflection
arch = Reflection(llm=get_llm(), max_iterations=2, target_score=8)
result = arch.run("Write a haiku about a glacier.")
print(result.output)
print("score:", result.metadata["final_score"], "/ 10")Same .run(task) interface across all 35 architectures. Same ArchitectureResult return shape. Swap the class, swap the pattern — your downstream code does not change.所有 35 种架构均使用相同的 .run(task) 接口,并返回统一的 ArchitectureResult 格式。只需更换类名即可切换模式,无需修改下游代码。
Set up a virtualenv from a fresh clone从全新的克隆库中设置 virtualenv
git clone https://github.com/FareedKhan-dev/all-agentic-architectures
cd all-agentic-architectures
python -m venv .venv
.venv\Scripts\activate # Windows
source .venv/bin/activate # macOS / Linux
pip install -e ".[dev,test,docs,nebius,faiss,tavily,networkx]"
cp .env.example .env # then fill in NEBIUS_API_KEY etc.
pytest -q # 283 tests pass in ~30s|
Self-critique loops that drive answer quality up through iteration.
|
Sample many paths or grow a tree with rewards.
|
Ground every claim — five retrieval shapes.
|
|
Learn across calls — pick the storage shape.
|
From one search tool to a real Chromium browser.
|
Specialists, debate, multi-perspective research.
|
|
Categorical actions through deterministic Python gates.
|
Patterns with a unique shape.
|
Patterns that appear across families.
|
Reasoning & Reflection推理与反思
| Architecture | Pattern | Reference |
|---|---|---|
| Reflection | Generate → critique → refine | Madaan 2023 |
| Reflexion | Verbal reflections in episodic memory | Shinn 2023 |
| Chain-of-Verification (CoVe) | Verify each baseline claim independently | Dhuliawala 2023 |
| Self-Discover | SELECT → ADAPT → IMPLEMENT → SOLVE | Zhou 2024 |
| Constitutional AI | Per-rule pass/fail → revise | Bai 2022 |
Sampling & Search采样与搜索
| Architecture | Pattern | Reference |
|---|---|---|
| Self-Consistency | Sample N paths, majority-vote | Wang 2022 |
| Tree of Thoughts | Beam search over thoughts | Yao 2023 |
| LATS | MCTS tree with reward backup | Zhou 2024 |
| Mental Loop | Simulate → score (deterministic-picker) | this repo |
| Ensemble | N voters, weighted aggregation | this repo |
Retrieval (RAG)检索 (RAG)
| Architecture | Pattern | Reference |
|---|---|---|
| Agentic RAG | Agent decides when & what to retrieve | LangGraph reference |
| Corrective RAG (CRAG) | Grade docs, fall back to web | Yan 2024 |
| Self-RAG | Per-doc reflection tokens | Asai 2024 |
| Adaptive RAG | Pre-route by query complexity | Jeong 2024 |
| GraphRAG | KG + community summaries | Microsoft 2024 |
Memory记忆
| Architecture | Stored unit | Reference |
|---|---|---|
| Episodic + Semantic | Conversation turns + triples | Park 2023 |
| Graph Memory | (subject, predicate, object) triples | this repo |
| MemGPT | OS-style context + archival tiers | Packer 2023 |
| Voyager | Reusable Python skills (real subprocess) | Wang 2023 |
| Agent Workflow Memory | High-level workflow recipes | Wang 2024 |
Tools & Actions工具与行动
| Architecture | Pattern | Reference |
|---|---|---|
| Tool Use | Agent with one tool | LangChain reference |
| ReAct | Thought → Action → Observation | Yao 2022 |
| Planning | Decompose → execute → replan | Wei 2022 |
| Plan-Execute-Verify (PEV) | Post-execution verification per step | this repo |
| SWE-Agent | Sandboxed file-system agent | Yang 2024 |
| BrowserAgent | Real Playwright + safety gate | Anthropic Computer-Use 2024 |
Multi-Agent多智能体
| Architecture | Pattern | Reference |
|---|---|---|
| Multi-Agent | Supervisor + specialists | LangGraph reference |
| Blackboard | Shared workspace + agents | classical AI |
| Debate | N agents × K rounds | Du 2023 |
| STORM | Multi-perspective research → article | Shao 2024 |
| Meta-Controller | Router over architectures | this repo |
Safety, Routing & Specialty安全、路由与专业领域
| Architecture | Pattern | Reference |
|---|---|---|
| Dry-Run | Propose → simulate → approval gate | this repo |
| Reflexive Metacognitive | Self-aware capability routing | this repo |
| RLHF Self-Improvement | Multi-dim deterministic scoring + archive | this repo |
| Cellular Automata | LLM rules over a grid | this repo |
| Provider | Install extra | Notes |
|---|---|---|
| Nebius (default) | [nebius] | Llama-3.3-70B + Qwen3-Thinking; cheapest for the included demos |
| OpenAI | [openai] | All architectures work; highest quality for reasoning patterns |
| Anthropic | [anthropic] | Strong on long context; required for production Computer-Use |
| Groq | [groq] | Fast inference; great for high-volume Self-Consistency |
| Ollama (local) | [ollama] | No API key; tool calling depends on the model |
| Together | [together] | Wide model catalogue |
| Fireworks | [fireworks] | Function-calling first-class |
| Mistral | [mistral] | EU-hosted option |
[google] | Gemini 2.x via Generative AI API |
Switch via LLM_PROVIDER + the corresponding key in .env. No code changes.通过 LLM_PROVIDER 和 .env 文件中的对应密钥进行切换,无需更改代码。
A 17-task suite runs every architecture and scores results. Most recent run, real Nebius Llama-3.3-70B, ~25 min, ~$1.50 in tokens:包含 17 个任务的测试套件会运行每种架构并对结果进行评分。最近一次运行使用真实的 Nebius Llama-3.3-70B,耗时约 25 分钟,Token 成本约 1.50 美元:
| Outcome | Architectures |
|---|---|
| Strong 2/2 or 3/3 | Reflection SelfConsistency SelfDiscover BrowserAgent |
| Perfect on attempted 1/1 | 21 more — see leaderboard |
| Pattern-fit failures | LATS on arithmetic (wrong shape) · Debate + Ensemble on Sally trick (group-think) · Reflexion + AWM on raw-fact recall (wrong memory shape) |
| Overall | 33 / 42 correct 78% |
Full leaderboard with per-task answer excerpts: docs/benchmarks.md包含各任务答案摘要的完整排行榜:docs/benchmarks.md
Four curated reading orders, depending on what you're trying to do.根据你的目标,提供四种精选阅读顺序。
| Path | For | Order |
|---|---|---|
| Beginner | Mental model | Reflection → Tool Use → ReAct → Planning → Self-Consistency |
| RAG-focused | Production retrieval | Agentic RAG → CRAG → Self-RAG → Adaptive RAG → GraphRAG |
| Multi-agent | Coordination | Multi-Agent → Blackboard → Debate → STORM → Meta-Controller |
| Safety | Guardrails | Dry-Run → Constitutional AI → Reflexive Metacognitive → BrowserAgent (safety gate) |
pytest -q
283 passed, 37 skipped (env-gated integration), 1 warning in ~30s
| Suite | Coverage |
|---|---|
| Registry sweep | All 35 architectures (metadata + instantiate + build) |
| Pure-Python helpers | Haiku checker, composite scorers, subprocess executor, safety gate, sandbox path |
| Notebook integrity | All 35 notebooks executed, no error outputs, §9 commentary tailored from real captured runs |
| Integration (env-gated) | One real-LLM happy-path per architecture, gated via RUN_INTEGRATION=1 |
| Full docs site | Dark-mode site with embedded notebooks (live after first deploy) |
| Quickstart | One-command install, 8-line example |
| Switching providers | Capability matrix; one env var to swap |
| Add your own architecture | 5-step contributor recipe |
| Deterministic-picker pattern | The central technical pattern, explained once |
| Memory variants | Comparison of all 7 memory shapes |
| API reference | mkdocstrings auto-gen from docstrings (live after first deploy) |
| Benchmarks | Full per-task leaderboard with answer excerpts |
Contributions welcome. Two paths:欢迎贡献。有两种途径:
- Add a new architecture — follow the 5-step recipe. The PR template includes a deterministic-picker checklist.添加新架构——遵循 5 步指南。PR 模板包含确定性选择器的检查清单。
- Improve an existing one — bug fix, prompt tuning, performance, scoring rubric. Open an issue first to discuss scope.改进现有架构——包括 Bug 修复、提示词优化、性能提升或评分准则优化。请先开启 Issue 讨论范围。
See CONTRIBUTING.md for the dev setup, code style, and commit-message convention (Conventional Commits — release-please auto-generates the CHANGELOG).请参阅 CONTRIBUTING.md 了解开发环境设置、代码规范和提交信息约定(Conventional Commits——release-please 会自动生成 CHANGELOG)。
@misc{khan2026agentic,
title = {Agentic Architectures: A Library of 35 Production-Grade Agentic AI Patterns},
author = {Khan, Fareed},
year = {2026},
howpublished = {\url{https://github.com/FareedKhan-dev/all-agentic-architectures}},
note = {MIT licensed Python library and runnable textbook}
}MIT — © 2026 Fareed Khan.MIT — © 2026 Fareed Khan。