Skip to content

fix(langchain): tighten structured output model fallbacks#38042

Merged
Mason Daugherty (mdrxy) merged 6 commits into
masterfrom
mdrxy/chore/oai-model-sweep
Jun 11, 2026
Merged

fix(langchain): tighten structured output model fallbacks#38042
Mason Daugherty (mdrxy) merged 6 commits into
masterfrom
mdrxy/chore/oai-model-sweep

Conversation

@mdrxy

Copy link
Copy Markdown
Member

Provider-native structured output fallback detection now uses bounded model-name patterns instead of broad substring checks, reducing false positives for unrelated model IDs. The model examples and test fixtures across OpenAI/OpenRouter-facing code were refreshed around current OpenAI model families while preserving shipped defaults.

Changes

  • Tightened FALLBACK_MODELS_WITH_STRUCTURED_OUTPUT from loose string fragments to regex patterns, with _supports_provider_strategy matching full model-name segments instead of arbitrary substrings.
  • Expanded structured-output fallback coverage for newer OpenAI, Anthropic, and xAI/Grok model families, including gpt-5.x, newer Claude 4/5-style names, and grok-build.
  • Reused _attempt_infer_model_provider in provider tool search routing so _provider_from_model_name follows the same provider inference behavior as init_chat_model.
  • Suppressed irrelevant provider-inference deprecation warnings during provider tool search registry lookup.
  • Refreshed OpenAI, Azure OpenAI, OpenRouter, core metadata, and example model references from older fixtures like gpt-4, gpt-4o, o1, and o4-mini to current test/profile models such as gpt-5.5, gpt-5-nano, and gpt-4.1-mini.
  • Removed outdated OpenAI test assumptions around legacy o1 behavior and narrowed legacy structured-output checks to explicitly legacy model names.

Provider-native structured output fallback detection now uses bounded model-name patterns instead of broad substring checks, reducing false positives for unrelated model IDs. The model examples and test fixtures across OpenAI/OpenRouter-facing code were refreshed around current OpenAI model families while preserving shipped defaults.

## Changes
- Tightened `FALLBACK_MODELS_WITH_STRUCTURED_OUTPUT` from loose string fragments to regex patterns, with `_supports_provider_strategy` matching full model-name segments instead of arbitrary substrings.
- Expanded structured-output fallback coverage for newer OpenAI, Anthropic, and xAI/Grok model families, including `gpt-5.x`, newer Claude 4/5-style names, and `grok-build`.
- Reused `_attempt_infer_model_provider` in provider tool search routing so `_provider_from_model_name` follows the same provider inference behavior as `init_chat_model`.
- Suppressed irrelevant provider-inference deprecation warnings during provider tool search registry lookup.
- Refreshed OpenAI, Azure OpenAI, OpenRouter, core metadata, and example model references from older fixtures like `gpt-4`, `gpt-4o`, `o1`, and `o4-mini` to current test/profile models such as `gpt-5.5`, `gpt-5-nano`, and `gpt-4.1-mini`.
- Removed outdated OpenAI test assumptions around legacy `o1` behavior and narrowed legacy structured-output checks to explicitly legacy model names.
@github-actions github-actions Bot added core `langchain-core` package issues & PRs fix For PRs that implement a fix integration PR made that is related to a provider partner package integration internal langchain `langchain` package issues & PRs langchain-classic `langchain-classic` package issues & PRs openai `langchain-openai` package issues & PRs openrouter `langchain-openrouter` package issues & PRs size: L 500-999 LOC text-splitters Related to the package `text-splitters` labels Jun 10, 2026

@open-swe open-swe Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ Open SWE Review: No issues found

Open SWE reviewed this PR and found no potential bugs to report.

Open in WebView Open SWE trace

@mdrxy Mason Daugherty (mdrxy) merged commit 6b9e22d into master Jun 11, 2026
144 of 148 checks passed
@mdrxy Mason Daugherty (mdrxy) deleted the mdrxy/chore/oai-model-sweep branch June 11, 2026 01:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core `langchain-core` package issues & PRs fix For PRs that implement a fix integration PR made that is related to a provider partner package integration internal langchain `langchain` package issues & PRs langchain-classic `langchain-classic` package issues & PRs openai `langchain-openai` package issues & PRs openrouter `langchain-openrouter` package issues & PRs size: L 500-999 LOC text-splitters Related to the package `text-splitters`

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant