Skip to content

Conversation

@dsfaccini
Copy link
Contributor

@dsfaccini dsfaccini commented Dec 2, 2025

Fixes #3617 temporarily while support is added.

Copy link
Collaborator

@DouweM DouweM left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dsfaccini We should also have a recorded test that verifies that a nested schema now works properly with OpenRouter + Gemini again

"""
is_image_model = 'image' in model_name
is_3_or_newer = 'gemini-3' in model_name
return GoogleModelProfile(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldn't copy paste all of this! We should call the original google_model_profile, and then do the replace thing to swap out just the transformer

) from _import_error


class OpenRouterGoogleJsonSchemaTransformer(JsonSchemaTransformer):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is public now, I don't think it should be :)

@DouweM DouweM changed the title Interim fix for latest json schema support for gemini models via openrouter Fix structured output with nested definitions with Gemini via OpenRouter Dec 2, 2025
@DouweM DouweM self-assigned this Dec 2, 2025
assert result['properties']['email']['description'] == 'User email (format: email)'
assert 'format' not in result['properties']['email']

# format -> description without existing description (lines 76-77)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These line numbers will get outdated; please don't include them

ToolDefinition(
name='insert_level_with_spaces',
description=InsertLevelWithSpaces.__doc__ or '',
parameters_json_schema=InsertLevelWithSpaces.model_json_schema(),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's use an Agent with a @agent.tool so we are sure that it goes through the exact same processing that users would see

@DouweM DouweM merged commit 3b6dc5e into pydantic:main Dec 3, 2025
56 of 59 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

OpenRouter + Google models produce degraded output due to schema format changes

2 participants