Skip to content

Native Chat passthrough never learns or downgrades a refused reasoning effort (Mistral 400/422) #8257

Open

Description

@lidge-jun

Area

Provider adapters

What are you trying to accomplish?

When a routed provider refuses a reasoning_effort rung on a native Chat Completions request (OpenCode, Kilo, any /v1/chat/completions caller), I want OpenCodex to learn that refusal and replay once at the next lower published rung, as it already does for Responses traffic. Reported in #8254: Mistral answers medium/xhigh with HTTP 400 and ultra with 422 for GLM 5.3, GLM 5.3 Flash and DeepSeek V4.1 Flash 1017.

What prevents this today?

planReasoningEffortDowngrade (src/providers/reasoning-metadata.ts) is only called from src/server/responses/adapter-dispatch.ts and src/server/responses/passthrough-dispatch.ts. The native Chat lane (src/server/chat-native.ts → src/adapters/openai-chat/passthrough.ts) has no downgrade replay and never calls recordUnsupportedReasoningEffort, so a refused rung fails every time and is never learned.

Second unknown: isReasoningEffortRejection needs the upstream body to blame the effort parameter. The reporter only saw the hub's sanitized client body ({"error":{"message":"The provider rejected the request.","type":"invalid_request_error","param":null,...}}), so nobody has confirmed what Mistral's raw 400/422 body says or whether it names reasoning_effort. Without that capture, wiring the replay might never trigger for Mistral.

What should OpenCodex do?

  1. Capture Mistral's raw 400 (medium on zai-glm-5-3) and 422 (ultra) bodies and check them against isReasoningEffortRejection.
  2. If they qualify, add the same single-rung downgrade replay and refusal recording to the native Chat lane, so a learned refusal also drops the rung from configuredReasoningEfforts for later turns and exports.

Example usage or interface

No new configuration. opencode run -m 'opencodex/mistral/deepseek-v4-1-flash-1017#medium' 'Reply with OK' would succeed on the replayed low rung and record medium as unsupported.

Alternatives or workarounds

The #8254 fix ships per-model Mistral ladders and folds native Chat ultra to max, which covers the known Mistral rows. The replay would cover rows whose accepted set changes later or is undocumented (DeepSeek V4.1 Flash 1017's ladder is empirical). Operators can also pin modelReasoningEfforts.

Additional context

Found while fixing #8254 on dev at ebeb1dc. Related: #7590, #8251.

Checks

  • I searched existing issues and documentation.
  • This request describes a concrete OpenCodex workflow rather than merely naming a desired technology.
  • I removed secrets and personal data.

Activity

  1. added
    enhancement
    on Nov 7, 2026
  2. added
    provider
    on Nov 7, 2026
  3. lidge-jun commented on Nov 10, 2026

    @lidge-jun
    OwnerAuthor

    Status on dev df0e6ccc41: unchanged. planReasoningEffortDowngrade is still called only from the two Responses dispatch lanes, and native Chat (src/server/chat-native.ts) has no downgrade replay.

    Step 1 of this proposal is still the blocker. isReasoningEffortRejection (src/providers/reasoning-metadata.ts:456) needs the upstream text to name the parameter: param: reasoning_effort, "unsupported … effort", or reasoning_effort near rejection wording. Without Mistral's raw 400/422 body we cannot tell whether a native Chat replay would ever fire for the Mistral rows in #8254.

    Could someone with a funded Mistral key capture the raw error bodies, with the key and account ids removed? Either of these works:

    • curl https://api.mistral.ai/v1/chat/completions with model: zai-glm-5-3, reasoning_effort: "medium" (the 400), then "ultra" (the 422);
    • or the upstreamError field of the matching ~/.opencodex/usage.jsonl row.

    Once the body is known, the wiring is a single-rung replay plus recordUnsupportedReasoningEffort in the native Chat lane, mirroring passthrough-dispatch.ts. Skipping implementation until then.

  4. lidge-jun commented on Nov 15, 2026

    @lidge-jun
    OwnerAuthor

    Could you capture the raw Mistral 400/422 response bodies (key and ids removed) for reasoning_effort: "medium" and "ultra", or the upstreamError field from the matching usage.jsonl rows? The downgrade needs to recognise the exact refusal text before native Chat can learn from it.

  5. added
    needs-info
    on Nov 15, 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

    enhancementneeds-infoprovider

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions