Google ADK (Agent Development Kit)

一句话定位

Google ADK(Python 包 google-adk,v2.4.0)是 Google 官方开源的 code-first agent 框架,README 自述为 “open-source, code-first Python toolkit for building, evaluating, and deploying sophisticated AI agents”。它的两个决定性特征:一是同一仓库并存两套执行范式——经典 flow 范式(flows/llm_flows/base_llm_flow.py 的单 agent 多轮 while True 循环)与 ADK 2.0 workflow 范式(workflow/_dynamic_node_scheduler.py 的 DAG 图编排、动态节点、可暂停/可恢复的 human-in-the-loop),Runner 优先走后者;二是模型策略两面下注——对 Gemini/Vertex 做深度协同(context caching、thinking planner、native code execution、grounding、Live 双向流、Memory Bank、多档托管代码沙箱都有 Google 侧实现),同时经 LiteLLM/Anthropic 适配保持模型无关。相比 langgraph/crewai 同类框架,ADK 更”平台化”,图编排范式则更接近 langgraph。

核心架构总览(目录结构关键路径 + 引用的 commit)

分析基于 commit 61ba59a23f06d78bbd5ed49bac918787e2739066(2026-07-10),版本 2.4.0src/google/adk/version.py)。源码根为 src/google/adk/,重点子包:

  • runners.py(2301 行)— Runner 顶层执行引擎:service 装配、run_async 主循环、DynamicNodeScheduler 驱动、append_event 落盘。
  • agents/BaseAgent(=BaseNode)/LlmAgent/Loop|Sequential|ParallelAgentContext/InvocationContext
  • flows/llm_flows/ — 单 agent 的 LLM 交互循环:request/response processor 管线、tool dispatch、agent transfer、compaction。
  • workflow/ADK 2.0 图编排引擎(_workflow.py 编译 DAG + _dynamic_node_scheduler.py 调度)。
  • tools/ — 工具体系(BaseTool/FunctionTool、MCP、bigquery/computer_use/bash/agent_tool 等大量内建工具)。
  • sessions/ — 会话持久化(in-memory / sqlite / database(SQLAlchemy) / vertex_ai)。
  • memory/ — 长期记忆服务(in-memory / vertex_ai_memory_bank / vertex_ai_rag)。
  • apps/ — App 容器 + 事件压缩(compaction/summarizer)。
  • plugins/ — 全局横切回调插件体系(plugin_manager + 内建插件)。
  • skills/兼容 Anthropic Agent Skills 规范的技能系统(SKILL.md L1/L2/L3 渐进加载)。
  • optimization/ — 自进化:GEPA / SimplePromptOptimizer 等 eval 驱动的 prompt/agent 优化器。
  • evaluation/ — eval 框架(trajectory / final-response / hallucination / rubric / llm-as-judge)。
  • code_executors/ — 代码执行沙箱(unsafe_local / container(docker) / gke / vertex_ai / agent_engine_sandbox / built-in Gemini)。
  • auth/ — 凭证/OAuth 体系(credential_manager、auth_handler、exchanger、refresher)。
  • telemetry/ — OpenTelemetry tracing + GenAI semconv。
  • planners/models/a2a/cli/artifacts/events/integrations/labs/ 等。

架构演进要点base_llm_flow.py:1307-1322 的注释确认——经典递归 transfer 路径在 ADK 2.0 下被 _llm_agent_wrapper.py 拦截绕过,改由 Workflow 调度;Runner 走 DynamicNodeScheduler 的入口在 runners.py:545,573,658,680。也就是说 flow 范式仍是单 agent 内层循环的实现,但跨 agent 的编排已上移到图调度层。

Agent Loop(主循环 / 何时继续何时停)

两层循环。

内层(单 agent LLM 循环)flows/llm_flows/base_llm_flow.py:918 run_async

