Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 17 additions & 9 deletions src/api/providers/openai-codex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -908,17 +908,25 @@ export class OpenAiCodexHandler extends BaseProvider implements SingleCompletion
}
}

if (item.type === "text" && item.text) {
yield { type: "text", text: item.text }
} else if (item.type === "reasoning" && item.text) {
yield { type: "reasoning", text: item.text }
} else if (item.type === "message" && Array.isArray(item.content)) {
for (const content of item.content) {
if ((content?.type === "text" || content?.type === "output_text") && content?.text) {
yield { type: "text", text: content.text }
// For "added" events, yield text/reasoning content (streaming path)
// For "done" events, do NOT yield text/reasoning - it's already been streamed via deltas
// and would cause double-emission (A, B, C, ABC).
if (event.type === "response.output_item.added") {
if (item.type === "text" && item.text) {
yield { type: "text", text: item.text }
} else if (item.type === "reasoning" && item.text) {
yield { type: "reasoning", text: item.text }
} else if (item.type === "message" && Array.isArray(item.content)) {
for (const content of item.content) {
if ((content?.type === "text" || content?.type === "output_text") && content?.text) {
yield { type: "text", text: content.text }
}
}
}
} else if (
}

// Only handle tool/function calls from done events (to ensure arguments are complete)
if (
(item.type === "function_call" || item.type === "tool_call") &&
event.type === "response.output_item.done"
) {
Expand Down
30 changes: 19 additions & 11 deletions src/api/providers/openai-native.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1223,20 +1223,28 @@ export class OpenAiNativeHandler extends BaseProvider implements SingleCompletio
}
}

if (item.type === "text" && item.text) {
yield { type: "text", text: item.text }
} else if (item.type === "reasoning" && item.text) {
yield { type: "reasoning", text: item.text }
} else if (item.type === "message" && Array.isArray(item.content)) {
for (const content of item.content) {
// Some implementations send 'text'; others send 'output_text'
if ((content?.type === "text" || content?.type === "output_text") && content?.text) {
yield { type: "text", text: content.text }
// For "added" events, yield text/reasoning content (streaming path)
// For "done" events, do NOT yield text/reasoning - it's already been streamed via deltas
// and would cause double-emission (A, B, C, ABC).
if (event.type === "response.output_item.added") {
if (item.type === "text" && item.text) {
yield { type: "text", text: item.text }
} else if (item.type === "reasoning" && item.text) {
yield { type: "reasoning", text: item.text }
} else if (item.type === "message" && Array.isArray(item.content)) {
for (const content of item.content) {
// Some implementations send 'text'; others send 'output_text'
if ((content?.type === "text" || content?.type === "output_text") && content?.text) {
yield { type: "text", text: content.text }
}
}
}
} else if (
}

// Only handle tool/function calls from done events (to ensure arguments are complete)
if (
(item.type === "function_call" || item.type === "tool_call") &&
event.type === "response.output_item.done" // Only handle done events for tool calls to ensure arguments are complete
event.type === "response.output_item.done"
) {
// Handle complete tool/function call item
// Emit as tool_call for backward compatibility with non-streaming tool handling
Expand Down
Loading