Repository navigation
Conversation
There was a problem hiding this comment.
Code Review
This pull request enhances the Gemini model implementation by resolving local $ref schemas as JSON pointers against the root document, replacing the previous limited $defs resolution. It also introduces robust handling for recursive references using node IDs and allows tools to be sent without an output schema if schema conversion fails, logging a warning instead of raising an error. The review feedback suggests utilizing structured logging fields to include the tool name in the warning log and handling potential empty tokens when splitting malformed JSON pointer paths.
huangjeff5
left a comment
There was a problem hiding this comment.
Pointer resolution checks out: zod's #/definitions and #/properties/a refs, a recursive pydantic model, ~1, and remote/missing refs raising INVALID_ARGUMENT with the ref named. Decoding before the split matches RFC 6901 §6. All 1366 tests pass. Two notes inline.
Follow-up idea: google-genai 2.21 has FunctionDeclaration.parameters_json_schema / response_json_schema, and structured output already sends response_json_schema by default. Routing tool schemas that way would pass MCP schemas through as is and make both inline cases go away.
py/packages/genkit-google-genai/tests/models/googlegenai_gemini_test.py:934: nit: stale after the rename;rootdefaults toinput_schemanow. Same for Test Case 12's "missing defs dict" at L1080.
A tool output schema that still can't be converted is now dropped with a warning instead of failing the request.
223f33e to
e586621
Compare
|
opened in the python repo: genkit-ai/genkit-python/pull/90 |
Why
The Gemini schema converter only resolved
$refs that point into a root$defs, matching on the ref's lastpath segment, and raised for anything else. Draft-07
#/definitions/Xand JSON pointer refs like#/properties/a(zod-to-json-schema's default for a reused sub-schema) are common in schemas from MCP servers,which the MCP plugin passes through as-is, so any request carrying such a tool failed before it was sent.
Changes
$refresolves as a local JSON pointer into the root schema:#,#/definitions/..., paths like#/properties/a/items, list indexes,~0/~1escapes and percent-encoding. Remote refs and pointers thatdon't resolve still raise.
$defsref already did. A{"$ref": "#"}inside the root is now treated that way instead of raising.responseand a warning is logged.Input schemas and structured output (
response_schema) still fail on a schema that can't be converted.