Detect OpenAI Reasoning Models and Adjust Request Payload
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 78/100
- Issue 类型
- 功能
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- typescript
调研方向
从 packages/models/src/providers/openai.ts 开始,issue 指出请求负载在此处构建;添加 issue 中描述的模型检测 helper 和条件负载字段。先检查现有的负载构建逻辑及附近的测试,然后补充对推理模型和标准模型分支的覆盖。完成的标准是两个分支都使用指定的字段和提示角色,并且通过要求的 typecheck、test 和 lint 命令。
由索引模型根据 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
-
isOpenAIReasoningModelcorrectly 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_tokensand notemperature - Standard models receive
temperatureandmax_tokensas 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, andnpm run lintall pass
- 主要语言
- TypeScript
- 星标
- 125
- 派生
- 23
- 平均合并
- 2 天 13 小时
- 30 天内合并 PR
- 12
环境准备
- 提供 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
devarshishimpi/codra 的其他 Issue
-
bug good first issue
难度 2/5 1-3 小时 新手友好度 84/100
devarshishimpi/codra#178 ·
维护者通常 1 天内回复
-
enhancement good first issue
难度 4/5 3-5 天 新手友好度 48/100
devarshishimpi/codra#186 ·
维护者通常 1 天内回复
-
enhancement good first issue
难度 4/5 3-5 天 新手友好度 55/100
devarshishimpi/codra#185 ·
维护者通常 1 天内回复
-
enhancement good first issue
难度 4/5 3-5 天 新手友好度 58/100
devarshishimpi/codra#184 ·
维护者通常 1 天内回复
-
enhancement good first issue
难度 3/5 1-2 天 新手友好度 62/100
devarshishimpi/codra#183 ·
维护者通常 1 天内回复
查看 devarshishimpi/codra 的全部 Issue
相似的 Issue
-
难度 1/5 1-3 小时 新手友好度 83/100
gofish-graphics/gofish-graphics#1384 ·
维护者通常 1 天内回复
-
adapter bug
难度 2/5 1-3 小时 新手友好度 83/100
Olanetsoft/agent-lookout#353 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 68/100
vicharanashala/vibe#1542 ·
维护者通常 1 天内回复
-
bug chore P2 size:XS
难度 2/5 1-3 小时 新手友好度 77/100
josephfung/curia#2666 ·
维护者通常 1 天内回复
-
area: batch
难度 2/5 1-3 小时 新手友好度 75/100
inabagumi/shinju-date#7294 ·
维护者通常 1 天内回复