Communitygithub.com

Google ADK Python 技能

使用 Google ADK Python(Agent Development Kit)构建 AI 智能体。适用于多智能体系统、工作流智能体(顺序/并行/循环)、Vertex AI 部署、工具集成和人工参与流程。

Google ADK Python 技能 是什么?

本技能详细介绍了 Google 的 Agent Development Kit (ADK) Python,这是一个开源、代码优先的工具包,用于构建、评估和部署 AI 智能体。它支持多种智能体类型,包括由 LLM 驱动的 LlmAgent,能够进行动态路由和自适应行为;以及面向可预测管道的结构化工作流智能体(SequentialAgent、ParallelAgent、LoopAgent)。该技能涵盖了核心概念,如工具生态系统(内置 Google 搜索、代码执行、自定义 Python 函数和 OpenAPI 集成)、多智能体架构(分层协调与任务委派)以及人工参与流程(工具执行审批)。此外,还提供了单智能体、多智能体系统、自定义工具创建以及顺序/并行工作流的实现模式,并支持部署到 Cloud Run、Vertex AI Agent Engine 或自定义基础设施。适用于各种用例,包括研究助手、代码助手、客户支持、内容创建和数据自动化。

兼容平台✓Claude Code~Codex CLI~Cursor✓Gemini CLI
npx skills add https://github.com/majiayu000/claude-skill-registry-data/tree/HEAD/agent/google-adk-python-hoanghd218-landing-page-ai-kien-2

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

Google ADK Python 技能 是做什么的?

您是 Google Agent Development Kit (ADK) Python 的专家级指南——这是一个开源、代码优先的工具包,用于构建、评估和部署 AI 智能体。

何时使用此技能

当用户需要以下功能时,使用此技能:

  • 构建具有工具集成和编排能力的 AI 智能体
  • 创建具有分层协调功能的多智能体系统
  • 实现面向可预测管道的工作流智能体(顺序、并行、循环)
  • 将 LLM 驱动的智能体与 Google 搜索、代码执行或自定义工具集成
  • 将智能体部署到 Vertex AI Agent Engine、Cloud Run 或自定义基础设施
  • 系统化地评估和测试智能体性能
  • 实现工具执行的人工审批流程

核心概念

智能体类型

LlmAgent:由 LLM 驱动的智能体,能够进行动态路由和自适应行为

  • 使用名称、模型、指令、描述和工具进行定义
  • 支持子智能体进行任务委派和协调
  • 基于上下文进行智能决策

工作流智能体:结构化、可预测的编排模式

  • SequentialAgent:按定义的顺序执行多个智能体
  • ParallelAgent:并发运行多个智能体
  • LoopAgent:使用迭代逻辑重复执行

BaseAgent:自定义智能体实现的基础类

关键组件

工具生态系统:

  • 预构建工具(google_search、code_execution)
  • 作为工具的自定义 Python 函数
  • OpenAPI 规范集成
  • 用于人工审批的工具确认流程

多智能体架构:

  • 分层智能体组合
  • 面向特定领域的专用智能体
  • 用于任务委派的协调器智能体

安装

# 稳定版(推荐)
pip install google-adk

# 开发版(最新功能)
pip install git+https://github.com/google/adk-python.git@main

实现模式

带工具的单智能体

from google.adk.agents import LlmAgent
from google.adk.tools import google_search

agent = LlmAgent(
    name="search_assistant",
    model="gemini-2.5-flash",
    instruction="你是一个乐于助人的助手,负责在网络上搜索信息。",
    description="网络查询的搜索助手",
    tools=[google_search]
)

多智能体系统

from google.adk.agents import LlmAgent

# 专用智能体
researcher = LlmAgent(
    name="Researcher",
    model="gemini-2.5-flash",
    instruction="使用网络搜索彻底研究主题。",
    tools=[google_search]
)

writer = LlmAgent(
    name="Writer",
    model="gemini-2.5-flash",
    instruction="基于研究结果编写清晰、引人入胜的内容。",
)

# 协调器智能体
coordinator = LlmAgent(
    name="Coordinator",
    model="gemini-2.5-flash",
    instruction="将任务委派给研究员和写作智能体。",
    sub_agents=[researcher, writer]
)

自定义工具创建

from google.adk.tools import Tool

def calculate_sum(a: int, b: int) -> int:
    """计算两个数字的和。"""
    return a + b

# 将函数转换为工具
sum_tool = Tool.from_function(calculate_sum)

agent = LlmAgent(
    name="calculator",
    model="gemini-2.5-flash",
    tools=[sum_tool]
)

顺序工作流

from google.adk.agents import SequentialAgent

workflow = SequentialAgent(
    name="research_workflow",
    agents=[researcher, summarizer, writer]
)

并行工作流

from google.adk.agents import ParallelAgent

parallel_research = ParallelAgent(
    name="parallel_research",
    agents=[web_researcher, paper_researcher, expert_researcher]
)

人工参与流程

from google.adk.tools import google_search

# 需要确认的工具
agent = LlmAgent(
    name="careful_searcher",
    model="gemini-2.5-flash",
    tools=[google_search],
    tool_confirmation=True  # 执行前需要批准
)

部署选项

Cloud Run 部署

# 容器化智能体
docker build -t my-agent .

# 部署到 Cloud Run
gcloud run deploy my-agent --image my-agent

Vertex AI Agent Engine

# 部署到 Vertex AI 以获得可扩展的智能体托管
# 与 Google Cloud 的托管基础设施集成

自定义基础设施

# 在本地或自定义服务器上运行智能体
# 完全控制部署环境

模型支持

针对 Gemini 优化:

  • gemini-2.5-flash
  • gemini-2.5-pro
  • gemini-1.5-flash
  • gemini-1.5-pro

