---
catalog_id: "R-105"
kind: "repo"
domain: "agent"
domain_label: "Agent 编排 / Agent Systems"
date: "2026-11-28"
title: "google/adk-recipes"
verdict: "三层组织可运行智能体配方与插件，80% 阈值评测门禁卡口"
summary: "Google 官方基于 ADK 构建的可运行 Agent 配方与垂直行业插件库，按 core/（11 个标准模式配方）、contrib/（社区与多语言可部署方案）与 plugins/（遵循 Agent Plugins v1.0.0 规范的垂直技能包）三层组织，并通过 JSON Schema、Ruff、脚手架校验器与 >=80% 阈值的 EVAL.yaml 评测门禁统一治理。"
summary_en: "Official ADK runnable recipes and vertical plugins across core/, contrib/, and plugins/, gated by schemas, Ruff, and 80% EVAL.yaml checks."
canonical_url: "https://oumuatown.com/repos/google__adk-recipes/"
markdown_url: "https://oumuatown.com/repos/google__adk-recipes.md"
og_image_zh: "https://oumuatown.com/og/zh/R-105.png"
og_image_en: "https://oumuatown.com/og/en/R-105.png"
cite_count: 44
repo: "google/adk-recipes"
github_url: "https://github.com/google/adk-recipes"
commit: "252a57c"
tags:
  - "google-adk"
  - "agent-recipes"
  - "agent-plugins"
  - "skills-toolset"
  - "guardrails"
  - "eval-harness"
  - "vertex-ai"
github_repos:
  - "https://github.com/google/adk-recipes/tree/252a57c"
---

# R-105 · google/adk-recipes

> **结论 / Verdict**: 三层组织可运行智能体配方与插件，80% 阈值评测门禁卡口
> **EN Summary**: Official ADK runnable recipes and vertical plugins across core/, contrib/, and plugins/, gated by schemas, Ruff, and 80% EVAL.yaml checks.

## Provenance & Evidence

