AI guide
【One-Line Pitch】
A practical, pattern-based playbook for building production-grade AI agents—covering everything from prompt chaining and routing to multi-agent collaboration, memory, and safety—this book is for developers who want to move beyond toy demos and architect reliable, scalable intelligent systems.
【Book Arc】
- **Opening (~0%–10%)**: Sets the stage with a vision of autonomous agents and the "agentic economy," then introduces the foundational pattern of **prompt chaining**—breaking complex tasks into sequential sub-prompts for reliability and control.
- **Early (~10%–25%)**: Covers core orchestration patterns: **routing** (classifying requests to specialized handlers), **parallelization** (fan-out/fan-in for efficiency), and **reflection** (generate-critique-improve loops). Includes concrete code examples using LangChain and Google ADK.
- **Early-Middle (~25%–40%)**: Expands into **tool use/function calling** (connecting LLMs to external APIs and data), **planning** (decomposing high-level goals into executable steps), and introduces **multi-agent collaboration**—from simple sequential pipelines to supervisor and hierarchical communication structures.
- **Middle (~40%–55%)**: Dives into **memory management** (session state, persistence with ADK's SessionService), **learning and adaptation** (self-improving agents like SICA, AlphaEvolve), and the **Model Context Protocol (MCP)** for standardizing tool and data integration.
- **Late (~55%–75%)**: Addresses production concerns: **goal setting and monitoring**, **human-in-the-loop (HITL)** patterns for safety and oversight, and **knowledge retrieval (RAG)**—vector databases, chunking, and the challenges of grounding agents in enterprise data.
- **Ending (~75%–100%)**: Focuses on **safety and guardrails**, evaluation, and deployment best practices, culminating in a synthesis of patterns for building robust, production-ready agent systems. (Excerpts are thin here; this stage is inferred from the book's stated scope.)
【Key Takeaways】
- **Prompt chaining is the bedrock pattern** (Early): Decomposing complex tasks into sequential, single-purpose prompts dramatically improves output reliability and controllability. It's the foundation for stateful dialogue, code generation, and multi-step reasoning.
- **Routing enables scalable specialization** (Early): A coordinator agent that classifies user intent and delegates to specialized handlers (e.g., "Booker" vs. "Info") is a clean, reusable pattern for building modular systems. Both LangChain's `RunnableBranch` and ADK's tool-based routing achieve this.
- **Parallelization boosts efficiency and quality** (Early): Fan-out tasks (e.g., summary, questions, key terms) and then aggregate results—this pattern reduces latency and can improve output diversity. Use it when subtasks are independent.
- **Reflection loops turn LLMs into self-critics** (Early): A generate-critique-improve cycle, with a clear stop condition (e.g., "CODE_IS_PERFECT"), is a powerful way to iteratively refine code or text without human intervention.
- **Tool use is what makes agents "real"** (Early-Middle): Function calling bridges LLM reasoning with external APIs, databases, and code execution. The broader "tool calling" view includes delegating to other agents, making the LLM an orchestrator of digital resources.
- **Planning transforms reactive agents into strategic executors** (Middle): When a task requires multiple interdependent steps, having the agent first generate a plan—then execute it—enables handling of complex workflows like research reports or competitive analysis.
- **Multi-agent communication structures are a design choice** (Middle): From simple sequential pipelines to supervisor, hierarchical, and custom topologies, the relationship model directly impacts scalability, robustness, and fault tolerance. Choose based on task complexity and autonomy needs.
- **MCP standardizes agent-tool integration** (Middle): The Model Context Protocol provides a client-server architecture for dynamic discovery and use of tools, data, and prompts. It's essential for enterprise systems needing interoperability, while direct function calls suffice for fixed, small tool sets.
【Reading Tips】
- **Skim the vision chapters (0–10%)** for motivation, but don't get bogged down in the speculative "agentic economy" scenarios—the real value starts with prompt chaining.
- **Deep-read the pattern chapters (10–40%)** with code at hand. The LangChain and ADK examples are concrete; try modifying the routing or reflection examples to internalize the patterns.
- **Pay special attention to the ADK-specific sections** (memory, MCP, HITL)—these are less common in other resources and show Google's production-oriented approach.
- **Treat the "One-Picture Overview" and "Key Points" sections** as quick-reference summaries; use them to review before implementing a pattern.
- **If you're new to agents, skip the advanced learning/adaptation chapter (SICA, AlphaEvolve) initially**—it's fascinating but assumes familiarity with RL and self-improvement concepts.
【Coverage Limits】
This guide synthesizes the first ~55% of the book in detail (patterns through MCP and RAG). The later chapters on safety, evaluation, and deployment are only partially covered by the excerpts; readers should consult the full book for those topics.
Passage locations
Page 6
. . . . . . . . . . . . . . . . . . . . . . 117 参考资料 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117 第11章:目标设定与监控 . . . . . ....
View in text
Excerpt 2
"questions": questions_chain, 56 "key_terms": terms_chain, 57 "topic": RunnablePassthrough(), # 传递原始 topic 58 } 59 ) 60 61 # 2. 定义最终汇总 prompt,整合并行结果 62 synth...
View in text
Excerpt 3
output}") 79 except StopIteration: 80 print("\n未发现代码执行步骤。") 上述代码利用OpenAI API 执行“深度研究”任务。首先用API密钥初始化客户端,定 义智能体角色和用户研究问题。构造API调用,指定模型、输入和工具,要求自动推理 摘要并启用网络搜索。调用...
View in text
Excerpt 4
textprotocol/server‑filesystem", 23 TARGET_FOLDER_PATH, 111 116 第 10章:模型上下文协议(MCP) 定义了能力发现和调用的标准流程,采用客户端 ‑服务器架构,服务器可向任意合规客 户端暴露工具、数据资源和Prompt。LLM应用作为客户端,能动态发...
View in text