fix(translator): stop emitting empty <think> markers into OpenAI content

This commit is contained in:
MrBeanDev
2026-09-26 11:31:54 +07:00
parent 3e4323e2fd
commit 5d2cfbf3c5
5 changed files with 185 additions and 38 deletions

View File

@@ -129,12 +129,16 @@ export function openaiToOpenAIResponsesResponse(chunk, state) {
}
if (content) {
// The answer starts, so thinking is over. Upstreams that send reasoning via
// reasoning_content never emit "</think>", so close it here rather than at finish.
closeReasoning(state, emit);
emitTextContent(state, emit, idx, content);
}
}
// Handle tool_calls (empty array is truthy; require a real call)
if (delta.tool_calls && delta.tool_calls.length) {
closeReasoning(state, emit);
closeMessage(state, emit, idx);
for (const tc of delta.tool_calls) {
emitToolCall(state, emit, tc);