while True:
    last_event = None
    async for event in self._run_one_step_async(ctx):   # 一步 = 一次 LLM 调用
        last_event = event; yield event
    if not last_event or last_event.is_final_response() or last_event.partial:
        break
  • 一步的定义_run_one_step_async(:933)= preprocess(processor 管线)→ _call_llm_async 调一次 LLM → postprocess → 若返回含 function_calls 则执行工具、把 function response 作为下一步输入喂回,让模型消费工具结果后继续循环。
  • 停止条件last_event.is_final_response()(一条没有未决函数调用的 model 回复即终止)或空/partial 事件跳出。此外 end_invocation 标志可提前中断(需要 auth/confirmation 时,:946/1055/1284)。
  • LoopAgent 的停止:agents/loop_agent.py:36 max_iterations 达上限,或子 agent 发出 event.actions.escalate(:56-77)。

外层(Runner / Workflow)runners.py:run_async(约 :1005)装配 InvocationContext 后交给 DynamicNodeScheduler(runners.py:545-640)。ADK 2.0 里每个 agent 是图节点(BaseAgent(BaseNode)base_agent.py:93),Workflow 调度”就绪”节点(前驱完成)为 asyncio task,支持并行分支、动态 ctx.run_node() 派生子节点,以及从 session.events 重建状态后恢复(rehydration,见 docs/guides/workflow/)。

记忆与上下文管理(压缩、长期记忆、会话持久化)

三层分离,边界清晰。

a) 短期 = Session(会话持久化)sessions/session.py:28 Session(state + events 列表)。BaseSessionService 有 in-memory / sqlite / database(SQLAlchemy) / vertex_ai 四实现。State 用作用域前缀:APP_PREFIX="app:" / USER_PREFIX="user:" / TEMP_PREFIX="temp:"sessions/state.py:64-66)——temp: 不持久化,app:/user: 跨会话共享。事件经 session_service.append_event 落盘(runners.py:640,812,1210)。

b) 上下文压缩(compaction)flows/llm_flows/compaction.py 的 CompactionRequestProcessor 在 contents processor 之前跑(single_flow.py:47-49),核心逻辑在 apps/compaction.py

  • token 阈值触发_run_compaction_for_token_threshold_config(:371)——当最近 prompt_token_count >= config.token_threshold(:389-394)时触发。
  • LlmEventSummarizerapps/llm_event_summarizer.py,模型 = agent.canonical_model)把旧事件 LLM 摘要成 compaction_event。
  • 支持滑窗模式(overlap_size_has_sliding_window_config :215)与 event_retention_size(保留最近 N 事件不压缩)+ rolling-summary 种子(:240)。
  • 有”自包含前缀”安全切分(_longest_self_contained_prefix :311 / _safe_token_compaction_split_index :335),避免把 function_call 与其 response 拆开。

c) 长期记忆(memory service)memory/base_memory_service.py:44 BaseMemoryService,抽象方法 add_session_to_memory / search_memory(+ add_events_to_memory / add_memory)。实现:in_memory_memory_servicevertex_ai_memory_bank_service(Vertex Memory Bank)、vertex_ai_rag_memory_service(RAG)。

  • 写入:context.py:883 add_session_to_memory / :907 add_events_to_memory / :937 add_memory(工具或回调里主动写)。
  • 读取:context.py:964 search_memory;两个自动工具——tools/preload_memory_tool.py(每次 LLM 请求前用 user query 检索,把结果作为 <PAST_CONVERSATIONS> 注入 system instruction,:83-89,模型无需显式调用)与 tools/load_memory_tool.py(模型显式调用式检索)。

工具体系(定义/调用协议/注册/权限)

  • 定义tools/base_tool.py:51 BaseTool(ABC)。核心方法 _get_declaration()types.FunctionDeclaration(OpenAPI/Gemini schema)、run_async(args, tool_context)process_llm_request()(默认 llm_request.append_tools([self]) 注册进请求,:169)。字段含 is_long_running(LRO:先返回 id 后完成)、_defers_response(内部,延迟 FR)、response_scheduling(Live API 异步 SILENT/WHEN_IDLE/INTERRUPT)。
  • tools/function_tool.py:42 FunctionTool 把 Python 函数自动转工具:_automatic_function_calling_util.py + _function_parameter_parse_util.py 从签名/type hints 生成 schema。
  • 注册:agent 声明 tools=[...],preprocess 阶段 _process_agent_toolsbase_llm_flow.py:421,1059)对每个 tool/toolset 调 process_llm_request 收集声明到 llm_request.tools_dict。也支持 BaseToolset(动态返回工具列表,含 MCP)。
  • 调用协议(dispatch)flows/llm_flows/functions.py:422 handle_function_call_list_async——并行执行,每个 function call 一个 asyncio task 走 asyncio.gather(:442-459),完成后 merge_parallel_function_response_events(:475)合并成一个 FR event。单个执行 _execute_single_function_call_async(:492):before_tool_callback(plugin→canonical,:568-584)→ __call_tool_async(:589)→ 异常走 on_tool_error_callback(:593)→ after_tool_callback。sync 工具丢线程池执行(_call_tool_in_thread_pool :159)。
  • 大量内建工具:MCP(_remote_mcp_server.py)、bash_tool.pycomputer_use/bigquery/bigtable/google_search_toolagent_tool.py(agent-as-tool)、crewai_tool.py、langchain 集成、openapi_tool/apihub_tool/ 等。
  • 权限:三段 callback(before/after/on_error)+ confirmation gate + auth,详见”安全与权限”章。

Prompt 设计(系统提示结构、动态组装)

系统提示通过 request processor 管线逐段拼装,非单一大模板。顺序定义在 single_flow.py:41-68basic → auth → request_confirmation → instructions → identity → compaction → contents → context_cache → interactions → nl_planning → code_execution → output_schema

  • instructionsflows/llm_flows/instructions.py)三来源:agent.instruction(动态,可为 InstructionProvider 回调)、agent.static_instruction(放前面,利于 context caching)、root_agent.global_instruction(已废弃,改用 GlobalInstructionPlugin)。关键设计:若设了 static_instruction,则动态 instruction 改注入到 user content 而非 system instructioninstructions.py:107-119llm_agent.py:259-263,292-303)——目的是缓存静态前缀。
  • state 注入instructions_utils.inject_session_state 把 instruction 里的 {var} 占位符用 session state 填充(instructions.py:55-58),除非 bypass_state_injection
  • identityidentity.py)注入 agent name/description。
  • contentscontents.py,1282 行)把 session events 转成模型对话历史;include_contents='none' 可禁历史(llm_agent.py:371)。
  • agent_transfer 与 skills 也各自 append 系统提示段(见下两章)。

Router / 编排(任务分解、多 agent、子 agent)

两条编排路径。

a) LLM 驱动的 agent transfer(软路由)flows/llm_flows/agent_transfer.py。AutoFlow(auto_flow.py)在 SingleFlow 基础上加 agent_transfer processor,把可转移目标(子 agent + 父 agent + peer,_get_transfer_targets :159)连同 description 拼成系统提示(:109-126,“If another agent is better … call transfer_to_agent”),并注册 TransferToAgentTool。模型调用后 event.actions.transfer_to_agent 被消费,切到目标 agent(base_llm_flow.py:1315-1322 _get_agent_to_run)。方向规则:parent↔sub、sub→peer(受 disallow_transfer_to_parent/peers 控制);mode in ('task','single_turn') 的 agent 不参与 transfer(:147,180)。flow 选择:无子 agent 且禁转移用 SingleFlow,否则 AutoFlow(llm_agent.py:843-851)。

b) 代码/图驱动编排(结构化)

  • 工作流 agentSequentialAgent / ParallelAgent / LoopAgentagents/)——固定顺序/并行/循环子 agent。
  • ADK 2.0 Workflow(图)workflow/_workflow.pyedges 编译为 DAG,_dynamic_node_scheduler.py 调度就绪节点、并行 asyncio task、动态 ctx.run_node() 派生子节点(generator-evaluator 循环、动态 fan-out),支持条件路由(RouteValue)与 human-in-the-loop 暂停/恢复。
  • agent-as-tooltools/agent_tool.py 把子 agent 包成工具调用(与 transfer 的差别:调用后返回结果、控制权回到调用方,不发生控制权转移)。

Skill / 插件体系

两个不同概念,仓库里都实现了。

a) Skills(skills/,实验性):**兼容 Anthropic Agent Skills 规范(agentskills.io)**的渐进式加载。skills/models.py 分 L1/L2/L3:Frontmatter(:38,含 name/description/license/allowed_tools(空格分隔的预批准工具,指向 agentskills.io spec)/metadata,metadata 里有 ADK 扩展字段 adk_inject_stateadk_additional_tools)、L2 = SKILL.md 正文、L3 = Resources(:149,references markdown / assets / scripts)。skill_registry.py:26 SkillRegistry(ABC:get_skill / search_skills / search_tool_description)。skills/prompt.py:format_skills_as_xml 把可用技能列成 <available_skills> XML 注入提示,模型据 description 决定是否加载(progressive disclosure)。README 明说支持 “dynamic loading of agent instructions, resources, and scripts … extended with new capabilities at runtime”。

b) Plugins(plugins/:全局横切回调,与 Skills 是完全不同的机制。base_plugin.py:105 BasePlugin 暴露约 15 个 hook:on_user_message / before_run / after_run / on_event / before_agent / after_agent / before_model / after_model / on_model_error / before_tool / after_tool / on_tool_error / on_agent_error / on_run_error / closeplugin_manager.py:PluginManager 顺序执行所有已注册插件的对应回调,任一返回非空即短路覆盖(base_llm_flow.py:228-235 before_model;functions.py:568 before_tool)。内建插件:logging_plugindebug_logging_pluginauto_tracing_plugincontext_filter_pluginglobal_instruction_pluginreflect_retry_tool_pluginsave_files_as_artifacts_pluginmultimodal_tool_results_pluginbigquery_agent_analytics_plugin

自进化能力(自我改进 / 学习型记忆 / eval 驱动纠错)

有实打实的 eval 驱动 prompt/agent 自动优化optimization/),但不做参数训练

  • agent_optimizer.py:28 AgentOptimizer(ABC,optimize(initial_agent, ...)→带分数的优化后 agent)。
  • gepa_root_agent_prompt_optimizer.py:接入外部 GEPA 框架(reflective prompt evolution,from gepa.core.adapter import GEPAAdapter,:95)。_AgentGEPAAdapter 实现 evaluate(:113,跑 agent 打分)+ make_reflective_dataset(:161,把失败轨迹喂给反思)。config 有 reflection_minibatch_size(:70)。用一个 optimizer_model(:204)反思并进化 root agent 的 prompt,pareto 式挑选。
  • simple_prompt_optimizer.py:迭代式——_generate_candidate_prompt(:96)生成候选 → _score_agent_on_batch(:125)在 eval 批上打分 → _run_optimization_iterations(:140)→ _run_final_validation(:183)。配套 local_eval_sampler.py / sampler.py 采样轨迹。
  • 运行时自纠错reflect_retry_tool_pluginplugins/)在工具失败时反思后重试。
  • 学习型长期记忆:Memory Bank / RAG(见”记忆”章)——session 可反哺记忆供后续检索,但这是检索型记忆,非参数更新。

可观测性(日志 / trace 格式)

  • OpenTelemetrytelemetry/tracing.py),用标准 GenAI semantic conventionsopentelemetry.semconv._incubating.attributes.gen_ai_attributes,import 见 :41-53,如 GEN_AI_AGENT_NAME / GEN_AI_OPERATION_NAME / GEN_AI_REQUEST_MODEL / GEN_AI_TOOL_NAME / GEN_AI_TOOL_CALL_ID / GEN_AI_RESPONSE_FINISH_REASONS / USER_ID / ERROR_TYPE)。span 埋点函数:trace_call_llm / trace_send_data / trace_tool_call / trace_merged_tool_callsfunctions.py:483)/ trace_agent_invocationtracing.py:117)。
  • span 分 stable / experimental semconv(_stable_semconv.py / _experimental_semconv.py),有 schema version(_schema_version.py)。
  • 隐私:env 开关可禁用含 PII 的 span 属性(tracing.py:79-80)。
  • 导出:sqlite_span_exporter.py(本地 sqlite)、google_cloud.py(Cloud Trace)、_agent_engine.py
  • auto_tracing_plugin 自动埋点;logging_plugin / debug_logging_plugin 结构化日志;每模块 logging.getLogger('google_adk.' + __name__)

安全与权限(审批门、密钥管理)

a) 工具审批门(human-in-the-loop confirmation)

  • tools/function_tool.py:53 require_confirmation(bool 或 callable,运行时判定 :245-252)。
  • 工具内可主动 tool_context.request_confirmation(hint=, payload=)context.py:847,把 ToolConfirmation 记到 event_actions.requested_tool_confirmations[function_call_id])。
  • functions.py:360 generate_request_confirmation_event 生成一个 adk_request_confirmation 长运行函数调用事件抛给客户端,中断 invocation 等人确认(base_llm_flow.py:1286-1290)。
  • 恢复:flows/llm_flows/request_confirmation.py 的 processor 解析用户回传的 confirmed/payload(_resolve_confirmation_targets :24),确认后才真正执行工具。
  • ToolConfirmationtools/tool_confirmation.py)字段:hint / confirmed / payload,experimental feature gate。

b) 密钥/凭证管理(auth/

  • credential_manager.py CredentialManagerauth_handler.py AuthHandlerauth_provider_registry.pyexchanger/(token 交换)、refresher/(刷新)、oauth2_credential_util.py / oauth2_discovery.py
  • 工具需凭证时 tool_context.request_credential(auth_config)context.py:819,记入 requested_auth_configs[function_call_id] 并生成 auth request)→ functions.py:334 generate_auth_event 抛出 auth 事件 + 中断 invocation。已有凭证走 save_credential / load_credentialcontext.py:773/785)。
  • Toolset 级预授权:base_llm_flow.py:125 _resolve_toolset_auth(列工具前先解析 toolset 凭证,缺则抛 auth 请求中断,凭证存 invocation_context.credential_by_key 防泄漏/竞态 :174-177)。
  • credential_service/(session/内存凭证存储)。

沙箱与执行隔离

code_executors/base_code_executor.py:28 BaseCodeExecutor(字段 stateful :56、optimize_data_file :48、error_retry_attempts=2 :59——代码报错自动重试)。五档隔离强度递增 + 一个模型侧执行:

  • unsafe_local_code_executor.pyexec(code, globals_, globals_)(:45)——无隔离,同进程执行,仅测试/信任场景。
  • container_code_executor.pyimport docker,DockerClient 起容器(默认镜像 adk-code-executor:latest :34)——进程/容器级隔离。
  • gke_code_executor.py:GKE,from k8s_agent_sandbox import SandboxClient,两模式 ‘job’ / ‘sandbox’(:48-51)——K8s pod 级隔离。
  • vertex_ai_code_executor.py:Vertex Code Interpreter Extension(Google 托管沙箱)。
  • agent_engine_sandbox_code_executor.py:Agent Engine Code Execution Sandbox(托管)。
  • built_in_code_executor.py:直接用 Gemini 原生 code execution(模型侧执行)。
  • 代码执行经 _code_execution request/response processor 接入 flow(single_flow.py:63),mutates contents 处理数据文件。

与模型的协同设计

  • 多 provider 适配models/):base_llm.py:32 BaseLlmgenerate_content_async 流式 + connect() 双向 Live 连接)。实现:google_llm.py(Gemini)、anthropic_llm.pylite_llm.py(LiteLLM→百家模型)、gemma_llm.pyapigee_llm.pyregistry.py 按模型名解析类。
  • Gemini 深度协同
    • context cachinggemini_context_cache_manager.py + context_cache_processor(single_flow.py:52)+ static_instruction 前置设计(见”Prompt”章),显式利用 Gemini 隐式/显式缓存。
    • thinking/plannerplanners/built_in_planner.py 直接配 Gemini thinking_configllm_agent.py:338 注明 planner 优先于 agent 的 thinking_config)。
    • native code execution(built_in_code_executor)、google_search / groundinggoogle_search_tool,grounding_metadata 特判 base_llm_flow.py:273-292)、Live/双向流gemini_llm_connection.py、audio 转写/缓存 audio_cache_manager.py)、GoogleLLMVariant(Gemini API vs Vertex 变体,工具 schema 生成分叉 base_tool.py:172)。
    • Interactions API(interactions_processor single_flow.py:56 + models/interactions_utils.py):有状态多轮 previous_interaction_id
  • PlanReActPlannerplanners/plan_re_act_planner.py):为不带原生 thinking 的模型提供 ReAct 式 plan 提示。
  • 工具声明按 API 变体生成不同 schema(_gemini_schema_util.py)。

轨迹利用(session/trajectory 是否反哺训练/评测)

主要用于评测 + prompt 优化,非参数训练。

  • 评测(evaluation/)是一等能力trajectory_evaluator.py:38 TrajectoryEvaluatortool-use accuracy 对比实际 vs 期望工具调用序列(_calculate_tool_use_accuracy :137)。另有 multi_turn_trajectory_quality_evaluator.pyrubric_based_multi_turn_trajectory_evaluator.pymulti_turn_tool_use_quality_evaluator.pyfinal_response_match_v1/v2hallucinations_v1llm_as_judge.pycustom_metric_evaluator.py。eval set 管理 eval_set.py / eval_case.py,本地/GCS/Vertex 存储;agent_evaluator.py 是入口。
  • 轨迹反哺优化:session 轨迹经 local_eval_sampler.py 采样喂给 optimization/ 的 GEPA/SimplePromptOptimizer 反思并进化 prompt(见”自进化”章)——形成”轨迹→评测→自动改 prompt”闭环。
  • 无迹象把轨迹导出做 SFT/RL 训练数据(仓库内无 tokenization/训练脚本;ADK 是应用层框架,模型训练不在其范围)。session→memory 的写入算是”轨迹反哺检索型记忆”。

与同类 harness 的关键差异(1-3 条)

  1. 双执行范式并存且正在迁移:同一仓库里 flow 范式(单 agent 内层多轮循环)与 ADK 2.0 图编排(DAG + DynamicNodeScheduler + resumable)共存,base_llm_flow.py:1307-1322 显示跨 agent 编排已从递归 transfer 上移到图调度;这一点比 crewai/langgraph 单一范式更复杂,图范式本身则最接近 langgraph。
  2. 平台化的模型协同:context caching、thinking planner、native code exec、grounding、Live 双向流、Memory Bank、多档托管代码沙箱(Vertex/Agent Engine/GKE)都有 Google 侧一等实现,同时经 LiteLLM/Anthropic 保持模型无关——“深绑生态 + 名义模型无关”两面下注,区别于纯厂商中立框架。
  3. 直接复用 Anthropic Agent Skills 规范skills/ 兼容 agentskills.io 的 SKILL.md L1/L2/L3 渐进披露,而非自造技能格式;同时用独立的 15-hook Plugins 机制承载横切逻辑,把”能力扩展”(Skills)与”运行时拦截”(Plugins)明确分层。

