Skip to content

fix: include http_request_id in request-wise priming event IDs#799

Open
DaleSeo wants to merge 3 commits intomainfrom
fix/priming-event-ids
Open

fix: include http_request_id in request-wise priming event IDs#799
DaleSeo wants to merge 3 commits intomainfrom
fix/priming-event-ids

Conversation

@DaleSeo
Copy link
Copy Markdown
Member

@DaleSeo DaleSeo commented Apr 10, 2026

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 a Last-Event-ID back to the originating stream. This moves priming event generation for request-wise streams into the session layer (LocalSessionManager::create_stream), where the http_request_id is available, so the priming event ID is now correctly formatted as 0/<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

SessionConfig has a new sse_retry: Option<Duration> field (defaults to Some(3s)). Since the struct is #[non_exhaustive], this is not a breaking change for downstream consumers.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

@github-actions github-actions bot added T-test Testing related changes T-core Core library changes T-transport Transport layer changes labels Apr 10, 2026
@DaleSeo DaleSeo force-pushed the fix/priming-event-ids branch from df297e0 to b881409 Compare April 10, 2026 01:05
@DaleSeo DaleSeo force-pushed the fix/priming-event-ids branch from b881409 to f15b728 Compare April 10, 2026 01:17
@DaleSeo DaleSeo marked this pull request as ready for review April 10, 2026 01:26
@DaleSeo DaleSeo requested a review from a team as a code owner April 10, 2026 01:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

T-core Core library changes T-test Testing related changes T-transport Transport layer changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Priming streamable http events use hardcoded event id of: "0"

1 participant