Skip to content

fix(console): emit complete Responses-API SSE lifecycle for converted streams - #40210

Open
Yuxin-Qiao wants to merge 1 commit into
anomalyco:devfrom
Yuxin-Qiao:fix/console-responses-stream-events
Open

fix(console): emit complete Responses-API SSE lifecycle for converted streams#40210
Yuxin-Qiao wants to merge 1 commit into
anomalyco:devfrom
Yuxin-Qiao:fix/console-responses-stream-events

Conversation

@Yuxin-Qiao

@Yuxin-Qiao Yuxin-Qiao commented Aug 3, 2026

Copy link
Copy Markdown

Issue for this PR

Closes #40171

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

/v1/responses (Zen/Go gateway) synthesizes Responses-API SSE from chat-completions upstream chunks, but only emitted response.output_text.delta and response.completed. Responses-API clients (e.g. the Codex CLI) rely on response.created, response.in_progress, response.output_item.added, response.content_part.added and response.output_item.done to parse a turn, so streaming turns never complete.

Live capture before this change (deepseek-v4-flash, stream: true):

event: response.output_text.delta
event: response.completed
data: [DONE]
event: ping

The fix makes the chat-to-responses stream converter stateful (createToOpenaiChunk in packages/console/app/src/routes/zen/util/provider/openai.ts) and emits the full lifecycle in order: response.created, response.in_progress, response.output_item.added (message), response.content_part.added, response.output_text.delta, response.output_item.done (with accumulated text), response.completed (with output, stop_reason, usage). Tool-call streams also get response.function_call_arguments.done and response.output_item.done. createStreamPartConverter creates one stateful converter per stream; upstreams that already speak Responses-API are still passed through unchanged.

Note: #40011 changes the client-side model catalog only and does not touch the gateway converter, so it does not fix this issue.

How did you verify your code works?

  • Added packages/console/app/test/openaiResponsesStream.test.ts (bun:test, matching existing console tests) covering: full text-stream lifecycle ordering with a single response.created, accumulated text in output_item.done/completed, tool-call lifecycle (function_call_arguments.done, output_item.done), stream with no visible text, and [DONE] passthrough.
  • Ran the same assertions through a Node type-stripping harness locally (bun is not installed in this environment); all passed.

Screenshots / recordings

N/A (server-side gateway change).

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@JINGMINGRUO

Copy link
Copy Markdown

Thanks for working on this! I am a Codex CLI user with an OpenCode Go subscription, and I am hitting exactly the failure described in #40171: with deepseek-v4-flash on https://opencode.ai/zen/go/v1 and wire_api = responses, streaming turns start but never complete because the lifecycle events (response.created, response.output_item.added, response.content_part.added, response.output_item.done) are missing. Long coding tasks are effectively unusable through Codex right now.

This fix looks like exactly what the gateway needs: completing the SSE lifecycle for the chat-to-responses conversion that is already happening. It would unblock a lot of Codex users on OpenCode Go, and I would be happy to test it end-to-end once it is merged.

One heads-up: the issue-compliance bot flagged that the PR description is missing the required template sections and said it would auto-close within 2 hours unless updated. @Yuxin-Qiao, could you fill in the PR description template so this stays open while it waits for review? Maintainers, this one would be great to prioritize if you have a moment.

@github-actions github-actions Bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Aug 3, 2026
@github-actions

github-actions Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

@Yuxin-Qiao

Copy link
Copy Markdown
Author

Thanks for the heads-up and the offer to test! I updated the PR description to follow the template, and the bot confirmed it now meets the contributing guidelines. Appreciate the context on how the missing lifecycle events break Codex CLI turns end to end.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Go service /v1/responses returns HTTP 200 but emits an incomplete SSE event stream, breaking Codex-style clients

2 participants