Support non-ADK agent transfer - #1032
Merged
yaozheng-fang merged 3 commits intoSep 1, 2026
Merged
Conversation
FirstayZheng
force-pushed
the
fix/non-adk-agent-transfer
branch
from
September 1, 2026 03:36
3ef3cb8 to
8f121e3
Compare
FirstayZheng
force-pushed
the
fix/non-adk-agent-transfer
branch
from
September 1, 2026 03:43
8f121e3 to
a38b0ef
Compare
yaozheng-fang
approved these changes
Sep 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景
Codex/PiAgent 这类非 ADK 原生 runtime 会进入各自的 reasoning / tool loop,不再继续走 Google ADK AutoFlow。ADK AutoFlow 原生动态注入的
transfer_to_agent(...)因此不会自动存在,导致配置了sub_agents的 Agent 在非 ADK runtime 下无法完成 agent transfer。这个 PR 的目标是:在不重新依赖 ADK AutoFlow 的前提下,为非 ADK runtime 恢复 ADK 兼容的 agent transfer 语义。
总体方案
veadk.runtime.agent_transfer:TransferToAgentTool暴露标准transfer_to_agent;single_turn、task等不可转移 agent;actions.transfer_to_agent;run_async,并保留output_key写 state 的行为。Codex runtime
transfer_to_agent,让 Codex 的 Responses/tool loop 能看到和 ADK AutoFlow 等价的 transfer tool。before_model_callback之后重新同步 tool bundle,确保 callback 对工具集合的增删改会反映到 Codex shim 中。actions.transfer_to_agent映射成结构化status="transferred",用于 runtime/proxy 判断 transfer 已发生。PiAgent runtime
before_model_callback修改后的 tools_dict 回写到 PiAgent extension;transfer_to_agent,并把 transfer instruction 一起写入 prompt。actions.transfer_to_agent映射成status="transferred"。测试覆盖
get_transfer_targets覆盖 ADK child / parent / peer 规则;append_transfer_instructions覆盖 transfer instruction 生成;run_transferred_agent覆盖目标 agent 执行和output_key写 state。actions.transfer_to_agent;actions.transfer_to_agent;agent_name精确路由到planner / coder / reviewer;before_model_callback可以删除 transfer tool;验证
uv run pre-commit run --files veadk/runtime/agent_transfer.py veadk/runtime/codex/proxy.py veadk/runtime/codex/runtime.py veadk/runtime/codex/tools_bridge.py veadk/runtime/piagent/runtime.py veadk/runtime/piagent/tool_runtime.py veadk/runtime/piagent/tools_bridge.py veadk/runtime/piagent/translate.py tests/runtime/test_agent_transfer.py tests/runtime/codex/test_codex_runtime.py tests/runtime/piagent/test_piagent_runtime.pyuv run pytest tests/runtime/piagent/test_piagent_runtime.py tests/runtime/test_agent_transfer.py tests/runtime/codex/test_codex_runtime.py82 passed, 9 warningsruntime="piagent";worker 使用真实 LLM Agent;.env,MODEL_AGENT_API_BASE显式使用https://ark.cn-beijing.volces.com/api/v3/;CALL transfer_to_agent {"agent_name": "worker"}、TRANSFER_ACTION worker,最终 worker 输出PIAGENT_REAL_LLM_WORKER_OK。r-yeu2jhhkowdvde9li1qa/run_sse返回 200piagent: generated tool extension for ['transfer_to_agent']和tool=transfer_to_agent status=transferredworker。