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

Aperta
#8,257 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
54/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
typescript
Ambito
api, backend

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.
Lingua principale
TypeScript
Stelle
16.9k
Fork
1.3k
Merge medio
1g 4h
PR unite (30g)
814

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di lidge-jun/opencodex

Tutte le issue di lidge-jun/opencodex

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.