Skip to content

Add SSE event type and id support to _convert_to_sse #265

@ian-norris-ncino

Description

@ian-norris-ncino

Is your feature request related to a problem? Please describe.
convert_to_sse only emits data: lines. Consumers can't distinguish event types without parsing the JSON
payload, and there's no support for resumable streams via the SSE id field.

Describe the solution you'd like
Add an SseEvent dataclass with data, event, and id fields. When _convert_to_sse receives an SseEvent, it
emits the appropriate event: and id: lines. Plain values still produce data:-only frames — fully
backward-compatible.

Describe alternatives you've considered

  • Tuple convention ((event_type, data)) — ambiguous since tuples could be legitimate data, and doesn't
    support optional fields like id.
  • Structured envelope dicts ({"event": "...", "data": ...}) — breaking change that moves SSE framing into
    the application layer.

Additional context
The SSE spec defines three frame fields: event, data, and id. Supporting event lets consumers route on
event type directly. Supporting id enables resumable streams via Last-Event-ID on reconnect. Documentation: https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#fields

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions