Map Thinking Budget to Reasoning Effort for OpenAI Models

Ouverte
#177 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Les mainteneurs répondent en général sous 1 jour

Personne n'a encore pris cette issue.

Évaluation

Difficulté
3/5
Temps estimé
1-2 jours
Accessibilité débutants
65/100
Type d'issue
Fonctionnalité
Clarté
Plutôt claire
Activité
Active
Stack technique
typescript

Piste de recherche

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.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

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
Langage dominant
TypeScript
Étoiles
125
Forks
23
Merge moyen
2 j 13 h
PR mergées (30 j)
12

Préparer son environnement

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de devarshishimpi/codra

Toutes les issues de devarshishimpi/codra

Issues similaires

Plus d'issues TypeScript

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.