mcpField
A
adk-architecture

adk-architecture

github.com/google开发22.0k120 次安装今天更新
代码仓库

关于 adk-architecture

adk-architecture 是介绍 google-adk Agent 与工作流架构的参考技能,帮助开发者在使用或扩展运行时前理解执行机制、上下文、事件、恢复行为和代码组织。

主要功能

  1. 01节点与工作流执行模型
  2. 02Runner 和 NodeRunner 的职责
  3. 03上下文与事件生命周期
  4. 04暂停和恢复行为
  5. 05源码模块索引

适用场景

  1. 01了解工作流如何调度节点
  2. 02追踪一次调用中的状态与事件
  3. 03规划可恢复的人工介入流程
  4. 04定位 ADK 实现模块

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/google/adk-python --skill adk-architecture

安装后在 Claude Code 中输入/adk-architecture确认已加载。

包含的文件

除 SKILL.md 外,安装时一起下载的参考资料和脚本。

references/
api-principles.md
architecture-checkpoint-resume.md
architecture-context.md
architecture-llm-context-orchestration.md
architecture-node-runner.md
architecture-observability.md
architecture-runner-roles.md
architecture-workflow-resumability.md
interface-agent.md
interface-base-agent.md
interface-base-node.md
interface-event.md
interface-runner.md
interface-workflow.md

详细介绍

ADK 架构

运行时是由节点构成的图。BaseNode 是执行单元。 Workflow 是一种沿着声明的边调度其他节点的节点。 NodeRunner 仅执行一个节点。Runner 管理调用和会话。Agent 也是节点——BaseAgent 扩展了 BaseNode。

节点通过每次执行专属的 Context 与父节点通信,并通过生成的 Event 与会话通信。这是两个独立的通道: ctx 将结果向上传递,事件则负责持久化和流式传输。

依赖任何签名之前,请先阅读源代码。这些说明可能会过时;代码不会。以下路径均相对于 src/google/adk/。

选择参考资料

问题参考资料
节点必须实现什么?可以生成什么?有哪些配置字段?BaseNode
图如何调度节点、对动态子节点去重并传播中断?Workflow
调用方如何启动一次调用?Runner
什么是 Agent?我应该调用它的哪些方法?Agent
我在继承 Agent——应该重写什么?BaseAgent
Event 中包含什么?我可以对它的生命周期做哪些假设?Event
节点会从 ctx 读取和写入什么?Context
谁创建子级 Context、为事件添加时间戳、重试并捕获错误?NodeRunner
为什么 Runner、NodeRunner 和 Workflow 是三个独立的组件?Runner 的职责
单个节点如何暂停以等待人工介入并恢复?检查点与恢复
整个工作流如何在暂停后继续运行?is_resumable 会带来什么变化?工作流可恢复性
Span 如何创建?它们包含哪些属性?可观测性
为什么模型看不到原始事件日志?大模型上下文编排
这项更改是否会造成不兼容变更?新的导出内容应放在哪里?API 原则

代码所在位置

概念模块
BaseNode、STARTworkflow/_base_node.py
Workflow、_LoopStateworkflow/_workflow.py
Graph、边编译workflow/_graph.py
NodeRunnerworkflow/_node_runner.py
DynamicNodeScheduler、DynamicNodeState、DynamicNodeRunworkflow/_dynamic_node_scheduler.py
ReplayManager(恢复扫描)workflow/utils/_replay_manager.py
check_interception(重放快进)workflow/utils/_replay_interceptor.py
NodeInterruptedError、NodeTimeoutErrorworkflow/_errors.py
Context、ctx.run_node()agents/context.py
ReadonlyContextagents/readonly_context.py
InvocationContextagents/invocation_context.py
BaseAgent、LlmAgent(别名为 Agent)agents/base_agent.py、agents/llm_agent.py
BaseLlmFlow、SingleFlow、AutoFlow、flows/llm_flows/ 子包(context/、prompt/、tools/、extensions/、core/)flows/llm_flows/
Event、NodeInfoevents/event.py
EventActionsevents/event_actions.py
分支路径(parent.child@1)events/_branch_path.py
节点路径(wf@1/child@2)events/_node_path_builder.py
Runner、InMemoryRunnerrunners.py
LiveRequestQueue、LiveRequestlive/live_request_queue.py
节点 Span、TelemetryContexttelemetry/node_tracing.py
ResumabilityConfigapps/_configs.py

workflow/ 下的所有内容都是以下划线开头的模块。请将这些名称视为内部内容——它们可能会在不提升主版本号的情况下变更,因此其中的更改不一定会造成不兼容变更。

评论

支持 Markdown