模型无关:虽然针对 Gemini 进行了优化,但 ADK 通过标准 API 支持其他 LLM 提供商。

最佳实践

  1. 代码优先理念:使用 Python 定义智能体,以实现版本控制、测试和灵活性
  2. 模块化设计:创建面向特定领域的专用智能体,组合成系统
  3. 工具集成:利用预构建工具,通过自定义函数进行扩展
  4. 评估:针对测试用例系统化地测试智能体
  5. 安全性:为敏感操作实现确认流程
  6. 分层结构:对于复杂的多智能体工作流,使用协调器智能体
  7. 工作流选择:选择工作流智能体用于可预测的管道,选择 LLM 智能体用于动态路由

常见用例

  • 研究助手:网络搜索 + 摘要 + 报告生成
  • 代码助手:代码执行 + 文档 + 调试
  • 客户支持:查询路由 + 知识库 + 升级处理
  • 内容创作:研究 + 写作 + 编辑流水线
  • 数据分析:数据获取 + 处理 + 可视化
  • 任务自动化:具有条件逻辑的多步骤工作流

开发 UI

ADK 内置界面,支持:

  • 交互式测试智能体行为
  • 调试工具调用和响应
  • 评估智能体性能
  • 迭代智能体设计

资源

实现工作流

实施基于 ADK 的智能体时:

  1. 定义需求:确定智能体能力和所需工具
  2. 选择架构:单智能体、多智能体或基于工作流
  3. 选择工具:预构建、自定义函数或 OpenAPI 集成
  4. 实现智能体:使用指令和工具创建智能体定义
  5. 本地测试:使用开发 UI 进行迭代
  6. 添加评估:创建用于系统化验证的测试用例
  7. 部署:选择 Cloud Run、Vertex AI 或自定义基础设施
  8. 监控:跟踪智能体性能并进行迭代

请记住:ADK 将智能体开发视为传统软件工程——使用版本控制、编写测试,并遵循工程最佳实践。

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

majiayu000/claude-skill-registry-data

Edit existing BMAD agents while maintaining compliance

majiayu000/claude-skill-registry-data

Edit existing BMAD agents while maintaining compliance

majiayu000/claude-skill-registry-data

Edit existing BMAD modules while maintaining coherence

majiayu000/claude-skill-registry-data

Edit existing BMAD modules while maintaining coherence

majiayu000/claude-skill-registry-data

Analyzes current state and user query to answer BMad questions or recommend the next workflow or agent. Use when user says what should I do next, what do I do now, or asks a question about BMad

majiayu000/claude-skill-registry-data

Build AI agents with Google ADK Python (Agent Development Kit). Use for multi-agent systems, workflow agents (sequential/parallel/loop), Vertex AI deployment, tool integration, human-in-the-loop.

majiayu000/claude-skill-registry-data

Portfolio allocation and rebalancing optimizer. Manages asset allocation across stocks/cash/bonds, performs periodic rebalancing, and ensures diversification according to market regime and risk tolerance.

majiayu000/claude-skill-registry-data

Create a hilarious and ultra-realistic video of an anthropomorphic animal acting like a human vlogger in a real-world setting.

majiayu000/claude-skill-registry-data

Speech-to-text transcription and translation via OpenAI Audio API -- models, response formats, timestamps, prompting, streaming, chunking, and diarization

majiayu000/claude-skill-registry-data

This skill should be used when the user asks about libraries, frameworks, API references, or needs code examples. Activates for setup questions, code generation involving libraries, or mentions of specific frameworks like React, Vue, Next.js, Prisma, Supabase, etc.

majiayu000/claude-skill-registry-data

小省导购员数字人带货版即梦视频提示词生成系统,基于四大智能体协同(提示词生成师、质量管控师、知识库运维师、跨环节适配师),按照"主体+运动+场景+(镜头语言+光影+氛围)"公式输出中英文双版提示词,适配5s短视频。确保人物一致性、视觉连贯性、情绪连贯性,支持知识库智能复用和跨工具适配(Suno音乐、AI绘画),为数字人带货视频提供高质量提示词生成服务。

majiayu000/claude-skill-registry-data

Upload and manage files using Google Gemini File API via scripts/. Use for uploading images, audio, video, PDFs, and other files for use with Gemini models. Supports file upload, status checking, and file management. Triggers on "upload file", "file API", "upload image", "upload PDF", "upload video", "file management".

majiayu000/claude-skill-registry-data

Analyze images/audio/video with Gemini API (better vision than Claude). Generate images (Imagen 4), videos (Veo 3). Use for vision analysis, transcription, OCR, design extraction, multimodal AI.

majiayu000/claude-skill-registry-data

Analyze images/audio/video with Gemini API (better vision than Claude). Generate images (Imagen 4), videos (Veo 3). Use for vision analysis, transcription, OCR, design extraction, multimodal AI.

majiayu000/claude-skill-registry-data

Skill for discovering and researching autonomous AI agents, tools, and ecosystems using the AgentFolio directory.

majiayu000/claude-skill-registry-data

Conduct domain and industry research. Use when the user says "lets create a research report on [domain or industry]

majiayu000/claude-skill-registry-data

Conduct market research on competition and customers. Use when the user says "create a market research report about [business idea]".

majiayu000/claude-skill-registry-data

Conduct technical research on technologies and architecture. Use when the user says "create a technical research report on [topic]".

majiayu000/claude-skill-registry-data

Understand an existing codebase through systematic exploration

majiayu000/claude-skill-registry-data

Builds, edit or validate Agent Skill through conversational discovery. Use when the user requests to "Create an Agent", "Optimize an Agent" or "Edit an Agent".

相关技能