Skip to content

fix(ai): reasoning request parameters follow the model's declared capability, not its name #888

Closed

Description

@dan-petty

Context & Rationale

is_reasoning_model (ai/client/models.py:209-218) decides from the model name alone. It checks for :thinking, then two substrings, six exact names and eight prefixes (config/constants.py:1691-1707).

OpenAICompatProviderMixin uses the answer to pick request parameters (ai/client/openai.py:102-105):

  • reasoning models get reasoning_effort and max_completion_tokens;
  • other models get max_tokens, temperature and top_p (:57-80).

At ef21785 it is wrong in both directions for the deployed gateway:

  • devops-reasoning is on the exact list, but the gateway routes it to ollama_chat/qwen3-coder:30b (k8s/llm/gateway/configmap.yaml:49-52), which does not reason. Its temperature and top_p are never sent.
  • gpt-oss:20b serves two of the four devops-review deployments (configmap.yaml:99-108) and is a reasoning model, but it gets standard parameters and no reasoning_effort.
  • Names outside the lists: o5-mini and claude-opus-4 also return false.

The gateway sets drop_params: true (configmap.yaml:166), so mismatched parameters are dropped silently instead of failing. A direct provider call gets no such protection. The gateway already serves /model/info, which fetch_model_info reads (ai/gateway.py:258).

Scope & Deliverables

  • Deliverable:
    • The client picks parameters from a declared capability:
      • gateway deployments declare supports_reasoning in their model_info, and the client reads it from /model/info once per process;
      • models used directly without the gateway declare it in devops-cli's model configuration;
      • an undeclared model gets standard parameters.
    • Delete the three name lists and the :thinking check.
  • Acceptance criteria:
    • Unit tests against a fake /model/info payload check that:

      • a declared deployment gets reasoning parameters;
      • an undeclared one gets standard parameters;
      • a model named o3 with no declaration gets standard parameters.

      Verified by the tests, with no network.

    • grep -rn 'CONST_REASONING_MODEL_' src tests prints nothing. Verified by the command.

    • Check a person runs after deploying the gateway config: curl -s -H "Authorization: Bearer $DEVOPS_AI_GATEWAY_KEY" "$DEVOPS_AI_GATEWAY_URL/model/info" | jq '.data[] | {model_name, model: .litellm_params.model, r: .model_info.supports_reasoning}' shows true only for the gpt-oss deployments.

  • Key questions:
    • What happens for a model group that mixes reasoning and non-reasoning deployments, such as devops-review? Proposed: a group gets reasoning parameters only when every deployment in it declares support. A mixed group gets standard parameters, and the PR records that this applies to devops-review.
    • Does the pinned LiteLLM image pass supports_reasoning through /model/info? The builder confirms it with the curl check above. If it does not, the client reads the same flag from devops-cli's own model configuration (proposed).
  • Constraint: No name or prefix matching remains. Tests never call a gateway.

Strategic Alignment

Split off #431 during the v0.2.25/v0.2.26 readiness review (2026-10-01): Part of #431's original scope that #431 no longer covers. It is a different module (the AI client) and needs a gateway config change, so it is its own PR.

Update 2026-10-08: refinement

Owner decision on #1001: thinking comes from pydantic-ai settings and profiles, never names. The declared capability sets supports_thinking on the ModelProfile; ai/client/openai.py:57-80 goes with #1001's adapters. Sources add Ollama's /api/show capabilities; the error-text checks (ai/client/ollama.py:214-401) go.

  • A model named o3 with no declaration gets supports_thinking=False.
  • With thinking off, no reasoning parameter is sent.

