Skip to content

Add is_reasoning_model config flag for non-OpenAI thinking models#448

Open
MateoTTR wants to merge 2 commits intoalgorithmicsuperintelligence:mainfrom
MateoTTR:upstream/reasoning-model-config
Open

Add is_reasoning_model config flag for non-OpenAI thinking models#448
MateoTTR wants to merge 2 commits intoalgorithmicsuperintelligence:mainfrom
MateoTTR:upstream/reasoning-model-config

Conversation

@MateoTTR
Copy link
Copy Markdown

Summary

  • Extract OPENAI_REASONING_MODEL_PREFIXES from local variable inside generate_with_context() to a module-level constant
  • Extract is_reasoning_model() as a standalone, importable function with 3-state logic
  • Add is_reasoning_model: Optional[bool] = None field to LLMModelConfig

Motivation

Users of non-OpenAI providers (Gemini 2.5 thinking models, DeepSeek-R1, Qwen thinking, etc.) cannot currently configure their models as reasoning models. The hardcoded prefix list only covers OpenAI models, and expanding it with non-OpenAI prefixes is fragile:

  • Gemini thinking is an optional mode — the same model name (gemini-2.5-flash) can run with or without thinking
  • gemini-2.5-flash-lite shares the gemini-2.5- prefix but is NOT a thinking model
  • Future model naming conventions are unpredictable across providers

Solution

A per-model config flag with auto-detection fallback:

  • True → force reasoning model conventions (max_completion_tokens, no temperature/top_p)
  • False → force standard conventions
  • None (default) → auto-detect via OpenAI prefix list (fully backward-compatible)
llm:
  models:
    - name: "gemini-2.5-flash"
      api_base: "https://generativelanguage.googleapis.com/v1beta/openai/"
      is_reasoning_model: true     # explicit opt-in for thinking mode

    - name: "o3-mini"
      # is_reasoning_model omitted → auto-detect → true (OpenAI prefix match)

    - name: "claude-sonnet-4-5-20250929"
      api_base: "https://api.anthropic.com/v1"
      # is_reasoning_model omitted → auto-detect → false

Additional cleanup

  • Removed redundant dash-prefixes (o1-, o3-, gpt-5-) already covered by base prefixes (o1, o3, gpt-5)
  • Replaced full model names gpt-oss-120b/gpt-oss-20b with gpt-oss- prefix
  • Rewrote test_openai_model_detection.py to import and test the real is_reasoning_model() function instead of duplicating detection logic with a non-existent api_base guard

Test plan

  • 12 new tests in test_reasoning_model_detection.py (3-state logic, auto-detect, explicit override, case insensitivity, backward compat)
  • Updated test_openai_model_detection.py to use real function + added gpt-oss coverage
  • All 384 existing tests pass (0 failures, 0 regressions)

🤖 Generated with Claude Code

MateoTTR and others added 2 commits March 28, 2026 12:30
Extract OPENAI_REASONING_MODEL_PREFIXES to module-level constant and
is_reasoning_model() to a standalone function. Add is_reasoning_model
field to LLMModelConfig with 3-state logic: True (force reasoning),
False (force standard), None (auto-detect via OpenAI prefixes).

This allows users of non-OpenAI providers (Gemini, DeepSeek, etc.) to
explicitly mark models as reasoning models via config, without relying
on fragile prefix-based detection.

Closes #2

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…t-oss coverage

- Remove redundant dash-prefixes (o1-, o3-, gpt-5-) already covered by base prefixes
- Replace gpt-oss-120b/gpt-oss-20b full names with gpt-oss- prefix
- Rewrite test_openai_model_detection.py to use real is_reasoning_model() function
  instead of duplicating logic with a non-existent api_base check
- Add test coverage for gpt-oss-* model family
- Add comment explaining intentional omission of is_reasoning_model from shared_config

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Mar 28, 2026

CLA assistant check
All committers have signed the CLA.

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.

2 participants