Support OpenAI Reasoning Models in the Model Adapter

Aperta
#171 0 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
48/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
typescript

Direzione di ricerca

Start with packages/models/src/providers/openai.ts around lines 138–160 and trace how the adapter builds request parameters and reads model sampling profiles. Check how existing tests construct standard model requests, then add coverage for reasoning and standard models as the work breakdown specifies. Done means the request fields match each model family’s requirements and the listed typecheck, test, and lint commands pass.

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

Descrizione

bug good first issue

Summary

Codra's OpenAI adapter in packages/models/src/providers/openai.ts unconditionally sends temperature and max_tokens to every OpenAI model. Modern OpenAI reasoning models including the o-series (o1, o3, o3-mini, o4-mini) and newer GPT-5/GPT-6 family models in reasoning mode reject these parameters and return HTTP 400 Bad Request, making it impossible to route Codra reviews to any OpenAI reasoning model.

This is the parent issue. See sub-issues for the specific implementation tasks.

Work Breakdown

  • Sub-issue: Add reasoning model detection helper and conditional request body (covers max_completion_tokens and role: "developer")
  • Sub-issue: Add reasoning_effort support via model sampling profile
  • Sub-issue: Tests for reasoning and standard model request construction

Affected File

packages/models/src/providers/openai.ts lines 138-160:

const bodyPayload: Record<string, unknown> = {
  model,
  messages: [
    { role: "system", content: prompts.system },
    { role: "user", content: prompts.user },
  ],
  temperature,                        // rejected by o1, o3, o3-mini, o4-mini
  max_tokens: effectiveCeiling,       // must be max_completion_tokens for reasoning models
  response_format: { type: "json_object" },
};

OpenAI Reasoning Model API Requirements

Model family temperature max_tokens max_completion_tokens reasoning_effort
gpt-4o, gpt-4o-mini accepted accepted - -
gpt-5, gpt-5-mini accepted accepted - -
o1, o1-mini rejected rejected required optional
o3, o3-mini rejected rejected required supported
o4-mini rejected rejected required supported
gpt-6 (reasoning mode) rejected rejected required supported

Reasoning models generate internal chain-of-thought tokens before producing output. max_completion_tokens controls the ceiling over both reasoning and output tokens combined.

Done When

  • o1, o3, o3-mini, o4-mini models receive max_completion_tokens instead of max_tokens
  • temperature is omitted for reasoning models
  • role: "developer" replaces role: "system" for reasoning model system prompts
  • reasoning_effort is populated from the model sampling profile when available
  • Detection logic is forward-compatible (prefix-based, not a hardcoded list of model names)
  • Standard models (gpt-4o, gpt-4o-mini, gpt-5, custom base URLs) continue working unchanged
  • Tests cover reasoning model request construction and standard model construction
  • npm run typecheck, npm test, and npm run lint all pass
Lingua principale
TypeScript
Stelle
125
Fork
23
Merge medio
2g 13h
PR unite (30g)
12

Preparare l'ambiente

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 devarshishimpi/codra

Tutte le issue di devarshishimpi/codra

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.