fix(langchain): allow Gemini 3 models to use ProviderStrategy with tools#34464
Merged
ccurme (ccurme) merged 8 commits intolangchain-ai:masterfrom Feb 19, 2026
Merged
Conversation
Contributor
Author
|
This should fixe this issue #34463 |
ProviderStrategy with tools
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.
Fixes #34463
Summary
Passing a raw Pydantic model to
create_agent(..., response_format=MyModel)defaults toAutoStrategy, which checks_supports_provider_strategybefore deciding betweenProviderStrategyandToolStrategy. For Gemini models the helper currently returnsFalsewhenever tools are present, so Gemini 3 models end up usingToolStrategyeven though they support provider-specific structured output with tools (link). Explicitly passingProviderStrategy(MyModel)works; only theAutoStrategydetection path is affected.Impact
create_agent(..., response_format=MyModel)can’t access Gemini’s native structured output when tools are bound.ToolStrategy.ProviderStrategymanually, defeating the convenience ofAutoStrategy.Expected Behavior
_supports_provider_strategyshould returnTruefor Gemini 3 models when tools are present, soAutoStrategyupgrades toProviderStrategyautomatically.gemini-flash(-lite)-latestaliases until they point to 3-series backends) should continue to fall back toToolStrategy.Additional Context
libs/langchain_v1/langchain/agents/factory.py::_supports_provider_strategy.libs/langchain_v1/tests/unit_tests/agents/test_response_format.pycover strategy selection, but there’s currently no case ensuring Gemini 3 + AutoStrategy succeeds.response_format=ProviderStrategy(...)is a temporary workaround but shouldn’t be required.