Skip to content

Assemble multiline SSE data before decoding chat chunks - #706

Draft
Kayvan-Zahiri wants to merge 1 commit into
pinecone-io:mainfrom
Kayvan-Zahiri:codex/assemble-multiline-chat-sse
Draft

Kayvan-Zahiri wants to merge 1 commit into
pinecone-io:mainfrom
Kayvan-Zahiri:codex/assemble-multiline-chat-sse

Conversation

@Kayvan-Zahiri

Copy link
Copy Markdown

Problem

Both assistant chat endpoints parse each SSE data: line as a complete JSON object. A valid event with JSON spread across multiple data fields raises orjson.JSONDecodeError in both synchronous and asynchronous clients. This was reproduced with replayed HTTP responses, not observed against a hosted assistant.

Solution

Share a small event-data assembler across the four parsers. Join data fields with newlines and decode only after an event boundary, ignoring non-data fields and comments. Preserve the existing final-event-at-EOF compatibility and [DONE] handling. Completed events are yielded immediately without reading the next event.

The event framing follows the SSE interpretation rules; the existing EOF compatibility is intentionally retained.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)

Test Plan

  • Four public-client regressions fail before the fix (both endpoints × sync/async).
  • 604 focused chat conformance, assistant-model, streaming parity, and SSE tests pass after the fix.
  • Coverage includes multiple events, comments and other fields, empty data, single-space handling, EOF, and incremental delivery.
  • Ruff lint/format checks and Mypy on all three changed source modules pass.
  • A broader unit run was interrupted: native gRPC tests require the unbuilt Rust extension, and interruption affected a retry-storm test. It is not claimed as passing. No hosted API requests were made.

This branch has not been deployed

No deployments
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