Repository navigation
Conversation
Inline Pydantic schema references before validating parameters in the Vertex fallback. Preserve Vertex-specific fields and leave the default JSON-schema and Gemini paths unchanged. Fixes google#6984
Collaborator
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.
Please ensure you have read the contribution guide before creating a pull request.
Link to Issue or Description of Change
Problem:
With
JSON_SCHEMA_FOR_FUNC_DECLdisabled, a tool that combines a nested Pydantic model with a parameter such asdatetimefails while building its Vertex AI declaration. The fallback passes Pydantic's$refand$defsdirectly totypes.Schema, which rejects them. The same tool works with the default JSON-schema declarations.Solution:
Resolve the references with the existing schema helper before validating Vertex fallback parameters. This preserves Vertex formats, defaults and additional properties. The default declaration builder and Gemini fallback are unchanged.
Testing Plan
Unit Tests:
The four regression cases cover a nested model directly and inside a list, mapping or optional parameter. All four fail on unchanged production code and pass with the fix. The assertions also cover required fields, defaults and Vertex formats.
Related declaration, FunctionTool and schema tests: 413 passed on Python 3.11. All applicable pre-commit hooks passed.
Full tox suite on Linux, Python 3.11–3.14, with no test filtering:
Each run also reported 12 xfailed and 2 xpassed. All four failures are the existing
test_ensure_resolved_uses_custom_factoryfailure witha2a-sdk==1.3.0:CustomFactory._httpx_clientis absent. For each Python version, checking out unchanged main with the same resolved dependencies reproduces the same test ID and error message. That compatibility fix is tracked separately in #7777. No A2A source or tests are changed here.The fork also passed the full pre-commit check, all three mypy comparisons, A2A 0.3 and MCP 2 compatibility on four Python versions, and the installed-wheel request check. The jobs retain upstream CI's
lancedbinstallation exclusion. Validation run and logs.Manual End-to-End (E2E) Tests:
Ran a real
InMemoryRunnerwithGemini,FunctionTooland the GenAI SDK, using a local HTTP mock instead of a provider call. On unchanged main, the legacy path fails before sending a request; the default path succeeds. With this change, both paths send a request and return the model response. The captured Vertex request contains the nested fields with no unresolved Pydantic references. The same check passes from an installed wheel on Linux.No live Vertex service call was made.
Checklist
Additional context
Prepared with Codex. The tests and request checks above were run against this branch.