原始源码定位

  • repo: https://github.com/google/adk-pythonpyproject.toml name=google-adk,description=“Agent Development Kit”,已验证为官方仓库)
  • commit/version analyzed: 61ba59a23f06d78bbd5ed49bac918787e2739066(2026-07-10 08:20:15 -0700),版本 2.4.0src/google/adk/version.py),克隆日期 2026-07-11
  • 关键文件列表(相对 src/google/adk/):
    • runners.py — Runner 顶层:service 装配、run_async 主循环、DynamicNodeScheduler 驱动、append_event
    • flows/llm_flows/base_llm_flow.py — agent loop、pre/postprocess、tool dispatch 入口、before/after model callback、agent 切换
    • flows/llm_flows/single_flow.py — request/response processor 管线注册顺序(单 agent)
    • flows/llm_flows/auto_flow.py — SingleFlow + agent_transfer processor(多 agent)
    • flows/llm_flows/functions.py — 工具并行执行、before/after/on_error callback、confirmation/auth 事件生成、parallel FR merge
    • flows/llm_flows/agent_transfer.py — 多 agent transfer 的系统提示注入 + transfer_to_agent 工具
    • flows/llm_flows/instructions.py — 系统提示组装(instruction / static_instruction / global_instruction + state 注入)
    • flows/llm_flows/compaction.py + apps/compaction.py — 会话事件压缩(token 阈值、LLM 摘要、滑窗 overlap、自包含切分)
    • agents/base_agent.py — BaseAgent(=BaseNode):run_async、before/after/error callback、agent state
    • agents/llm_agent.py — LlmAgent 全字段与 flow 选择
    • agents/loop_agent.py — LoopAgent:max_iterations + escalate 停止
    • agents/context.py — Context/ToolContext:request_confirmation / request_credential / search_memory / save_artifact / run_node
    • tools/base_tool.pyfunction_tool.pytool_confirmation.pypreload_memory_tool.py — 工具定义/声明/confirmation/记忆预载
    • skills/models.pyprompt.pyskill_registry.pyREADME.md — Agent Skills 系统
    • optimization/gepa_root_agent_prompt_optimizer.pysimple_prompt_optimizer.pyagent_optimizer.py — 自进化 prompt 优化
    • plugins/plugin_manager.pybase_plugin.py — 插件回调体系
    • telemetry/tracing.py — OTel span + GenAI semconv
    • code_executors/*.py — 代码执行沙箱各实现
    • workflow/_dynamic_node_scheduler.py + docs/guides/workflow/* — 图编排/动态节点/恢复
    • sessions/memory/auth/evaluation/(成组阅读,未逐文件列出)

一手源存档(sources/)

存档目录 /Users/zhao/projects/self-wiki/ai-research/sources/harness/google-adk/

  • NOTES.md — 第一阶段源码级调研笔记(本 dossier 的唯一信息来源,含全部文件路径/行号)
  • src-archive/(26 个核心源文件,约 468K),具体文件:
    • runners.pybase_plugin.pyplugin_manager.pycompaction.py
    • agents/base_agent.pycontext.pyllm_agent.pyloop_agent.py
    • flows_llm_flows/agent_transfer.pyauto_flow.pybase_llm_flow.pycompaction.pyfunctions.pyinstructions.pysingle_flow.py
    • optimization/agent_optimizer.pygepa_root_agent_prompt_optimizer.pysimple_prompt_optimizer.py
    • skills/README.mdmodels.pyprompt.pyskill_registry.py
    • tools/base_tool.pyfunction_tool.pypreload_memory_tool.pytool_confirmation.py

说明:第一阶段未额外抓取官方文档站(google.github.io/adk-docs)与官方博客;仓库内 docs/guides/ 已覆盖 workflow/agents/tools/events 的原理说明。若需补充设计动机可后续补抓。