# agent-study **Repository Path**: m626/agent-study ## Basic Information - **Project Name**: agent-study - **Description**: AI Agent全栈课程:从ReAct循环到Claude Code逆向、MCP/A2A协议、RAG、DSPy、生产可观测性——全部为可运行Python文件,面试导向。 - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-06-07 - **Last Updated**: 2026-06-07 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README

🤖 AI Agent Full-Stack Learning Course

Master AI Agent core theory and engineering from zero to one
36 Chapters · 22,000+ Lines of Code · 60+ Runnable Examples · Interview-Ready

Python Chapters License Update
🇨🇳 中文 README

--- ## 🔗 Quick Links

Live Site GitHub RAG Deep Dive MCP Protocol

> **🌐 No installation — read in your browser**: [agent-study-ruddy.vercel.app](https://agent-study-ruddy.vercel.app/) · All 36 chapters · Dark blueprint theme · Mobile-friendly --- ## 📖 Overview A **career-oriented** AI Agent full-stack learning course. From Agent fundamentals to Claude Code reverse engineering, from RAG to MCP/A2A protocols, from DSPy to production observability — covering **36 topics across 7 tiers**. Each chapter is a **standalone runnable `.py` file** — a complete lecture and executable code in one. > **Target audience**: New graduates, career switchers, and any developer looking to systematically master AI Agents. --- ## 🗺️ Course Roadmap (36 Chapters · 7 Tiers) ``` Tier 1: Foundations ── Tier 2: Engineering ── Tier 3: Deep Tech ── Tier 4: Production Ch0-3 Ch4-7 Ch8-12 Ch13-18 Tier 5: Advanced Arch ── Tier 6: Reinforcement ── Tier 7: Expert Ch19-24 Ch25-28 Ch29-36 ``` ### Tier 1: Agent Foundations | Ch | Topic | Key Technologies | |------|------|----------| | **[Ch0](https://callous-0923.github.io/agent-study/chapter_00_overview/00_course_overview.html)** | Course Overview & Setup | Learning roadmap, dependency installation, API key config | | **[Ch1](https://callous-0923.github.io/agent-study/chapter_01_fundamentals/01_hello_agent.html)** | Your First Agent | Handwritten ReAct loop, Function Calling principles | | **[Ch2](https://callous-0923.github.io/agent-study/chapter_02_components/02_agent_components.html)** | Agent Core Components | Planner, memory systems (short/long/working term), tool design golden rules | | **[Ch3](https://callous-0923.github.io/agent-study/chapter_03_types/03_agent_types.html)** | Agent Architecture Types | ReAct / Plan-Execute / Reflexion comparison | ### Tier 2: Engineering Practice & Frameworks | Ch | Topic | Key Technologies | |------|------|----------| | **[Ch4](https://callous-0923.github.io/agent-study/chapter_04_frameworks/04_frameworks.html)** | Mainstream Frameworks | LangChain Agent + LangGraph state machine | | **[Ch5](https://callous-0923.github.io/agent-study/chapter_05_multi_agent/05_multi_agent.html)** | Multi-Agent Systems | Writer+Reviewer collaboration, crewAI style | | **[Ch6](https://callous-0923.github.io/agent-study/chapter_06_evaluation/06_evaluation.html)** | Evaluation & Testing | Eval frameworks, LLM-as-Judge, production checklist | | **[Ch7](https://callous-0923.github.io/agent-study/chapter_07_interview/07_interview_prep.html)** | Interview Preparation | 20 high-frequency questions + project guide + interview flow | ### Tier 3: Deep Technical Analysis | Ch | Topic | Key Technologies | |------|------|----------| | **[Ch8](https://callous-0923.github.io/agent-study/chapter_08_claude_code/08_claude_code_architecture.html)** | Claude Code Architecture | nO main loop, h2A Steering, context compaction, SubAgent | | **[Ch9](https://callous-0923.github.io/agent-study/chapter_09_rag_deepdive/09_rag_deepdive.html)** | RAG Deep Dive | Chunking strategies, Embedding selection, RRF, Cross-Encoder, production modes | | **[Ch10](https://callous-0923.github.io/agent-study/chapter_10_mcp/10_mcp_deepdive.html)** | MCP Protocol Explained | JSON-RPC, primitives (Tools/Resources/Prompts), capability negotiation | | **[Ch11](https://callous-0923.github.io/agent-study/chapter_11_tool_calling/11_tool_calling_deepdive.html)** | Tool Calling Internals | OpenAI vs Anthropic, streaming assembly, strict mode | | **[Ch12](https://callous-0923.github.io/agent-study/chapter_12_infrastructure/12_infrastructure.html)** | Agent Production Infrastructure | OpenClaw architecture, Harness, production checklist | ### Tier 4: Production Engineering | Ch | Topic | Key Technologies | |------|------|----------| | **[Ch13](https://callous-0923.github.io/agent-study/chapter_13_fastapi/13_fastapi_agent_service.html)** | FastAPI Agent Service | REST API, SSE streaming, WebSocket, production deployment | | **[Ch14](https://callous-0923.github.io/agent-study/chapter_14_sqlite/14_sqlite_agent_storage.html)** | SQLite Persistence | 5-table schema, WAL mode, session/task/user management | | **[Ch15](https://callous-0923.github.io/agent-study/chapter_15_a2a/15_a2a_protocol.html)** | Google A2A Protocol | AgentCard, Task, Artifact, multi-agent collaboration | | **[Ch16](https://callous-0923.github.io/agent-study/chapter_16_memgpt/16_memgpt_letta.html)** | MemGPT/Letta Memory | Core Memory, Heartbeat, Sleep-Time, Filesystem Memory | | **[Ch17](https://callous-0923.github.io/agent-study/chapter_17_computer_use/17_computer_use.html)** | Computer Use | Screenshot-Action Loop, coordinate calculation, security sandbox | | **[Ch18](https://callous-0923.github.io/agent-study/chapter_18_security/18_agent_security.html)** | Agent Security & Guardrails | Prompt Injection, privilege levels, input sanitization, 4-layer defense | ### Tier 5: Advanced Architecture & Optimization | Ch | Topic | Key Technologies | |------|------|----------| | **[Ch19](https://callous-0923.github.io/agent-study/chapter_19_workflow_patterns/19_workflow_patterns.html)** | Agentic Workflow Patterns | Reflection / Routing / Orchestrator-Worker / Evaluator-Optimizer (7 patterns) | | **[Ch20](https://callous-0923.github.io/agent-study/chapter_20_context_engineering/20_context_engineering.html)** | Context Engineering | Context Rot, budget management, XML-structured prompts, Skill.md | | **[Ch21](https://callous-0923.github.io/agent-study/chapter_21_streaming/21_streaming_architecture.html)** | Streaming & Real-time Architecture | EventBus, dynamic interrupts, backpressure, StateManager Reducer | | **[Ch22](https://callous-0923.github.io/agent-study/chapter_22_dspy/22_dspy.html)** | DSPy Auto-Optimization | Signature→Module→Optimizer, automatic few-shot, LangChain complement | | **[Ch23](https://callous-0923.github.io/agent-study/chapter_23_code_agents/23_code_agents.html)** | Code Agent Architecture Survey | CodeAct / ACI / Plan-Execute, SWE-bench, Agentless findings | | **[Ch24](https://callous-0923.github.io/agent-study/chapter_24_observability/24_observability.html)** | Agent Observability | Tracing Span tree, dashboards, LangSmith vs LangFuse, alerting | ### Tier 6: Foundational Reinforcement | Ch | Topic | Key Technologies | |------|------|----------| | **[Ch25](https://callous-0923.github.io/agent-study/chapter_25_vectordb/25_vectordb.html)** | Vector Database Selection | Chroma / Pinecone / Milvus / Qdrant comparison, Embedding trade-offs | | **[Ch26](https://callous-0923.github.io/agent-study/chapter_26_model_routing/26_model_routing.html)** | Model Routing Strategies | Threshold / Cascade / Semantic / Cost-Aware (4 strategies) | | **[Ch27](https://callous-0923.github.io/agent-study/chapter_27_prompt_eng/27_prompt_engineering.html)** | Agent Prompt Engineering | System Prompt 6-module template, tool description scoring card | | **[Ch28](https://callous-0923.github.io/agent-study/chapter_28_cache/28_cache.html)** | Semantic Caching & Token Optimization | Exact→Semantic→LLM three-tier cache, token budget management | ### Tier 7: Expert Level | Ch | Topic | Key Technologies | |------|------|----------| | **[Ch29](https://callous-0923.github.io/agent-study/chapter_29_multimodal/29_multimodal.html)** | Multi-Modal Agent | Vision + text joint reasoning, multi-modal tool calling | | **[Ch30](https://callous-0923.github.io/agent-study/chapter_30_reliability/30_reliability.html)** | Agent Reliability Engineering | Circuit breaker, exponential backoff retry, idempotency, degradation | | **[Ch31](https://callous-0923.github.io/agent-study/chapter_31_benchmarks/31_benchmarks.html)** | Agent Benchmarking in Depth | GAIA / AgentBench / WebArena / tau-bench | | **[Ch32](https://callous-0923.github.io/agent-study/chapter_32_self_improving/32_self_improving.html)** | Self-Improving Agent | Bad case collection → auto prompt optimization → eval validation | | **[Ch33](https://callous-0923.github.io/agent-study/chapter_33_prompt_cache/33_prompt_cache.html)** | Prompt Caching & Inference Optimization | Anthropic Cache, KV sharing, speculative decoding | | **[Ch34](https://callous-0923.github.io/agent-study/chapter_34_finetune/34_finetune.html)** | Model Fine-tuning for Function Calling | LoRA, fine-tuning data preparation, cost-benefit analysis | | **[Ch35](https://callous-0923.github.io/agent-study/chapter_35_data_flywheel/35_data_flywheel.html)** | Data Flywheel | Interaction collection → bad case detection → auto-triggered improvement | | **[Ch36](https://callous-0923.github.io/agent-study/chapter_36_defense/36_defense.html)** | Agent Defense in Depth | Canary Token, layered isolation, behavioral sandbox | --- ## 🚀 Quick Start ### 1. Clone the Repository ```bash git clone https://github.com/Callous-0923/agent-study.git cd agent-study ``` ### 2. Check Environment ```bash python chapter_00_overview/00_course_overview.py ``` ### 3. Install Dependencies Open `chapter_00_overview/00_course_overview.py`, change `install = False` to `install = True`, then run: ```bash python chapter_00_overview/00_course_overview.py ``` ### 4. Configure API Key (only needed for Ch1-5) Create a `.env` file in the project root: ```env OPENAI_API_KEY=sk-your-api-key-here OPENAI_BASE_URL=https://api.openai.com/v1 LLM_MODEL=gpt-4o-mini ``` > You can also use other providers (DeepSeek, Qwen, etc.) by changing `OPENAI_BASE_URL` and `LLM_MODEL`. ### 5. Start Learning (most chapters require no API key!) ```bash # No API key needed — run directly python chapter_08_claude_code/08_claude_code_architecture.py python chapter_10_mcp/10_mcp_deepdive.py python chapter_14_sqlite/14_sqlite_agent_storage.py python chapter_19_workflow_patterns/19_workflow_patterns.py python chapter_21_streaming/21_streaming_architecture.py python chapter_24_observability/24_observability.py python chapter_26_model_routing/26_model_routing.py python chapter_28_cache/28_cache.py ``` --- ## 📦 Dependencies | Dependency | Chapters | Description | |------|----------|------| | `openai` | Ch1-3 | OpenAI API calls | | `langchain` + `langgraph` | Ch4-5 | Agent framework hands-on | | `fastapi` + `uvicorn` | Ch13 | Agent service deployment | | `pydantic` | Ch13 | Data model validation | | `python-dotenv` | Ch0 | Environment variable management | > **Note**: Chapters 8-12 and 14-28 mostly rely on the Python standard library (`sqlite3`, `asyncio`, `hashlib`, etc.) — no extra installation needed. --- ## 🎯 Learning Paths ### Path 1: From Scratch (recommended for beginners) Follow Ch0 → Ch36 in order, 1-2 hours per chapter. ### Path 2: Interview Cram (key chapters) - **Ch7**: 20 high-frequency interview questions + process - **Ch8**: Claude Code architecture (industry-grade Agent design) - **Ch9**: RAG deep dive - **Ch10 + Ch15**: MCP & A2A dual protocols - **Ch11**: Tool Calling internals - **Ch18**: Agent security (demo vs. production engineer differentiator) - **Ch19**: Workflow design patterns (universal system design framework) - **Ch26**: Model routing (50-80% cost reduction) ### Path 3: Build Products - **Ch13**: FastAPI service - **Ch14**: SQLite persistence - **Ch12 + Ch24**: Production checklist + observability - **Ch26 + Ch28**: Cost optimization (routing + caching) --- ## 🧠 Core Technology Coverage ``` Tool Calling Internals ★★★★★ Complete OpenAI vs Anthropic comparison + Streaming assembly MCP Protocol ★★★★★ Full lifecycle simulation (Initialize→tools/call) A2A Protocol ★★★★★ AgentCard/Task/Artifact + Multi-Agent collaboration Claude Code Architecture★★★★★ nO/h2A/Compaction/SubAgent reverse analysis RAG Full-Stack ★★★★ Chunking/Embedding/RRF/Cross-Encoder/Production Model Routing ★★★★ 4 strategies + cost comparison experiments (94% savings) Semantic Caching ★★★★ Three-tier cache + Token budget management Agent Security ★★★★ Prompt Injection + privilege levels + 4-layer defense DSPy Auto-Optimization ★★★★ Signature/Module/Optimizer + LangChain complement Agentic Workflow ★★★★ 7 design patterns + system design answer framework Context Engineering ★★★★ Context Rot principles + XML Prompt + budget management Streaming Architecture ★★★★ EventBus + dynamic interrupts + backpressure Observability ★★★★ Tracing Span tree + LangSmith vs LangFuse MemGPT Memory ★★★★ Core Memory/Heartbeat/Sleep-Time/Filesystem Code Agents ★★★ CodeAct/ACI/Plan-Execute + SWE-bench Vector Databases ★★★ Chroma/Pinecone/Milvus/Qdrant + Embedding strategies FastAPI Service ★★★ REST/SSE/WebSocket + production deployment SQLite Persistence ★★★ 5-table Schema + WAL + audit queries Computer Use ★★★ Screenshot-Action Loop + security sandbox ``` --- ## 📁 Project Structure ``` agent-study/ ├── README.md ├── README_EN.md ├── .gitignore ├── chapter_00_overview/ 🚀 Course overview + setup ├── chapter_01_fundamentals/ 📖 First Agent (handwritten ReAct) ├── chapter_02_components/ 🧩 Planner + Memory + Tool design ├── chapter_03_types/ 🎯 ReAct / Plan-Execute / Reflexion ├── chapter_04_frameworks/ 🔧 LangChain + LangGraph ├── chapter_05_multi_agent/ 🤝 Multi-agent collaboration ├── chapter_06_evaluation/ 📊 Evaluation + testing strategies ├── chapter_07_interview/ 🎓 20 interview questions + career guide ├── chapter_08_claude_code/ 🏗️ Claude Code architecture reverse engineering ├── chapter_09_rag_deepdive/ 🔍 RAG deep dive (Chunking, Embedding, Production) ├── chapter_10_mcp/ 🔌 MCP protocol complete implementation ├── chapter_11_tool_calling/ ⚙️ Tool Calling internals ├── chapter_12_infrastructure/ 🏭 OpenClaw/Harness/Production infrastructure ├── chapter_13_fastapi/ 🌐 FastAPI Agent service ├── chapter_14_sqlite/ 💾 SQLite persistence ├── chapter_15_a2a/ 🤖 Google A2A protocol ├── chapter_16_memgpt/ 🧠 MemGPT/Letta memory architecture ├── chapter_17_computer_use/ 🖥️ Computer Use + GUI ├── chapter_18_security/ 🛡️ Agent security & guardrails ├── chapter_19_workflow_patterns/ 🏷️ Agentic Workflow design patterns ├── chapter_20_context_engineering/ 📐 Context Engineering ├── chapter_21_streaming/ 📡 EventBus real-time architecture ├── chapter_22_dspy/ 🔬 DSPy auto-optimization ├── chapter_23_code_agents/ 📊 Code Agent architecture survey ├── chapter_24_observability/ 📈 Observability (LangSmith/LangFuse) ├── chapter_25_vectordb/ 🗄️ Vector database selection ├── chapter_26_model_routing/ 🔀 Model routing & cost optimization ├── chapter_27_prompt_eng/ ✍️ Agent Prompt engineering ├── chapter_28_cache/ ⚡ Semantic caching & token optimization ├── chapter_29_multimodal/ 👁️ Multi-Modal Agent ├── chapter_30_reliability/ 🛡️ Agent reliability engineering ├── chapter_31_benchmarks/ 📊 Agent benchmarking in depth ├── chapter_32_self_improving/ 🔄 Self-Improving Agent ├── chapter_33_prompt_cache/ 💾 Prompt Caching & inference optimization ├── chapter_34_finetune/ 🎯 Model fine-tuning for Function Calling ├── chapter_35_data_flywheel/ 🔁 Data flywheel └── chapter_36_defense/ 🏰 Agent defense in depth ``` --- ## ✨ Features - **📝 Lecture-as-Code**: Each `.py` file is both a complete lecture (module-level docstring) and runnable code - **🤖 No API Key Needed**: Chapters 8-28 mostly use only the standard library — run directly - **🎤 Interview-Oriented**: Each chapter highlights key interview topics with answer frameworks and scoring points - **🔗 Cross-Referenced**: Chapters form a complete knowledge network through cross-references - **📊 Runnable Demos**: Every chapter includes complete demonstration output - **🇨🇳 Chinese-first** with English README available --- ## 🌟 References - [ReAct: Synergizing Reasoning and Acting in Language Models](https://arxiv.org/abs/2210.03629) (Yao et al., ICLR 2023) - [MemGPT: Towards LLMs as Operating Systems](https://arxiv.org/abs/2310.08560) (Packer et al., 2023) - [Reflexion: Language Agents with Verbal Reinforcement Learning](https://arxiv.org/abs/2303.11366) (Shinn et al., 2023) - [DSPy: Compiling Declarative LM Calls into Self-Improving Pipelines](https://arxiv.org/abs/2310.03714) (Khattab et al., 2023) - [SWE-bench: Can Language Models Resolve Real-World GitHub Issues?](https://arxiv.org/abs/2310.06770) (Jimenez et al., 2024) - [Agentless: Demystifying LLM-Based Software Engineering Agents](https://arxiv.org/abs/2407.01489) (Xia et al., 2024) - [MCP Official Specification](https://modelcontextprotocol.io) (Anthropic, 2024-2025) - [A2A Protocol Specification](https://a2a-protocol.org) (Google, 2025) - [Building effective agents](https://www.anthropic.com/engineering/building-effective-agents) (Anthropic, 2024) - [Effective context engineering for AI agents](https://www.anthropic.com/engineering/effective-context-engineering-for-ai-agents) (Anthropic, 2025) - [Claude Code Reverse Analysis](https://github.com/shareAI-lab/analysis_claude_code) (Community, 2025) --- ## 📄 License MIT License — Free to use, modify, and distribute. ---

If this project helps you, please give it a ⭐ Star!
36 Chapters · 7 Tiers · Continuously updated · Issues and PRs welcome