Repository navigation
fix(tools): handle tuple parameters in external tool adapters - #8480
zhanghm783-hash wants to merge 2 commits into
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
|
Could the adapter regression include AI-assisted review; verification scope described above. |
Link to Issue or Description of Change
Problem
LangChain and CrewAI tools with fixed-length tuple arguments fail while ADK builds their function declarations. Pydantic emits
prefixItemswithoutitems, and the adapter mapping indexesitemsdirectly. A real LangChain wrapper raisesValueError: Failed to build function declaration for Langchain tool: 'items'before the tool can run.Reproduced on main at
e90308ed988bedcf4ba41742eac81886161ea9a5, Windows, Python 3.12.10, google-genai 2.34.0 and langchain-core 1.8.5.Solution
Reuse the existing tuple-schema normalizer before mapping adapter parameters. This follows the handling already used by the FunctionTool fallback. Regression coverage checks fixed, heterogeneous, nullable and nested tuples through both adapter declaration builders, including item types and length bounds. Empty tuples and nested empty tuples retain minItems=maxItems=0 without requiring an items schema; the type mapper recurses only when items exists.
Testing Plan
Unit tests
The eight new cases fail on the unmodified source with
KeyError: 'items'. After the initial fix, these files reported 258 passed. The four empty-tuple regressions (tuple[()] and list[tuple[()]] through both adapters) fail on that revision with KeyError('items'). After guarding recursion on the presence of items, the following related files report 262 passed.Manual adapter verification
With the checkout on PYTHONPATH and its dependencies installed, run this local tool.
Before the change, declaration building raises the error above. After the change, the declaration has an ARRAY of NUMBER values with length bounds of two, and the tool returns
4.0.This is an offline declaration and tool-execution check. Live model requests, the complete CrewAI wrapper integration, the full repository test matrix and remote CI have not been verified.
isort, pyink, Ruff, codespell, compliance, documentation and whitespace checks passed. The Windows pre-commit launcher could not find /bin/bash for the new-file check. Its Python entry point passed separately with the added-file list generated from the actual diff, which adds no files.