Activity

  1. added
    type/bug
    scope/ai
    priority/p2-medium
    on Oct 1, 2026
  2. dan-petty commented on Oct 3, 2026

    @dan-petty
    OwnerAuthor

    Evidence from the model-choice evaluation (2026-10-03): enable_thinking=False turns thinking on. Source: .data/model-choice-20261003.md, section 3, and its verification pass. Lines are at e3ff98c.

    How "no thinking" becomes think: true.

    • The persona calls with enable_thinking=False (ai/review/pipeline.py:967). On the gateway path that reaches only reasoning-named models (ai/client/openai.py:101-104).
    • Where it applies, _apply_reasoning_params maps False to effort "low", or to the configured ai.reasoning_effort, which is "high" in the owner's config (openai.py:60).
    • LiteLLM v1.103.0's ollama_chat map_openai_params sets think = value in {"low", "medium", "high"} for every model except gpt-oss [sourced: BerriAI/litellm v1.103.0 litellm/llms/ollama/chat/transformation.py].
    • So a request that means "no thinking" arrives at Ollama as think: true.

    Ollama's side (v0.34.4) [sourced]:

    The workaround today. think: false in a gateway deployment's litellm_params reaches Ollama as top-level think, because LiteLLM's transform_request keeps False. The model-choice plan uses it for a qwen3.6:35b-a3b trial group.

    Suggested addition to the criteria. A model declared to support thinking, called with enable_thinking=False, sends think: false (or no reasoning parameter), never an effort that LiteLLM maps to think: true. A model declared without it gets no think at all.

    No review model is reasoning-named today (devops-review, qwen3-coder:30b), so this bites only if a thinking model joins the review. P2 still fits.

    The other settings the pipeline cannot pass are filed as #1070: num_ctx on the gateway path, sampling keys that are silently dropped, streamed chat sending no sampling, sampling that cannot be left unset, sessions that record no sampling, and the reply cache key.

  3. dan-petty commented on Oct 8, 2026

    @dan-petty
    OwnerAuthor

    Addition from the 2026-10-08 client-library audit (checked at release/v0.2.29, 05e9388).

    The native Ollama client decides thinking support from error text.

    • It sends think: true, and on an HTTP 400 whose body contains "does not support thinking" it records the model as non-thinking and retries with think: false (ai/client/ollama.py:213, :388).
    • "Model not found" is also read from the body text (:216, :392).

    Ollama's documented source is POST /api/show, whose reply lists the model's capabilities (for example thinking). The client should read it once per host and model, cache it, and send think only when the model declares the capability. The error-text checks and the retry go.

    Key question for the owner: probe on first use or at prewarm?

    • Proposed: on first use, cached for the process. Prewarm does not run before every command.

    Found by the 2026-10-08 client-library audit.

  4. added this to the v0.2.37 milestone on Oct 17, 2026
  5. dan-petty commented on Oct 17, 2026

    @dan-petty
    OwnerAuthor

    Moved to v0.2.37: v0.2.37 started with fewer than its 16 items and was topped up to 16 from Ready items, critical fixes and P0 features first. (devops roadmap reprioritize)

  6. dan-petty commented on Oct 18, 2026

    @dan-petty
    OwnerAuthor

    What changed

    #1636, merged into release/v0.2.37 as 50711da.

    Summary

    Replaces model name heuristics (CONST_REASONING_MODEL_* constants, name substring matching, and :thinking prefixes) with capability-driven parameter selection:

    • Gateway deployments declare supports_reasoning: true in model_info within k8s/llm/gateway/configmap.yaml, and the client queries /model/info cached per process. Model groups (e.g. devops-review) require unanimous declaration across all group deployments; mixed or undeclared deployments receive standard parameters.
    • Models used directly without the gateway declare supports_reasoning in config (AIConfig, AITaskOverride). Undeclared models (including o3) receive standard parameters.
    • Native Ollama client sends think: true only when thinking is enabled AND supports_reasoning=True is declared in config; when thinking is disabled or undeclared, no reasoning parameters (think, reasoning_effort) are sent.
    • Transparent 400 error-text scraping and retry loops are eliminated.
    • Deleted CONST_REASONING_MODEL_SUBSTRINGS, CONST_REASONING_MODEL_PREFIXES, and CONST_REASONING_MODEL_EXACT.

    Closes #888

    25 file(s) changed.

    How it was verified

    Check runs at 30d88eb:

    • Prune PR DevContainer Images: pass
    • Audit Defect PR Hardening: skipping
    • devops-cli: pass
    • zizmor: pass
    • bandit: pass
    • CodeQL: pass
    • Static Analysis: pass
    • Fail-to-Pass Check: pass
    • Rule Pack Tests: pass
    • Changed-Test Independence: pass
    • Fail-to-Pass Self-Check: pass
    • Tests & Coverage: pass
    • Analyze (python): pass
    • Analyze (actions): pass
    • Service Image: skipping
    • Dependency Freshness: skipping
    • DevContainer Image: skipping

    Acceptance Criteria of docs/agent/tasks/task-888-reasoning-request-parameters.md:

    No Acceptance Criteria section.

  7. added a commit that references this issue on Oct 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority/p2-mediumscope/aitype/bug

    Type

    No type

    Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions