Skip to content

fix(console): terminate converted chat streams - #43707

Closed
dajiaohuang wants to merge 1 commit into
anomalyco:devfrom
dajiaohuang:fix-stream-termination
Closed

dajiaohuang wants to merge 1 commit into
anomalyco:devfrom
dajiaohuang:fix-stream-termination

Conversation

@dajiaohuang

Copy link
Copy Markdown

Issue for this PR

Closes #43379

Type of change

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

What does this PR do?

The Responses-to-Chat stream converter emitted a final Chat Completions chunk with finish_reason null when the upstream Responses stream ended with response.completed, then closed without the Chat SSE [DONE] terminator.

This change treats that explicit completion event as terminal, preserving known provider stop reasons and otherwise choosing tool_calls when the completed response contains a function call or stop for text output. It appends [DONE] only for completed OpenAI Responses streams converted to OpenAI-compatible Chat Completions. It does not infer completion from a bare EOF.

How did you verify your code works?

  • bun test test/openai-stream.test.ts (3 pass)
  • bun typecheck (packages/console/app)
  • oxlint on the three changed files (0 errors)
  • git diff --check
  • The full console-app suite also has two unrelated existing Google usage assertions expecting outputTokens 3 while current dev returns 5.

Screenshots / recordings

N/A - server-side streaming fix.

Checklist

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

@github-actions

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

Potential Duplicate Found

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

Why it's related: This PR addresses a similar issue with the Responses-to-Chat stream converter, specifically handling the SSE lifecycle for converted streams. Both PRs focus on properly terminating and completing chat stream conversions, though this one (PR #40210) appears to be an earlier or related attempt at fixing stream termination behavior.

@github-actions

Copy link
Copy Markdown
Contributor

Automated PR Cleanup

Thank you for contributing to opencode.

Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions.

This PR was closed because it matched the following cleanup criteria:

  • The PR was created more than 1 month ago
  • The PR had fewer than 2 positive reactions
  • Positive reactions are counted as thumbs-up, heart, celebration, or rocket reactions on the PR

PRs created within the last month are not affected by this cleanup.

If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate.

Thanks again for taking the time to contribute.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Streaming responses for muse-* models on the Zen gateway never send finish_reason — strict OpenAI-compatible clients enter a retry loop

1 participant