Skip to content

Fix ADK single-turn agent-as-tool hanging on Conductor - #468

Draft
ling-senpeng13 wants to merge 1 commit into
mainfrom
fix/adk-single-turn-agent-tool
Draft

Fix ADK single-turn agent-as-tool hanging on Conductor#468
ling-senpeng13 wants to merge 1 commit into
mainfrom
fix/adk-single-turn-agent-tool

Conversation

@ling-senpeng13

@ling-senpeng13 ling-senpeng13 commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Problem

An ADK coordinator whose sub-agents declare mode="single_turn" hangs on Conductor — status stays RUNNING, no error, no timeout, no answer. The identical agent runs correctly under adk web / adk run.

Cause

ADK creates the duplicate itself. Declaring a sub-agent mode="single_turn" auto-inserts a private tool wrapper into the parent's tools while still listing that agent in sub_agents. Serializing the reported coordinator shows both fields carrying the same two children:

tools:      [(_SingleTurnAgentTool, weather_specialist), (_SingleTurnAgentTool, time_specialist)]
sub_agents: [(LlmAgent,             weather_specialist), (LlmAgent,             time_specialist)]

ADK reconciles this per request — _get_transfer_targets() drops single-turn sub-agents when it assembles the model call. The server compiles from a serialized snapshot, where no such step exists, so both survive. It sees a coordinator with tools and sub-agents and offers the model two routes per child with incompatible semantics: the bare sub-agent name, forked as a SIMPLE task no worker is registered for (SCHEDULED forever, JOIN never completes), or a transfer signal that ends the loop and hands off permanently to one specialist. Hence either a hang or a partial answer.

Compounding it, the serializer didn't recognise the wrapper at all: agent-as-tool detection gated on _is_agent_tool, an OpenAI-SDK attribute the ADK wrapper lacks, so it fell through to generic pydantic walking and emitted the private class name as its _type.

Fix

Two changes in serializer.py, both keyed on one isinstance check against ADK's exported AgentTool base class — which covers the private subclasses for single_turn and task without naming them, and won't break on an ADK rename:

  • Emit ADK agent-tools under the public AgentTool shape.
  • Drop sub-agents already reachable as an agent-tool from sub_agents, keyed on object identity since ADK wraps the very same instance.

Adds an e2e regression test, guarded by importorskip on google-adk.

google-adk materialises a tool wrapper into the parent's `tools` for every
sub-agent declared `mode="single_turn"` or `mode="task"`, and leaves that
sub-agent in `sub_agents` as well. ADK reconciles the duplication per request,
when it assembles the model call; the server compiles from the serialized
snapshot, where no such step exists, so both survive.

The compiler then sees a coordinator with tools AND sub-agents and offers the
model two routes per sub-agent with incompatible semantics: the bare sub-agent
name, routed to FORK_JOIN_DYNAMIC as a SIMPLE task no worker is registered for
(SCHEDULED forever, JOIN never completes), or a transfer control signal that
ends the loop and hands off permanently to exactly one specialist. The
workflow either hangs with no error or returns a partial answer.

Two changes to the serializer:

  - Emit ADK agent-tools under the public `AgentTool` shape. Detection is an
    isinstance check against the exported base class, so it covers the private
    subclasses ADK materialises for single_turn/task without naming them.
    Serialization routes through the enclosing `_serialize` so the shared
    `seen` set terminates ADK's `parent_agent` back-reference.

  - Drop sub-agents already reachable as an agent-tool from `sub_agents`,
    keyed on object identity since ADK wraps the very same instance.

Adds an e2e regression test, guarded by importorskip on google-adk.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@ling-senpeng13 ling-senpeng13 self-assigned this Aug 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant