2025年10月初,谷歌资深工程主管、杰出工程师Antonio Gulli免费公开发布了一本长达400多页的新书——《Agentic Design Patterns: A Hands-On Guide to Building Intelligent Systems》。该书旨在为当前火热的AI Agent开发领域提供首批系统性的“设计模式”,更有条理地构建强大、可靠的智能系统。 全书内容覆盖从提示链、路由、工具使用等基础单元操作,到记忆管理、多智能体协作、安全护栏等高级主题,为开发者提供了一份从原型到生产实践的完整学习路线图。
AI Reading Assistant
Whole-book reading guide from stratified index samples; jump to passages in the text
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.
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
Excerpt 5
nt。首先通 过客户端凭证初始化 CalendarToolset,访问Google Calendar API。随后创建 LlmAgent 实例,配置Gemini 模型、名称和管理日历的说明,并集成 CalendarToolset 工具,实现日历查询和修改。说明中动态插入当前日期,便于时序 上下文。 以下代码展示了...
View in text
Excerpt 6
ID 不匹配。") 23 # 返回字典阻止工具执行 24 return { 25 "status": "error", 26 "error_message": f"工具调用被阻止:用户 ID 校验未通过,出于安全原因。" 27 } 28 29 # 允许工具继续执行 30 print(f"工具 '{tool.nam...
View in text
Excerpt 7
0 附录A ‑高级提示工程技术 提示结构化 除了提供示例,提示结构化对于引导模型至关重要。结构化提示通过不同部分(如指 令、上下文、示例)清晰分隔信息,帮助模型正确解析并理解每段文本的角色。 系统提示(System Prompting) 系统提示用于设定模型整体行为和交互目的,定义规则、角色或风格。与具体用户查询...
View in text
Excerpt 8
别与策略选择 4. 任务类型分类 →整数幂的算术比较。 选择解题策略 候选策略: A.直接计算(算出3⁴和 4³) B.对数比较(比较4・ln3与 3・ln4) C.模式启发(小指数时3的幂增长快于4?) 我选择策略A,因为数字很小,直接算最省资源。 阶段2 – 知识检索 6. 检索算术事实 3² = 9(记忆)...
View in text
Tags
AI categories
AIProgramming LanguageBackend
Text Preview (First 20 pages)
Registered users can read the full content for free
Register as a Gaohf Library member to read the complete e-book online for free and enjoy a better reading experience.
Generating text preview…
Loading comments...
Reply to Comment
Edit Comment