Skip to content

Expose session_id back to server when SSE connections are established #338

Open
@nimeshmc

Description

@nimeshmc

Is your feature request related to a problem? Please describe.
When a new SSE connection is established, I'm creating state specific to that session within my server. Requests coming into the /messages endpoint need to be able to access and modify the state created upon connection establishment. When a SSE connection is established, the SDK currently sends the session ID to the client, attached to the /messages URI. However, the server can't access this session ID right now without intercepting the streamed data.

Describe the solution you'd like
Expose the session ID for the SSE connection from the sse.connect_sse async context manager. Also expose the session ID to the request handlers.

Describe alternatives you've considered
Intercept the data being written to the outgoing stream to get the session ID from the endpoint event.
Doing something more contrived that involves introducing another primitive to duplicate what the session ID actually does, but is accessible to the server.

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