Skip to content

fix(agent): send final streaming message with isComplete flag after stream ends#1831

Open
Br1an67 wants to merge 1 commit intobytedance:mainfrom
Br1an67:fix/issue-833-streaming-complete
Open

fix(agent): send final streaming message with isComplete flag after stream ends#1831
Br1an67 wants to merge 1 commit intobytedance:mainfrom
Br1an67:fix/issue-833-streaming-complete

Conversation

@Br1an67
Copy link
Copy Markdown
Contributor

@Br1an67 Br1an67 commented Mar 1, 2026

Summary

Fixes #833

The OpenAI streaming API sends finishReason in a separate content-less chunk after the last content chunk. The streaming handler only set isComplete: true when both content and finishReason were present in the same chunk, which never happened. As a result, no assistant_streaming_message event with isComplete: true was ever emitted.

Changes:

  • Track whether any content was streamed via hasStreamedContent flag
  • After the stream loop completes, send a final assistant_streaming_message with isComplete: true when content was streamed and finishReason is set

This ensures the UI receives a proper stream completion signal.

Checklist

  • Added or updated necessary tests (Optional).
  • Updated documentation to align with changes (Optional).
  • Verified no breaking changes, or prepared solutions for any occurring breaking changes (Optional).
  • My change does not involve the above items.

When the LLM stream finishes, the finish_reason typically arrives in a
separate content-less chunk. Since we only send assistant_streaming_message
for chunks with content, the last streaming message always had
isComplete: false, causing the Web UI to appear stuck in streaming state.

Send a final assistant_streaming_message with isComplete: true after the
stream loop completes when content was streamed and finishReason is set.

Closes bytedance#833
@netlify
Copy link
Copy Markdown

netlify Bot commented Mar 1, 2026

Deploy Preview for tarko ready!

Name Link
🔨 Latest commit 8f12c5b
🔍 Latest deploy log https://app.netlify.com/projects/tarko/deploys/69a46e26acbe3d00085fd825
😎 Deploy Preview https://deploy-preview-1831--tarko.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify
Copy link
Copy Markdown

netlify Bot commented Mar 1, 2026

Deploy Preview for agent-tars-docs ready!

Name Link
🔨 Latest commit 8f12c5b
🔍 Latest deploy log https://app.netlify.com/projects/agent-tars-docs/deploys/69a46e264f9ca00008906b0b
😎 Deploy Preview https://deploy-preview-1831--agent-tars-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@Br1an67
Copy link
Copy Markdown
Contributor Author

Br1an67 commented Mar 8, 2026

Hi — just a gentle bump on this. Happy to make any changes if needed!

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 Report]: last chunk of assistant_streaming_message should be isComplete: true

1 participant