fix(frameworks): serialize Google ADK AgentTool and zod v4 schemas - #170
Closed
ling-senpeng13 wants to merge 1 commit into
Closed
fix(frameworks): serialize Google ADK AgentTool and zod v4 schemas#170ling-senpeng13 wants to merge 1 commit into
ling-senpeng13 wants to merge 1 commit into
Conversation
Two gaps made the ADK agent-as-tool example hang forever and, once unblocked, call tools with no arguments: 1. _tryExtractAgentTool only recognized OpenAI Agents SDK markers (_is_agent_tool / _agent_instance). Google ADK's AgentTool exposes a plain 'agent' property (constructor names are minified), so it degraded into a generic tool entry with no callable — the server scheduled a worker task no local worker ever polled. Detect the ADK shape and recursively serialize the child agent. 2. _isZodSchema only matched zod v3 (_def.typeName). ADK bundles zod v4, whose schemas carry _zod internals instead, so tool parameter schemas fell through to generic enumeration and serialized as mangled internals — the LLM saw parameterless tools and called them argless. Add v4 detection and a structural _zod.def -> JSON Schema walker (the SDK's own zod is v3, so no library can convert a v4 instance cross-package). Verified: examples/agents/adk/21-agent-tool.ts, previously deadlocked, now completes with tool-grounded results and zero tool errors.
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.
Fixes Google ADK agent-as-tool usage —
examples/agents/adk/21-agent-tool.tshung forever.1. Detect ADK
AgentTool. ADK's publicAgentToolConfigholds the child agent under a plainagentproperty._tryExtractAgentToolonly knew the OpenAI SDK markers (_is_agent_tool/_agent_instance), so ADK agent-tools serialized as workers with no callable — the server scheduled tasks no worker ever polled (deadlock). Detection is by the documentedagentshape: class names are minified in the published bundle, and ADK's ownisAgentTool()guard can't be imported by this framework-agnostic serializer.2. Support zod v4 schemas. ADK tool parameters are zod v4 (
ToolInputParameters, and@google/adkdepends onzod ^4.2.1). v4 dropped_def.typeName(changelog), so_isZodSchemamissed v4 schemas and tool parameters serialized as raw zod internals — the LLM saw parameterless tools and called them with no arguments. Added v4 detection (_zodmarker) and a structural_zod.def→ JSON Schema walker (the SDK's own zod is v3, so no existing converter can read a v4 instance).Verified: example 21 now completes with tool-grounded results and zero tool errors; ADK examples 15–22 pass in parallel with the new paths active; 25/25 serializer tests, 94/94 frameworks suite.