Map Thinking Budget to Reasoning Effort for OpenAI Models

Aperta
#177 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à
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
65/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
typescript

Direzione di ricerca

Start by locating the OpenAI adapter and the sibling issue's isReasoning branch, then read how it builds bodyPayload and accesses the model sampling profile. Add the specified thinkingBudget mapping and cover numeric thresholds, string values, absent budgets, and standard models in tests. Done when those tests 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

Goal

Add reasoning_effort parameter support to the OpenAI adapter for reasoning models that accept it (o3, o3-mini, o4-mini, gpt-6).

Background

OpenAI's reasoning models accept a reasoning_effort parameter with values "low", "medium", or "high" that controls how many internal thinking tokens the model uses. Currently Codra sends no such parameter and cannot tune the cost/quality tradeoff for reasoning model calls.

This sub-issue is part of the parent issue: OpenAI adapter incompatible with reasoning models.

What to Build

After the isReasoning branch is in place (see sibling sub-issue), read the thinkingBudget from the model's sampling profile and map it to reasoning_effort:

if (isReasoning && sampling?.thinkingBudget) {
  let effort: "low" | "medium" | "high" | undefined;

  if (typeof sampling.thinkingBudget === "number") {
    effort =
      sampling.thinkingBudget > 10000 ? "high"
      : sampling.thinkingBudget > 3000 ? "medium"
      : "low";
  } else if (
    sampling.thinkingBudget === "low" ||
    sampling.thinkingBudget === "medium" ||
    sampling.thinkingBudget === "high"
  ) {
    effort = sampling.thinkingBudget;
  }

  if (effort) {
    bodyPayload.reasoning_effort = effort;
  }
}

Done When

  • reasoning_effort is included in requests to supported reasoning models when a thinking budget is configured
  • Numeric budgets are mapped to low/medium/high correctly
  • String values low/medium/high are passed through directly
  • The parameter is omitted when no thinking budget is configured
  • Standard (non-reasoning) models are not affected
  • Tests cover all mapping cases and the absent-budget case
  • 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.