Skip to content

Stream plain answer text as it arrives - #22

Merged
defcron merged 1 commit into
mainfrom
codex/stream-progressive-text
Nov 17, 2026
Merged

defcron merged 1 commit into
mainfrom
codex/stream-progressive-text

Conversation

@defcron

@defcron defcron commented Nov 17, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Emit ordinary answer text as soon as upstream snapshots arrive instead of waiting for a newline.
  • Continue holding complete or split file-reference and citation markers for rich-output rendering.
  • Add real-socket regression coverage for progressive text on both Chat Completions and Responses streams.

Validation

  • Full coverage suite: 100% statements, branches, functions, and lines.
  • Focused streaming tests: 79 passed.
  • Worker tests: 10 passed.
  • Worker build/typecheck passed.

Summary by CodeRabbit

  • New Features
    • Chat responses can begin appearing before the full response has finished generating, providing a more progressive streaming experience.
  • Bug Fixes
    • Partial responses now handle references and other non-displayable content more carefully, reducing the chance that incomplete or internal text appears in the chat.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-17T02:32:45.789562Z 7a0b5f9 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@coderabbitai

coderabbitai Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

Explain Change →

Caution

Review failed

The pull request is closed.

Walkthrough

The streaming handler now emits text through a safe prefix before the upstream stream ends. It retains incomplete file-reference markers and private-use characters. Tests cover prefix boundaries and early delivery for Chat Completions and Responses.

Changes: Streaming Text Release

Layer / File(s) Summary
Safe-prefix detection
apps/server/src/openai.ts
The new safeStreamingTextLength function returns the earliest boundary before a complete or partial file-reference marker, or a private-use character. Otherwise, it returns the text length.
Stream emission and endpoint validation
apps/server/src/openai.ts, apps/server/tests/openai-routes.test.mjs, SHA256-MANIFEST.json
The streaming handler emits text through the safe boundary instead of waiting for a newline or withholding text from [ onward. Tests cover boundary cases and early delivery for both endpoints. The manifest hashes are updated.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant UpstreamStream
  participant StreamingHandler
  participant safeStreamingTextLength
  participant Client
  UpstreamStream->>StreamingHandler: Send assistant text snapshot
  StreamingHandler->>safeStreamingTextLength: Find safe text boundary
  safeStreamingTextLength-->>StreamingHandler: Return boundary
  StreamingHandler->>Client: Emit safe text prefix
  UpstreamStream->>StreamingHandler: Send remaining events and completion
  StreamingHandler->>Client: Emit completion event
Loading
Merge Risk: High · up to 7a0b5

Streaming answers that contain a file download link can fail midway when an upstream update ends inside the link, after part of the answer has already been sent. Hold unclosed Markdown links until the destination is complete, and add a two-snapshot test for both endpoints, before merging.

- [ ] Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7a0b5f9780

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread apps/server/src/openai.ts
Comment on lines +503 to +505
const privateMarker = text.search(/[\uE000-\uF8FF]/);
if (privateMarker >= 0) boundary = Math.min(boundary, privateMarker);
return boundary;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Hold unfinished Markdown links before emitting their labels

When an upstream snapshot ends with Here is [report]( and a later snapshot appends sandbox:/mnt/data/report.csv), this helper emits the entire first snapshot because it contains no recognized marker. Once the destination arrives, renderRichOutput replaces the whole Markdown link with Download file: [report.csv](...), including the already-emitted label. Consequently, remainingStreamText throws Upstream changed text already delivered to the client, terminating both Chat Completions and Responses streams instead of delivering the download. The previous bracket guard prevented this case; retain unfinished link syntax until its destination is known rather than buffering only the pointer prefix.

Useful? React with 👍 / 👎.

@codecov

codecov Bot commented Nov 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@defcron
defcron merged commit 1a154d1 into main Nov 17, 2026
8 of 9 checks passed
@defcron
defcron deleted the codex/stream-progressive-text branch November 17, 2026 02:35
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.

2 participants