Files
nexus/wiki/concepts/Generator.md
2026-04-27 08:02:55 +08:00

43 lines
1.5 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
title: "Generator 模式"
type: concept
tags: [Agent, Skill, Design Pattern, ADK]
sources: [google-5个agent-skill设计模式-2026-03-19]
last_updated: 2026-05-15
---
## Overview
Generator 是 Google ADK 发布的 5 种 Agent Skill 设计模式之一,通过"填空"流程从模板生成结构化输出,强制保证输出格式的一致性。
## Mechanism
- 利用两个可选目录:`assets/` 存放输出模板,`references/` 存放样式指南
- SKILL.md 扮演项目经理的角色
- 指示 Agent 加载模板、读取样式指南、向用户询问缺失的变量、然后填充文档
## Use Cases
- 生成统一的 API 文档
- 标准化 commit 信息
- 脚手架项目结构生成
- 任何需要保持格式一致的结构化输出
## Implementation
```
assets/output-template.md: 输出模板
references/style-guide.md: 样式指南
SKILL.md: 项目经理角色,引导 Agent 填充模板
→ 向用户询问缺失变量 → 填充文档 → 输出
```
## Key Insight
> 如果 Tool Wrapper 是应用知识Generator 则是强制一致的输出格式。很多 agent 每次运行生成的文档结构都不一样Generator 完美解决这个问题。
## Related Concepts
- [[ToolWrapper]]应用知识Generator 生成结构,两者互补
- [[Inversion]]:可以在开头依赖 Inversion 来收集必要的变量
- [[Reviewer]]:可以审查 Generator 生成的输出
- [[渐进式披露]]:类似的按需加载思想
## Connections
- [[Google5个AgentSkill设计模式]] ← part_of ← [[Generator]]
- [[ADK]] ← published_by ← [[Generator]]