Description
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.