mirror of
https://github.com/Nezumi-2711/9router.git
synced 2026-09-22 20:00:47 +00:00
fix(reasoning): preserve effort through Codex translations
Carry Claude reasoning_effort/reasoning into OpenAI Chat, map into OpenAI Responses reasoning.effort, and keep request-level effort (incl. xhigh) across tool-result turns instead of collapsing to high. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
committed by
decolua
co-authored by
Cursor
parent
940a35e009
commit
3a866fe18d
@@ -159,12 +159,10 @@ export function hasThinkingConfig(body) {
|
||||
return !!(body.reasoning_effort || body.thinking?.type === "enabled");
|
||||
}
|
||||
|
||||
// Normalize thinking config based on last message role
|
||||
// - If lastMessage is not user → remove thinking config
|
||||
// - If lastMessage is user AND has thinking config → keep it (force enable)
|
||||
// Normalize provider-native thinking config based on last message role.
|
||||
// OpenAI reasoning_effort is request-level and must survive tool-result turns.
|
||||
export function normalizeThinkingConfig(body) {
|
||||
if (!isLastMessageFromUser(body)) {
|
||||
delete body.reasoning_effort;
|
||||
delete body.thinking;
|
||||
}
|
||||
return body;
|
||||
|
||||
@@ -168,7 +168,7 @@ function applyFormat(fmt, body, cfg, caps) {
|
||||
case "openai": {
|
||||
if (none && canDisable) { body.reasoning_effort = "none"; break; }
|
||||
const level = toLevel(eff);
|
||||
if (level) body.reasoning_effort = level === "xhigh" || level === "max" ? "high" : level;
|
||||
if (level) body.reasoning_effort = level;
|
||||
break;
|
||||
}
|
||||
case "claude-adaptive": {
|
||||
|
||||
@@ -80,6 +80,16 @@ export function claudeToOpenAIRequest(model, body, stream) {
|
||||
result.tool_choice = convertToolChoice(body.tool_choice);
|
||||
}
|
||||
|
||||
if (body.reasoning_effort !== undefined) {
|
||||
result.reasoning_effort = body.reasoning_effort;
|
||||
} else if (body.reasoning?.effort !== undefined) {
|
||||
result.reasoning_effort = body.reasoning.effort;
|
||||
}
|
||||
|
||||
if (body.reasoning !== undefined) {
|
||||
result.reasoning = body.reasoning;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -316,6 +316,8 @@ export function openaiToOpenAIResponsesRequest(model, body, stream, credentials)
|
||||
if (body.temperature !== undefined) result.temperature = body.temperature;
|
||||
if (body.max_tokens !== undefined) result.max_tokens = body.max_tokens;
|
||||
if (body.top_p !== undefined) result.top_p = body.top_p;
|
||||
if (body.reasoning !== undefined) result.reasoning = body.reasoning;
|
||||
if (body.reasoning_effort !== undefined) result.reasoning = { effort: body.reasoning_effort, summary: "auto" };
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user