Map Thinking Budget to Reasoning Effort for OpenAI Models

Abierto
#177 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
65/100
Tipo de issue
Nueva funcionalidad
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
typescript

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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
Lenguaje dominante
TypeScript
Estrellas
125
Forks
23
Merge medio
2 d 13 h
PR fusionados (30 d)
12

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de devarshishimpi/codra

Todos los issues de devarshishimpi/codra

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.