Skip to content

fix(streaming): Ensure final partial=False frame is always yielded#6096

Open
xuanyang15 wants to merge 1 commit into
google:v1from
xuanyang15:import-3754-fix-to-v1
Open

fix(streaming): Ensure final partial=False frame is always yielded#6096
xuanyang15 wants to merge 1 commit into
google:v1from
xuanyang15:import-3754-fix-to-v1

Conversation

@xuanyang15

Copy link
Copy Markdown
Collaborator

The StreamingResponseAggregator.close() method previously returned None if it didn't accumulate text or parts, such as for safety blocks or pure function calls. This caused clients (e.g., Vertex AI Reasoning Engine) to hang indefinitely waiting for a partial=False termination frame, and caused loops to break prematurely.

This fix ensures close() always returns a final LlmResponse(partial=False) as long as a response exists, carrying over any error_code, error_message, and usage_metadata, regardless of whether PROGRESSIVE_SSE_STREAMING is enabled. Added parameterized unit tests to verify behavior across both streaming modes.

This is to import cd81f7b to v1 branch.

The `StreamingResponseAggregator.close()` method previously returned `None` if it didn't accumulate text or parts, such as for safety blocks or pure function calls. This caused clients (e.g., Vertex AI Reasoning Engine) to hang indefinitely waiting for a `partial=False` termination frame, and caused loops to break prematurely.

This fix ensures `close()` always returns a final `LlmResponse(partial=False)` as long as a response exists, carrying over any `error_code`, `error_message`, and `usage_metadata`, regardless of whether `PROGRESSIVE_SSE_STREAMING` is enabled. Added parameterized unit tests to verify behavior across both streaming modes.
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.

1 participant