Skip to content

Conversation

@mindful-time
Copy link
Contributor

Description

Fixes #9032

The gpt-5-chat model (available through Azure AI Foundry) was being incorrectly classified as a reasoning model, causing it to be subject to reasoning model validation requirements and attempting to pass reasoning parameters that Azure's API doesn't support.

Changes

  • Updated regex pattern in dspy/clients/lm.py: Modified the reasoning model detection regex to use negative lookahead (?!-chat) to exclude gpt-5-chat while still allowing other gpt-5 variants (gpt-5-mini, gpt-5-nano, gpt-5-pro) to be recognized as reasoning models.

  • Added test coverage:

    • Added gpt-5-chat test case to test_reasoning_model_token_parameter to verify it's not treated as a reasoning model
    • Added dedicated test test_gpt_5_chat_not_reasoning_model to explicitly verify gpt-5-chat can use standard temperature and max_tokens values

Technical Details

The original regex pattern r"^(?:o[1345](?:-(?:mini|nano))?(?:-\d{4}-\d{2}-\d{2})?|gpt-5(?:-(?:mini|nano))?)$" would match gpt-5-chat because the optional suffix allowed any text after gpt-5-.

The new pattern r"^(?:o[1345](?:-(?:mini|nano|pro))?(?:-\d{4}-\d{2}-\d{2})?|gpt-5(?!-chat)(?:-.*)?)$" uses:

  • Negative lookahead (?!-chat) to explicitly exclude -chat suffix
  • (?:-.*)? to allow other suffixes (like -mini, -nano, -pro, or future variants)
  • Also added pro to the o-model variants to support gpt-5-pro as a reasoning model

Testing

  • All existing tests pass
  • New test test_gpt_5_chat_not_reasoning_model verifies gpt-5-chat is not treated as a reasoning model
  • Updated test_reasoning_model_token_parameter includes gpt-5-chat as a non-reasoning model case
  • test_reasoning_model_requirementsincludesgpt-5-pro` to verify it's correctly recognized as a reasoning model

Impact

This fix allows users to use gpt-5-chat with standard conversational parameters (e.g., temperature=0.7, max_tokens=1000) without validation errors, and prevents the runtime error where Azure's API rejects reasoning parameters for this non-reasoning model.

Related

The regex pattern for identifying reasoning models was incorrectly
matching gpt-5-chat, causing it to be subject to reasoning model
validation requirements and attempting to pass reasoning parameters
that Azure's API doesn't support for this model.

Updated the regex to use negative lookahead (?!-chat) to exclude
gpt-5-chat while still allowing other gpt-5 variants like gpt-5-mini,
gpt-5-nano, and gpt-5-pro to be recognized as reasoning models.

- Updated regex pattern in dspy/clients/lm.py
- Added test case for gpt-5-chat in test_reasoning_model_token_parameter
- Added dedicated test test_gpt_5_chat_not_reasoning_model

Fixes issue where gpt-5-chat (Azure AI Foundry) was incorrectly
classified as a reasoning model, preventing normal usage with
standard temperature and max_tokens values.
@mindful-time mindful-time marked this pull request as draft November 7, 2025 22:10
@mindful-time mindful-time marked this pull request as ready for review November 7, 2025 22:11
@okhat okhat merged commit eb29c47 into stanfordnlp:main Nov 10, 2025
10 checks passed
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.

[Bug] Azure gpt-5-chat incorrectly classified as reasoning model

2 participants