google-adk by vladm3105/aidoc-flow-framework
npx skills add https://github.com/vladm3105/aidoc-flow-framework --skill google-adk提供使用 Google Agent Development Kit (ADK) 开发智能体应用和多智能体系统的专业指导。使 AI 助手能够设计智能体、构建工具、编排多智能体工作流、实现记忆/状态管理,并遵循代码优先的开发模式部署基于智能体的应用。
在以下情况调用此技能:
不要将此技能用于:
框架理念:
支持的语言:
google-adk 包广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
adk-go 仓库adk-java 仓库运行时环境:
1. LlmAgent(动态,模型驱动)
用于:
特点:
2. 工作流智能体(确定性,程序化)
顺序智能体:
并行智能体:
循环智能体:
3. 自定义智能体(用户定义逻辑)
用于:
智能体组合:
工具类别:
内置工具:
自定义函数工具:
OpenAPI 工具:
MCP(模型上下文协议)工具:
工具属性:
会话管理:
状态持久化:
上下文缓存:
步骤 1:定义智能体目的
步骤 2:识别所需工具
决策标准:
步骤 3:选择智能体类型
START: 智能体的决策模式是什么?
│
├─> 需要自然语言推理? ─是─> LlmAgent ★
│
├─> 固定的步骤序列?
│ └─> 顺序工作流智能体 ★
│
├─> 独立的并行操作?
│ └─> 并行工作流智能体 ★
│
├─> 需要迭代优化?
│ └─> 循环工作流智能体 ★
│
└─> 自定义编排逻辑?
└─> 自定义智能体 ★
步骤 4:设计多智能体架构(如果需要)
模式:
智能体实现示例:
[参见代码示例:examples/google_adk_agent_implementation.py]
演示的关键智能体模式:
create_weather_assistant() - 具有自定义工具的对话智能体create_data_pipeline() - 有序执行(获取 → 转换 → 保存)create_market_researcher() - 并发工具执行create_content_generator() - 带中断条件的迭代优化create_stateful_session() - 具有历史记录的多轮对话Web UI 测试:
# 启动 API 服务器
adk api_server --port 8000
# 启动 web UI(单独终端)
cd adk-web
npm install
npm start
# 访问:http://localhost:4200
程序化测试:
# 智能体的单元测试
def test_weather_agent():
agent = create_weather_agent()
response = agent.run("纽约天气?")
assert "weather" in response.content.lower()
assert response.success is True
# 使用模拟工具的集成测试
def test_pipeline_agent():
agent = create_pipeline_agent(mock_tools=True)
result = agent.run({"input": "test_data"})
assert result["status"] == "completed"
评估框架:
from google.adk.evaluation import evaluate_agent
# 基于标准的评估
results = evaluate_agent(
agent=my_agent,
test_cases=[
{"input": "2+2 等于多少?", "expected_output": "4"},
{"input": "解释量子计算", "criteria": "mentions_qubits"}
],
evaluator_model="gemini-2.0-flash"
)
print(f"通过率:{results.pass_rate}")
print(f"平均分数:{results.avg_score}")
[参见代码示例:examples/google_adk_tools_example.py]
演示的示例:
calculate_tax() - 带有类型提示的简单工具fetch_user_data() - 异步 API 调用send_email(), delete_user_account() - 需要人工批准send_email_tool() - 电子邮件格式验证和清理fetch_external_data() - 带指数退避的自动重试call_external_api() - 基于装饰器的速率限制fetch_stock_price() - 失败时的优雅降级集成模式:
create_api_agent()]集成模式:
create_mcp_agent()][参见代码示例:examples/google_adk_multi_agent.py]
模式 1:协调器/分发器(复杂度:4)
create_coordinator_system() - 天气 + 金融专家模式 2:顺序管道(复杂度:3)
create_content_pipeline() - 研究 → 撰写 → 编辑模式 3:并行扇出/收集(复杂度:4)
create_market_analysis_system() - 技术 + 基本面 + 情感分析模式 4:层级分解(复杂度:5)
create_project_management_system() - 多级智能体层级模式 5:生成器-评判器循环(复杂度:4)
create_quality_content_system() - 生成 → 评判 → 优化模式 6:人在回路(复杂度:3)
create_account_management_agent() - 删除前确认模式 7:状态管理
StatefulAgent - 带历史记录的内存状态存储模式 8:数据库持久化
save_state(), load_state() - PostgreSQL 支持的持久化[参见代码示例:examples/google_adk_multi_agent.py - 状态管理部分]
基本会话模式:
[参见:examples/google_adk_agent_implementation.py 中的 create_stateful_session()]
自定义状态对象:
[参见:examples/google_adk_multi_agent.py 中的 StatefulAgent 类]
数据库持久化:
[参见:examples/google_adk_multi_agent.py 中的 save_state(), load_state() 函数]
[参见代码示例:examples/google_adk_deployment.py]
部署命令:
pip install google-adk[cli]
adk auth login
adk deploy --agent-file agent.py --agent-name my_agent --project-id my-gcp-project --region us-central1
[参见:create_production_agent() 获取配置示例]
组件:
[参见:examples/google_adk_deployment.py 中的 FastAPI 应用实现、Dockerfile 参考、部署命令]
自托管选项:
[参见:examples/google_adk_deployment.py 中的 docker-compose.yml 参考、部署命令]
| 智能体复杂度 | CPU | 内存 | 并发请求 |
|---|---|---|---|
| 简单 LlmAgent | 1 核心 | 512MB | 10 |
| 工作流智能体 | 2 核心 | 1GB | 20 |
| 多智能体(3-5 个智能体) | 4 核心 | 2GB | 10 |
| 复杂多智能体(>5) | 8 核心 | 4GB | 5 |
[参见代码示例:examples/google_adk_deployment.py - 评估端点]
模式:
[参见:examples/google_adk_deployment.py 中的 evaluate_agent_endpoint()]
模式:
[参见 UserSimulator 示例的文档]
[参见代码示例:examples/google_adk_tools_example.py - 工具设计最佳实践部分]
有效模式:
[参见:examples/google_adk_tools_example.py 末尾的 GOOD 与 BAD 示例]
关键原则:
[参见:examples/google_adk_tools_example.py 末尾的工具设计示例]
策略:
[参见:examples/google_adk_tools_example.py 中的 fetch_stock_price(), fetch_external_data(), send_email_tool()]
实现:
[参见:examples/google_adk_tools_example.py 中的 send_email_tool(), rate_limit() 装饰器]
异步工具:
[参见:examples/google_adk_tools_example.py 中的 fetch_price(), create_portfolio_analyzer()]
当满足以下条件时,智能体已具备生产就绪状态:
功能性:
性能:
安全性:
可观测性:
文档:
当满足以下条件时,工具已具备生产就绪状态:
接口:
可靠性:
测试:
问题:智能体没有调用正确的工具
原因: 工具描述不清晰或模糊
解决方案:
# 不好:模糊的描述
def process(data): """处理数据。""" # 太笼统
def validate_email_format(email: str) -> bool: """检查电子邮件地址是否匹配有效格式(user@domain.com)。
仅使用此工具验证电子邮件语法,而非验证
电子邮件是否存在或可送达。"""
问题:智能体无限循环
原因: 循环智能体中没有终止条件
解决方案:
# 添加 max_iterations 和显式中断条件
agent = LoopAgent( tools=[...], max_iterations=10, # 硬限制 break_condition=lambda result: result.get("completed", False) )
问题:"工具执行失败" 错误
原因: 工具引发未处理的异常
解决方案:
def robust_tool(param: str) -> str:
try:
result = risky_operation(param)
return f"成功:{result}"
except SpecificError as e:
return f"操作失败:{e.message}"
except Exception as e:
logger.error(f"robust_tool 中的意外错误:{e}")
return "临时服务错误,请重试"
问题:智能体响应太慢
原因: 可能并行化时使用了顺序工具调用
解决方案:
# 使用并行智能体或异步工具
agent = ParallelAgent( tools=[tool1, tool2, tool3] # 并发执行 )
问题:超出上下文限制
原因: 对话历史太长
解决方案:
session = Session(
agent=my_agent,
max_history_turns=10, # 限制历史记录
context_window_tokens=30000 # 设置显式限制
)
问题:在 Cloud Run 上部署失败
原因: 缺少依赖项或环境变量
解决方案:
# 确保 requirements.txt 完整
pip freeze > requirements.txt
gcloud run deploy my-agent
--set-env-vars GOOGLE_API_KEY=your_key,AGENT_CONFIG=prod
1. 启用详细日志记录:
import logging
logging.basicConfig(level=logging.DEBUG)
logger = logging.getLogger("google.adk")
logger.setLevel(logging.DEBUG)
2. 独立测试工具:
# 在没有智能体的情况下测试工具
tool = Tool.from_function(my_function)
result = my_function("test_input")
print(f"工具输出:{result}")
3. 使用 web UI 进行交互式调试:
adk api_server --debug
# 在 http://localhost:4200 访问 UI
# 查看工具调用、智能体推理、响应生成
4. 检查智能体执行追踪:
response = agent.run("测试查询", return_trace=True)
print(response.trace) # 显示所有工具调用和决策
| 任务 | 评级 | 描述 |
|---|---|---|
| 带工具的简单 LlmAgent | 2 | 基本对话智能体 |
| 顺序工作流智能体 | 2 | 固定顺序的工具执行 |
| 并行工作流智能体 | 3 | 并发操作 |
| 循环工作流智能体 | 3 | 迭代优化 |
| 自定义智能体 | 3 | 用户定义的编排 |
| 协调器/分发器(2-3 个智能体) | 4 | 多智能体路由 |
| 顺序管道(3+ 个智能体) | 4 | 链式智能体执行 |
| 层级多智能体(>5 个智能体) | 5 | 复杂的嵌套架构 |
| 自定义工具开发 | 2 | Python 函数包装器 |
| OpenAPI 工具集成 | 2 | 从规范自动生成 |
| MCP 工具集成 | 3 | 跨框架工具 |
| 部署到 Agent Engine | 2 | 托管部署 |
| 自托管 Docker 部署 | 3 | 容器编排 |
| 高级评估框架 | 4 | 自定义标准和模拟 |
pip install google-adkn8n 技能api-design-architect 技能cloud-devops-expert 技能版本: 1.0.0 最后更新: 2025-11-13 复杂度评级: 3(中等 - 需要智能体架构知识) 预计学习时间: 10-15 小时以达到熟练
每周安装
103
仓库
GitHub Stars
10
首次出现
Jan 24, 2026
安全审计
安装于
gemini-cli90
codex88
opencode87
github-copilot85
amp77
kimi-cli75
Provide specialized guidance for developing agentic applications and multi-agent systems using Google's Agent Development Kit (ADK). Enable AI assistants to design agents, build tools, orchestrate multi-agent workflows, implement memory/state management, and deploy agent-based applications following code-first development patterns.
Invoke this skill when:
Do NOT use this skill for:
Framework Philosophy:
Supported Languages:
google-adk packageadk-go repositoryadk-java repositoryRuntime Environment:
1. LlmAgent (Dynamic, model-driven)
Use for:
Characteristics:
2. Workflow Agents (Deterministic, programmatic)
Sequential Agent:
Parallel Agent:
Loop Agent:
3. Custom Agents (User-defined logic)
Use for:
Agent Composition:
Tool Categories:
Built-in Tools :
Custom Function Tools :
OpenAPI Tools :
MCP (Model Context Protocol) Tools :
Tool Attributes:
Session Management:
State Persistence:
Context Caching:
Step 1: Define Agent Purpose
Step 2: Identify Required Tools
Decision criteria:
Step 3: Select Agent Type
START: What's the agent's decision pattern?
│
├─> Requires natural language reasoning? ─Yes─> LlmAgent ★
│
├─> Fixed sequence of steps?
│ └─> Sequential Workflow Agent ★
│
├─> Independent parallel operations?
│ └─> Parallel Workflow Agent ★
│
├─> Iterative refinement needed?
│ └─> Loop Workflow Agent ★
│
└─> Custom orchestration logic?
└─> Custom Agent ★
Step 4: Design Multi-Agent Architecture (if needed)
Patterns:
Agent Implementation Examples:
[See Code Examples: examples/google_adk_agent_implementation.py]
Key agent patterns demonstrated:
create_weather_assistant() - Conversational agent with custom toolscreate_data_pipeline() - Ordered execution (fetch → transform → save)create_market_researcher() - Concurrent tool executioncreate_content_generator() - Iterative refinement with break conditionscreate_stateful_session() - Multi-turn conversation with historyWeb UI Testing:
# Start API server
adk api_server --port 8000
# Start web UI (separate terminal)
cd adk-web
npm install
npm start
# Access: http://localhost:4200
Programmatic Testing:
# Unit test for agent
def test_weather_agent():
agent = create_weather_agent()
response = agent.run("Weather in NYC?")
assert "weather" in response.content.lower()
assert response.success is True
# Integration test with mock tools
def test_pipeline_agent():
agent = create_pipeline_agent(mock_tools=True)
result = agent.run({"input": "test_data"})
assert result["status"] == "completed"
Evaluation Framework:
from google.adk.evaluation import evaluate_agent
# Criteria-based evaluation
results = evaluate_agent(
agent=my_agent,
test_cases=[
{"input": "What's 2+2?", "expected_output": "4"},
{"input": "Explain quantum computing", "criteria": "mentions_qubits"}
],
evaluator_model="gemini-2.0-flash"
)
print(f"Pass rate: {results.pass_rate}")
print(f"Average score: {results.avg_score}")
[See Code Examples: examples/google_adk_tools_example.py]
Examples demonstrated:
calculate_tax() - Simple tool with type hintsfetch_user_data() - Asynchronous API callssend_email(), delete_user_account() - Human approval requiredsend_email_tool() - Email format validation and sanitizationfetch_external_data() - Automatic retry with exponential backoffcall_external_api() - Decorator-based rate limitingfetch_stock_price() - Graceful degradation on failuresIntegration Pattern:
create_api_agent() in examples/google_adk_tools_example.py]Integration Pattern:
create_mcp_agent() in examples/google_adk_tools_example.py][See Code Examples: examples/google_adk_multi_agent.py]
Pattern 1: Coordinator/Dispatcher (Complexity: 4)
create_coordinator_system() - Weather + Finance specialistsPattern 2: Sequential Pipeline (Complexity: 3)
create_content_pipeline() - Research → Write → EditPattern 3: Parallel Fan-Out/Gather (Complexity: 4)
create_market_analysis_system() - Technical + Fundamental + Sentiment analysisPattern 4: Hierarchical Decomposition (Complexity: 5)
create_project_management_system() - Multi-level agent hierarchyPattern 5: Generator-Critic Loop (Complexity: 4)
create_quality_content_system() - Generate → Critique → RefinePattern 6: Human-in-the-Loop (HITL) (Complexity: 3)
create_account_management_agent() - Confirmation before deletionPattern 7: State Management
StatefulAgent - In-memory state storage with historyPattern 8: Database Persistence
save_state(), load_state() - PostgreSQL-backed persistence[See Code Examples: examples/google_adk_multi_agent.py - State Management section]
Basic Session Pattern:
[See: create_stateful_session() in examples/google_adk_agent_implementation.py]
Custom State Object:
[See: StatefulAgent class in examples/google_adk_multi_agent.py]
Database Persistence:
[See: save_state(), load_state() functions in examples/google_adk_multi_agent.py]
[See Code Examples: examples/google_adk_deployment.py]
Deployment Commands:
pip install google-adk[cli]
adk auth login
adk deploy --agent-file agent.py --agent-name my_agent --project-id my-gcp-project --region us-central1
[See: create_production_agent() for configuration example]
Components:
[See: FastAPI app implementation, Dockerfile reference, deployment commands in examples/google_adk_deployment.py]
Self-Hosted Options:
[See: docker-compose.yml reference, deployment commands in examples/google_adk_deployment.py]
| Agent Complexity | CPU | RAM | Concurrent Requests |
|---|---|---|---|
| Simple LlmAgent | 1 core | 512MB | 10 |
| Workflow Agent | 2 cores | 1GB | 20 |
| Multi-Agent (3-5 agents) | 4 cores | 2GB | 10 |
| Complex Multi-Agent (>5) | 8 cores | 4GB | 5 |
[See Code Examples: examples/google_adk_deployment.py - Evaluation endpoint]
Pattern:
[See: evaluate_agent_endpoint() in examples/google_adk_deployment.py]
Pattern:
[See documentation for UserSimulator examples]
[See Code Examples: examples/google_adk_tools_example.py - Tool Design Best Practices section]
Effective Patterns:
[See: GOOD vs BAD examples at end of examples/google_adk_tools_example.py]
Key Principles:
[See: Tool design examples at end of examples/google_adk_tools_example.py]
Strategies:
[See: fetch_stock_price(), fetch_external_data(), send_email_tool() in examples/google_adk_tools_example.py]
Implementation:
[See: send_email_tool(), rate_limit() decorator in examples/google_adk_tools_example.py]
Async Tools:
[See: fetch_price(), create_portfolio_analyzer() in examples/google_adk_tools_example.py]
An agent is production-ready when:
Functionality:
Performance:
Safety:
Observability:
Documentation:
A tool is production-ready when:
Interface:
Reliability:
Testing:
Issue: Agent doesn't call the right tool
Cause: Tool description unclear or ambiguous
Resolution:
# BAD: Vague description
def process(data): """Process data.""" # Too generic
def validate_email_format(email: str) -> bool: """Check if email address matches valid format (user@domain.com).
Use this tool ONLY to validate email syntax, not to verify
if email exists or is deliverable."""
Issue: Agent loops indefinitely
Cause: No termination condition in Loop Agent
Resolution:
# Add max_iterations and explicit break condition
agent = LoopAgent( tools=[...], max_iterations=10, # Hard limit break_condition=lambda result: result.get("completed", False) )
Issue: "Tool execution failed" errors
Cause: Tool raises unhandled exception
Resolution:
def robust_tool(param: str) -> str:
try:
result = risky_operation(param)
return f"Success: {result}"
except SpecificError as e:
return f"Operation failed: {e.message}"
except Exception as e:
logger.error(f"Unexpected error in robust_tool: {e}")
return "Temporary service error, please try again"
Issue: Agent response is too slow
Cause: Sequential tool calls when parallelization possible
Resolution:
# Use Parallel Agent or async tools
agent = ParallelAgent( tools=[tool1, tool2, tool3] # Execute concurrently )
Issue: Context limit exceeded
Cause: Conversation history too long
Resolution:
session = Session(
agent=my_agent,
max_history_turns=10, # Limit history
context_window_tokens=30000 # Set explicit limit
)
Issue: Deployment fails on Cloud Run
Cause: Missing dependencies or environment variables
Resolution:
# Ensure requirements.txt is complete
pip freeze > requirements.txt
gcloud run deploy my-agent
--set-env-vars GOOGLE_API_KEY=your_key,AGENT_CONFIG=prod
1. Enable verbose logging:
import logging
logging.basicConfig(level=logging.DEBUG)
logger = logging.getLogger("google.adk")
logger.setLevel(logging.DEBUG)
2. Test tools independently:
# Test tool without agent
tool = Tool.from_function(my_function)
result = my_function("test_input")
print(f"Tool output: {result}")
3. Use web UI for interactive debugging:
adk api_server --debug
# Access UI at http://localhost:4200
# View tool calls, agent reasoning, response generation
4. Inspect agent execution trace:
response = agent.run("test query", return_trace=True)
print(response.trace) # Shows all tool calls and decisions
| Task | Rating | Description |
|---|---|---|
| Simple LlmAgent with tools | 2 | Basic conversational agent |
| Sequential Workflow Agent | 2 | Fixed-order tool execution |
| Parallel Workflow Agent | 3 | Concurrent operations |
| Loop Workflow Agent | 3 | Iterative refinement |
| Custom Agent | 3 | User-defined orchestration |
| Coordinator/Dispatcher (2-3 agents) | 4 | Multi-agent routing |
| Sequential Pipeline (3+ agents) | 4 | Chained agent execution |
| Hierarchical Multi-Agent (>5 agents) | 5 | Complex nested architecture |
| Custom tool development | 2 | Python function wrapper |
pip install google-adkn8n skillapi-design-architect skillcloud-devops-expert skillVersion: 1.0.0 Last Updated: 2025-11-13 Complexity Rating: 3 (Moderate - requires agent architecture knowledge) Estimated Learning Time: 10-15 hours for proficiency
Weekly Installs
103
Repository
GitHub Stars
10
First Seen
Jan 24, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykWarn
Installed on
gemini-cli90
codex88
opencode87
github-copilot85
amp77
kimi-cli75
agent-browser 浏览器自动化工具 - Vercel Labs 命令行网页操作与测试
157,400 周安装
AI驱动规模化个性化销售开场白生成器 - 提升8-15%回复率,节省90%研究时间
102 周安装
Obsidian Bases 技能详解:创建编辑 .base 文件,实现动态视图、过滤器与公式配置
102 周安装
GitHub CLI 完整使用指南:仓库管理、PR、议题操作命令大全
102 周安装
应用安全专家技能:OWASP Top 10 2025、安全编码、DevSecOps 与漏洞管理指南
102 周安装
Twitter 搜索与分析工具:使用高级语法获取1000条推文并生成专业洞察报告
102 周安装
C++20专家技能:现代C++编程、性能优化与系统级开发指南
103 周安装
| OpenAPI tool integration | 2 | Auto-generated from spec |
| MCP tool integration | 3 | Cross-framework tools |
| Deployment to Agent Engine | 2 | Managed deployment |
| Self-hosted Docker deployment | 3 | Container orchestration |
| Advanced evaluation framework | 4 | Custom criteria and simulation |