Detect OpenAI Reasoning Models and Adjust Request Payload

オープン 初心者向け
#176 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
78/100
issue の種類
機能追加
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
typescript

調査の方向性

issueによるとリクエストのペイロードが構築される packages/models/src/providers/openai.ts から始め、issueで説明されているモデル検出ヘルパーと条件付きペイロードフィールドを追加してください。まず既存のペイロード構築処理と近くのテストを確認し、その後、推論モデルと標準モデルの分岐をカバーするテストを追加してください。両方の分岐で指定されたフィールドとプロンプトのロールが使われ、要求されたtypecheck、test、lintの各コマンドが成功すれば完了です。

索引モデルが issue の本文から書いたものです。

説明

bug good first issue

Goal

Add a helper function that detects whether an OpenAI model identifier refers to a reasoning model, and use it to conditionally adjust the request payload sent in packages/models/src/providers/openai.ts.

Background

OpenAI reasoning models (o1, o3, o3-mini, o4-mini, and future variants) reject the temperature parameter and require max_completion_tokens instead of max_tokens. The current adapter sends both unconditionally, causing HTTP 400 errors for any reasoning model.

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

What to Build

Add an isOpenAIReasoningModel(model: string): boolean helper in the openai provider:

function isOpenAIReasoningModel(model: string): boolean {
  const lower = model.toLowerCase();
  return (
    /^o\d/.test(lower) ||            // o1, o3, o3-mini, o4-mini, o5, etc.
    lower.includes("-reasoning") ||   // possible future naming convention
    lower.startsWith("gpt-6")         // gpt-6 and variants when in reasoning mode
  );
}

Then update the body payload construction to branch on isReasoning:

const isReasoning = isOpenAIReasoningModel(model);

const bodyPayload: Record<string, unknown> = {
  model,
  messages: [
    { role: isReasoning ? "developer" : "system", content: prompts.system },
    { role: "user", content: prompts.user },
  ],
  ...(isReasoning
    ? { max_completion_tokens: effectiveCeiling }
    : { temperature, max_tokens: effectiveCeiling }),
  response_format: { type: "json_object" },
};

Done When

  • isOpenAIReasoningModel correctly identifies o-series and gpt-6 models
  • Standard models (gpt-4o, gpt-5, custom endpoints) return false and are unaffected
  • Reasoning models receive max_completion_tokens and no temperature
  • Standard models receive temperature and max_tokens as before
  • role: "developer" is used for the system prompt on reasoning models
  • Unit tests cover the detection helper and both branches of the payload builder
  • npm run typecheck, npm test, and npm run lint all pass
主要言語
TypeScript
スター
125
フォーク
23
平均マージ
2日 13時間
マージ済み PR(30日)
12

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

devarshishimpi/codra のほかの issue

devarshishimpi/codra の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。