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

Open
#8,257 2 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
54/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
typescript
Domain
api, backend

Research direction

Start by capturing Mistral’s raw 400 and 422 response bodies for the reported reasoning efforts, then check whether they match isReasoningEffortRejection in src/providers/reasoning-metadata.ts. Read src/server/chat-native.ts and src/adapters/openai-chat/passthrough.ts, comparing their flow with the Responses dispatch files. Done means a qualifying refusal triggers one lower-rung replay and records the refused rung so later turns and exports omit it.

Written by the indexing model from the issue text.

Description

enhancement needs-info provider
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 ebeb1dc8ad. 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.
Dominant language
TypeScript
Stars
16.9k
Forks
1.3k
Avg merge
1d 4h
Merged PRs (30d)
814

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from lidge-jun/opencodex

All issues in lidge-jun/opencodex

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.