Skip to content

fix(tools): resolve nested models in legacy Vertex declarations - #7792

Closed
Samecho wants to merge 1 commit into
google:mainfrom
Samecho:codex/vertex-legacy-nested-schema
Closed

Samecho wants to merge 1 commit into
google:mainfrom
Samecho:codex/vertex-legacy-nested-schema

Conversation

@Samecho

@Samecho Samecho commented Oct 28, 2026

Copy link
Copy Markdown
Contributor

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_DECL disabled, a tool that combines a nested Pydantic model with a parameter such as datetime fails while building its Vertex AI declaration. The fallback passes Pydantic's $ref and $defs directly to types.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:

  • I have added or updated unit tests for my change.
  • All unit tests pass locally. See the full-suite results below.

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:

Python Passed Failed Skipped
3.11 21,641 1 96
3.12 21,632 1 97
3.13 21,632 1 97
3.14 21,634 1 95

Each run also reported 12 xfailed and 2 xpassed. All four failures are the existing test_ensure_resolved_uses_custom_factory failure with a2a-sdk==1.3.0: CustomFactory._httpx_client is 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 lancedb installation exclusion. Validation run and logs.

Manual End-to-End (E2E) Tests:

Ran a real InMemoryRunner with Gemini, FunctionTool and 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

  • I have read the CONTRIBUTING.md document.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have added tests that prove my fix is effective or that my feature works.
  • New and existing unit tests pass locally with my changes. See the baseline failure above.
  • I have manually tested my changes end-to-end.
  • Any dependent changes have been merged and published in downstream modules. No dependent changes are required.

Additional context

Prepared with Codex. The tests and request checks above were run against this branch.

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
copybara-service Bot pushed a commit that referenced this pull request Oct 29, 2026
With JSON_SCHEMA_FOR_FUNC_DECL disabled, both GEMINI_API and VERTEX_AI declarations now inline nested pydantic models, and VERTEX_AI keeps the response schema for return types such as `Sequence[Person]`.

Merge #7792

Fixes #6984

PiperOrigin-RevId: 1009986494
@adk-bot

adk-bot commented Oct 29, 2026

Copy link
Copy Markdown
Collaborator

Thank you @Samecho for your contribution! 🎉

Your changes have been successfully imported and merged via Copybara in commit 392feb2.

Closing this PR as the changes are now in the main branch.

@adk-bot adk-bot added the merged [Status] This PR is merged label Oct 29, 2026
@adk-bot adk-bot closed this Oct 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merged [Status] This PR is merged

Projects

None yet

3 participants