Repository navigation
fix: omit synthesized reasoning items in Chat→Responses translation (#224) #231
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -275,30 +275,11 @@ export function openaiToOpenAIResponsesRequest( | |
|
|
||
| // Convert assistant messages | ||
| if (role === "assistant") { | ||
| // Add reasoning content before assistant output | ||
| if (msg.reasoning_content) { | ||
| input.push({ | ||
| type: "reasoning", | ||
| id: `reasoning_${input.length}`, | ||
| summary: [{ type: "summary_text", text: toString(msg.reasoning_content) }], | ||
| }); | ||
| } | ||
| // Skip reasoning_content — OpenAI Responses API requires server-generated | ||
| // rs_* IDs for reasoning items. Synthesizing client-side IDs (e.g. reasoning_N) | ||
| // causes 400 errors from Responses-compatible upstreams. (#224) | ||
|
|
||
| // Handle thinking blocks in array content | ||
| if (Array.isArray(msg.content)) { | ||
| for (const blockValue of msg.content) { | ||
| const block = toRecord(blockValue); | ||
| if (block.type === "thinking" || block.type === "redacted_thinking") { | ||
| input.push({ | ||
| type: "reasoning", | ||
| id: `reasoning_${input.length}`, | ||
| summary: [ | ||
| { type: "summary_text", text: toString(block.thinking || block.data, "...") }, | ||
| ], | ||
| }); | ||
| } | ||
| } | ||
| } | ||
| // Skip thinking blocks in array content — same rs_* ID constraint applies | ||
|
|
||
|
Comment on lines
+278
to
283
|
||
| // Build assistant output content | ||
| const outputContent: unknown[] = []; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change fixes a specific interoperability bug (synthetic reasoning_* IDs causing 400s). Please add a unit test that exercises Chat→Responses translation with (a) assistant reasoning_content and (b) assistant array content containing thinking/redacted_thinking blocks, and asserts that no reasoning items are emitted and no synthetic IDs appear in result.input.