- Primary Repository: https://github.com/google/adk-recipes (@252a57c)
- Verified Source Citations (#Lxx): 44
- Web Reader: https://oumuatown.com/repos/google__adk-recipes/

# google/adk-recipes

> 仓库地址：https://github.com/google/adk-recipes · 审计版本：`google/adk-recipes@252a57c` · 审计日期：2026-11-28
> 来源文章：[关联文章](../articles/2026-11-28-0xmovez-20-google-agent-repos.md)

## 定位与解决的真问题

- **核心定位与目标用户**：面向使用 Google Agent Development Kit（ADK，覆盖 Python / TypeScript / Go / Java / Kotlin）构建生产级智能体的开发者与企业团队，提供可直接 fork 或“先研读再适配（clone-and-study）”的模块化参考实现（`README.md#L6-L33`）。
- **相比常规做法解决的关键痛点**：
  1. **三层分级避免示范代码与生产模板混杂**：严格区分 `core/`（`agents-cli` 团队维护的 11 个教学型标准模式，每个均配备指导编码 Agent 阅读顺序的 `AGENTS.md`）、`contrib/`（必须可独立容器化部署到 Agent Engine / Cloud Run / Gemini Enterprise 的完整方案）与 `plugins/`（打包为编码助手可安装技能的垂直行业方案，如 `plugins/retail/`），并通过 `AGENTS.md#L4-L20` 禁止把仓库自用维护技能（`.agents/skills/`）与面向用户的行业插件混淆。
  2. **“配方 ≠ 脚手架”的按需能力装配**：与 `google/agents-cli` 配套，基础设施与工程壳由 `agents-cli` 脚手架生成，而 RAG、跨会话记忆、OAuth 授权、长程沙盒、安全护栏等业务能力则通过 `adk-recipes` 的单能力配方提供可拆解移植的源码范式（`README.md#L16-L31`）。
  3. **强工程门禁防止示例腐化**：仓库体积达 ~320 MB、跨 5 种语言，通过 `manifest.yaml` 责任人绑定（`ownership.team` + `ownership.poc`）、严格闭集 Schema 校验、`EVAL.yaml` ≥80% 评测阈值与静态脚手架检查抑制“示例写完即无人维护”（`docs/recipe-handbook/manifest.md#L51-L101`、`tools/validate_plugin_scaffolding.py#L16-L36`）。

## 技术栈与核心目录结构

- **语言 / 运行时 / 关键依赖**：Python 3.11+（`uv` + `ruff` + `pytest` + `jsonschema` + `pyyaml`）、ADK 多语言生态（`google-adk`、`google-genai`、`vertexai`、`google-cloud-modelarmor`）以及 TypeScript/Go/Java/Kotlin 配方矩阵（`AGENTS.md#L42-L56`、`README.md#L35-L46`）。
- **关键目录树与职责划分**（`google/adk-recipes@252a57c`，经 `--sparse` 检出顶层治理与核心切片核验）：
  - `core/python/`：11 个精选核心配方（`adk-voice-agent`、`ambient-expense-agent`、`ambient-quality-agent`、`cross-session-memory`、`deep-search`、`genmedia-for-commerce`、`long-horizon-harness`、`oauth-user-consent-flow`、`rag-agent-search`、`rag-vector-search`、`safety-plugins`），外加 `core/go/`。
  - `contrib/`：跨 5 门语言的社区/行业可部署方案（Python 13 个、Java 2 个、Kotlin 2 个、Go 1 个、TypeScript 1 个），均需配置 `deployable: true` 与根目录 `Dockerfile`（`docs/recipe-handbook/manifest.md#L39`）。
  - `plugins/`：遵循 Google Agent Plugins v1.0.0 规范（`https://agent-plugins.org/schemas/1.0.0/plugin.schema.json`）的垂直插件目录，当前标杆为 `plugins/retail/`，包含 `product-search` 与 `virtual-tryon` 两个技能包（`plugins/README.md#L1-L49`、`plugins/retail/plugin.json#L1-L26`）。
  - `tools/` & `.github/schemas/`：仓库治理与质量门禁引擎，涵盖 `validate_manifest.py`、`validate_plugin_scaffolding.py`、`run_plugin_eval.py`、`affected_recipes.py` 及两套 JSON Schema（`manifest-schema.json`、`plugin-schema.json`）。
  - `docs/`：包含面向贡献者的 `recipe-checklist.md` 与 `recipe-handbook/`（`anatomy.md`、`manifest.md`、`plugins.md`、`skills-catalog.md`）。

## 核心实现源码级剖析（附文件路径与行号）

1. **三类 ADK 扩展机制：`BasePlugin` 全局拦截、`SkillToolset` 动态加载与长程 Harness 组合**
   - **Runner 级安全插件（`BasePlugin`）**：`core/python/safety-plugins/safety_plugins/main.py#L50-L65` 将 `LlmAsAJudge` 或 `ModelArmorSafetyFilterPlugin` 直接挂载到 `InMemoryRunner(..., plugins=plugins)`，无需修改 Coordinator 或任何 Sub-agent 定义即可全局接管调用链。其中 `LlmAsAJudge`（`core/python/safety-plugins/safety_plugins/plugins/agent_as_a_judge.py#L63-L107`）通过 `JudgeOn` 枚举支持在 `USER_MESSAGE`、`BEFORE_TOOL_CALL`、`TOOL_OUTPUT`、`MODEL_OUTPUT` 四个生命周期回调点拦截；`ModelArmorSafetyFilterPlugin`（`core/python/safety-plugins/safety_plugins/plugins/model_armor.py#L55-L120`）则封装 Google Cloud Model Armor API（`sanitize_user_prompt` / `sanitize_model_response`）防止有毒提示或工具返回污染会话状态。
   - **运行时技能组合（`SkillToolset`）**：`contrib/python/agent-skills-tutorial/app/agent.py#L36-L200` 展示 ADK 原生 `SkillToolset` 的四种技能注入模式——内联 `models.Skill`（#L36-L58）、本地目录 `load_skill_from_dir`（#L66-L68）、外部仓库技能（#L76-L78）与附带 `models.Resources` 参考文档的 Meta-Skill `skill-creator`（#L86-L162），统一打包进 `SkillToolset` 后自动向 Agent 注册 `list_skills`、`load_skill` 与 `load_skill_resource` 工具（#L167-L176）。
   - **长程自治底座（`long-horizon-harness`）**：`core/python/long-horizon-harness/horizon/agent.py#L25-L200` 演示了生产级长程 Agent 如何把多项 ADK 扩展叠加到单一 `App`：使用 `AgentEngineSandboxCodeExecutor(..., stateful=True)` 提供有状态代码执行沙盒（#L139-L149）；针对原生 `PreloadMemoryTool` 每次把 `<PAST_CONVERSATIONS>` 塞入 `system_instruction` 导致 Gemini Context Cache 失效的问题，专门实现 `HorizonPreloadMemoryTool` 将历史记忆改放至不参与缓存指纹的尾部上下文（#L195-L199）；并挂接 `IterationBudgetPlugin`、`GuardrailsPlugin`（含 `exfil_guard`、`policies_guard`、`permission_guard`）以及按会话工作目录动态重绑技能的 `bind_session_skills_callback`（#L44-L91`, `#L122-L136`）。

2. **Agent Plugins v1.0.0 双布局校验与严格 Manifest 治理**
   - **垂直插件结构与过渡期双布局**：`docs/recipe-handbook/plugins.md#L13-L58` 定义了从旧版单技能目录（`plugins/<vertical>/<solution>/manifest.yaml`）向 Agent Plugins v1.0.0 规范目录（`plugins/<plugin-name>/plugin.json` + `skills/<skill-name>/SKILL.md`）的迁移规范，明确禁止同一目录下混放 `manifest.yaml` 与 `plugin.json`。
   - **插件 Schema 与脚手架静态检查**：`.github/schemas/plugin-schema.json#L1-L103` 强制校验 `$schema`、`name`（kebab/dot 命名正则）与 `ownership`（`team`、`poc`），并允许通过 `extensions` 反向域名命名空间携带客户端扩展字段且设置 `additionalProperties: false` 防止拼写静默失效。`tools/validate_plugin_scaffolding.py#L90-L250` 逐项验证每个技能必须具备带 `name`/`description` YAML Frontmatter 的 `SKILL.md`、Pass 阈值 `>= 0.80` 的 `EVAL.yaml` 以及不少于 30 字节的 `README.md`；`tools/validate_manifest.py#L89-L249` 对普通配方执行同样严格的闭集 YAML 校验，拒绝 `TODO` 占位符并输出含修复建议的可操作诊断。

3. **对话式安装器（Q-MODE）与插件评测体系（`EVAL.yaml`）**
   - **Q-MODE 交互式配置生成**：以 `plugins/retail/skills/product-search/SKILL.md#L22-L120` 为代表，垂直插件以 `SKILL.md` 充当编码助手的对话式安装向导：启动先询问 Quick Start（2 题）或 Full Setup（4 题），先通过 `bootstrap.sh` 初始化 `.venv` 与模板 `./design-spec.md`（并明令禁止并行竞态修改），再以 YAML Frontmatter 作为单一事实来源驱动 `setup.py` 完成 BigQuery 建表与 Vector Search 2.0 集合创建；其配套 `scripts/agent.py#L35-L168` 采用延迟 `vertexai.init` 避免 CI 无 ADC 环境下导入报错，并在 `app = apps.App(..., name="scripts")` 中显式匹配目录名以防 `adk web` 会话查找失败。
   - **规则+断言混合评测器**：`plugins/retail/skills/product-search/EVAL.yaml#L1-L219` 为每个用例同时定义自然语言 `rubric`（如不得编造目录外品牌/价格）与结构化 `assertions`（`contains_product`、`price_under`、`tool_called`、`no_hallucination`、`graceful_no_results` 等）。`tools/run_plugin_eval.py#L64-L313` 校验每条 rubric 是否包含 RFC 2119 强制词（`MUST` / `SHOULD` / `MUST NOT` / `SHALL` / `CANNOT`）且长度 ≥15 字符（#L77-L88），校验 13 种受支持的断言类型（#L102-L134），并强制整体通过率达到 `max(0.80, declared_threshold)`（#L207, `#L302`）。

4. **多通道部署配置：`agents-cli-manifest.yaml` 与可导出生产容器包**
   - **对接 `agents-cli` 的清单标记**：在如 `contrib/python/agent-skills-tutorial/agents-cli-manifest.yaml#L1-L22` 与 `core/python/long-horizon-harness/agents-cli-manifest.yaml` 中，配方通过放置 `agents-cli-manifest.yaml` 声明 `agent_directory`、`deployment_target`（如 `cloud_run`）与 `is_a2a: true`，使 `agents-cli deploy` 可直接接管部署；注释同时揭示故意省略 `acli_version` 以免误触发 `scaffold upgrade`（#L3-L8）。
   - **插件一键导出生产容器**：`plugins/retail/skills/virtual-tryon/scripts/export_app.py#L71-L150` 将沙盒脚本、静态 UI 与 `pyproject.toml` 中的 `[project.optional-dependencies].serving` 依赖动态生成为独立的 `requirements.txt`（避免手工维护导致运行期缺包崩溃，#L74-L78），连同 `plugins/retail/skills/virtual-tryon/assets/export-template/cloudbuild.yaml#L1-L25` 与 `deploy_cloudrun.sh#L18-L47` 一并导出，形成从本地原型到 Cloud Build / Cloud Run 的无依赖交付包。

## 亮点设计 vs 局限/坑点

- **值得借鉴的设计**：
  - **为编码 Agent 而非仅为人写的 `AGENTS.md` 导览**：每个 `core/` 配方把阅读顺序、可照搬模块与业务耦合边界写进 `AGENTS.md`，使 `agents-cli` 在 Phase 1 可以让 Claude Code / Antigravity 按图索骥精准移植模式而非全盘照抄。
  - **`HorizonPreloadMemoryTool` 修复 Context Cache 命中率**：通过将动态变化的历史记忆从 `system_instruction` 移至尾部 `contents`，直接避免每轮刷新缓存前缀导致的高昂延迟与费用（`core/python/long-horizon-harness/horizon/agent.py#L195-L199`）。
  - **可导出依赖单源推导**：`export_app.py` 从 `pyproject.toml` 的 `serving` extra 动态生成导出镜像的 `requirements.txt`，根治“本地能跑、容器缺包崩溃”的经典漂移。
- **局限、隐含假设与潜在坑点**：
  - **仓库体积庞大且重度绑定 GCP 服务**：全量历史/资产约 320 MB，未加 `--sparse` 会拉取大量演示图片/视频与多语言目录；垂直插件高度依赖 Vertex AI Vector Search 2.0（如 `SKILL.md#L128` 注明仅 `us-central1` 确认可用，其他区域可能返回 `501`）、BigQuery 与 Cloud Armor。
  - **非 `core/` 目录无 `AGENTS.md` 导览保障**：`contrib/` 质量与结构由社区贡献，虽然受 `manifest.yaml` 校验，但缺少统一架构拆解文档；且 `tools/run_plugin_eval.py` 目前是静态结构与规则质量审计器（检查 RFC 2119 词与断言类型），实际 LLM 端到端评分需结合 `adk` / `agents-cli eval`。

## 可复用的模块或设计模式

- **如何迁移到未来项目**：
  1. **`BasePlugin` 横切护栏架构**：将内容审核、PII 脱敏、预算限制与外泄检测抽离为 Runner 级 `BasePlugin`，对主 Agent 与所有子 Agent 透明生效，不污染业务逻辑。
  2. **闭集 Schema + 可操作 CI 诊断信息（`ci_message`）**：在插件/技能仓库中复用 `validate_manifest.py` / `validate_plugin_scaffolding.py` 的“报错即给修复命令与手册路径”诊断格式，大幅降低外部贡献者往返改错成本。
  3. **Q-MODE 对话式 `SKILL.md` + `design-spec.md` 单一事实源**：开发需配置多项云资源的 Skill 时，可复用 `SKILL.md` 分档问答写入 YAML Frontmatter、再由幂等 Python 脚本读取执行的范式。
- **关联 Pattern**：（由 `synthesizer` 补全）

## Cross-Referenced Specimens

- [A-020 · 用 5 层 20 个 Google 系 Agent 开源仓库武装 Gemini 4 Neon `/swarm`——从裸跑编排到技能、运行时与工具栈（先装 3 个而非 20 个）](https://oumuatown.com/articles/2026-11-28-0xmovez-20-google-agent-repos.md) — 二十款谷歌 Agent 仓实测：先装三件套与五处源码勘误
- [P-023 · Google 5 层 Agent 工程栈、协议互操作与运行时选型模式（Google 5-Layer Agent Stack, Protocols & Runtimes）](https://oumuatown.com/patterns/google-agent-stack-protocols-and-runtimes.md) — 五层谷歌 Agent 栈选型矩阵与全栈源码避坑清单
