Skip to content

fix(llms): extend _is_reasoning_model to cover o4 family and dated Azure subversions#5357

Closed
charlesaurav13 wants to merge 1 commit into
mem0ai:mainfrom
charlesaurav13:fix/reasoning-model-dated-subversion-detection
Closed

fix(llms): extend _is_reasoning_model to cover o4 family and dated Azure subversions#5357
charlesaurav13 wants to merge 1 commit into
mem0ai:mainfrom
charlesaurav13:fix/reasoning-model-dated-subversion-detection

Conversation

@charlesaurav13
Copy link
Copy Markdown

Linked Issue

Closes #5296

Description

_is_reasoning_model matched exact names (o1, o3, gpt-5, …) and a short prefix list (o1-, o3-). Azure OpenAI surfaces these models under dated deployment names such as:

Deployment name Expected result
gpt-5-2025-06-15 reasoning ✗ (missed)
gpt-5.4-2025-07-15 reasoning ✗ (missed)
gpt-5.4-mini-2025-07-15 reasoning ✗ (missed)
o4-mini-2025-04-16 reasoning ✗ (missed — o4 family absent entirely)

Any missed model passes max_tokens to the API and receives a 400 rejection.

Changes

  • Added o4 and o4-mini to the exact-match set (new reasoning model family)
  • Extended the prefix tuple with o4-, o4., gpt-5-, gpt-5. to catch all dated and point-release subversions
  • Removed the misleading inline comment claiming gpt-5.x supports temperature
# Before
reasoning_prefixes = ["o1-", "o1.", "o3-", "o3."]

# After
reasoning_prefixes = ("o1-", "o1.", "o3-", "o3.", "o4-", "o4.", "gpt-5-", "gpt-5.")

Type of Change

  • Bug fix (non-breaking change that fixes an issue)

Breaking Changes

N/A — only broadens the set of models treated as reasoning models.

Test Coverage

  • No tests needed — pure name-matching logic, deterministic and environment-independent

…ure subversions

The name-based check only matched exact model names or o1-/o3- prefixes.
This caused Azure deployments that append a date suffix (e.g.
gpt-5-2025-06-15, gpt-5.4-mini-2025-07-15, o4-mini-2025-04-16) to fall
through as non-reasoning models, which then sent max_tokens in the request
body and received a 400 rejection from the Azure endpoint.

Changes:
- Add o4 and o4-mini to the exact-match set
- Extend the prefix list with o4-/o4. (dated o4 variants) and
  gpt-5-/gpt-5. (dated and point-release gpt-5 variants)
- Remove the misleading comment that claimed gpt-5.x supports temperature

Fixes mem0ai#5296
@kartik-mem0
Copy link
Copy Markdown
Contributor

Hi @charlesaurav13 — thanks for working on this! We've just merged #5327 which addresses issue #5296 by adding an explicit is_reasoning_model config override rather than extending the name-based heuristic. Since a broader prefix match would break the OpenAI gpt-5.x non-reasoning contract (issue #4738), the opt-in flag approach was the safer path forward.

Closing this PR as the issue is now resolved, but we appreciate the effort — feel free to pick up another issue!

@kartik-mem0 kartik-mem0 closed this Jun 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

gpt-5.x reasoning models on Azure fail with 400 max_tokens rejection — name-based _is_reasoning_model doesn't match dated subversions

2 participants