fix: include http_request_id in request-wise priming event IDs#799
Open
fix: include http_request_id in request-wise priming event IDs#799
Conversation
df297e0 to
b881409
Compare
b881409 to
f15b728
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #791
Motivation and Context
Priming events on POST request-wise SSE streams used a hardcoded event ID of
"0", making it impossible for clients to identify which stream to resume after disconnection. The MCP spec requires event IDs to encode enough information to correlate aLast-Event-IDback to the originating stream. This moves priming event generation for request-wise streams into the session layer (LocalSessionManager::create_stream), where thehttp_request_idis available, so the priming event ID is now correctly formatted as0/<http_request_id>(e.g.0/0,0/1). GET standalone and initialize priming remain unchanged at"0"since they have no per-request stream identity.Additionally, the event cache for a request-wise channel was discarded as soon as the response was delivered, so a client that disconnected and tried to resume after the tool call finished would find nothing to replay. The cache is now retained after completion, allowing late resume requests to replay cached events. Completed entries are evicted lazily when new channels are created.
How Has This Been Tested?
Added two integration tests.
Breaking Changes
SessionConfighas a newsse_retry: Option<Duration>field (defaults toSome(3s)). Since the struct is#[non_exhaustive], this is not a breaking change for downstream consumers.Types of changes
Checklist