Repository navigation
Conversation
CachedTx::sync replayed the cache starting at the event named by Last-Event-ID, so the last event the client received was sent again on every resume. Replay only the events after it, as the EventStore path already does. The standalone GET stream's synthetic priming event has the fixed id 0, which the first cached common event also used. Start the common cache at 1 so that resuming from the priming event still replays every cached notification.
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Contributor
|
@michaelneale is on triage rotation this week and is the reviewer for this one. Labels come from the PR labeler. Please review the change. Automated triage. Labels are a first pass and the assigned maintainer has the final say. |
This branch has not been deployed
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.
This picks up the replay part of #1165, which was closed as stale, and answers its open review question about the standalone priming event.
Problem
CachedTx::syncreplayed the cache starting at the event named byLast-Event-ID, so that event was always delivered twice. The transports spec says the client sends the "last event ID it received" and the server replays messages "that would have been sent after the last event ID". TheEventStore::replay_events_aftercontract in this crate already says "strictly after". Only the default in-memory path (LocalSessionManagerwithout an event store) was off by one.On main, with the default config and a standalone GET carrying events
0,1,2: resuming from1replays1and2, and resuming from2replays2. rmcp's own client and the TypeScript SDK client both resume with the id of the last event they processed, so every reconnect after a dropped connection re-delivers one message. That message can be a progress notification, a response, or a sampling/elicitation request, and it reaches the client a second time.Change
sync(index)now skips throughindexitself, so only later events are replayed.0. Before this change, the first cached notification also had id0, so a strict "after 0" would have skipped a notification the client never saw. With the cache starting at 1, resuming from the priming id0still replays every cached notification, anddead_primary_replacement_replays_cached_eventspasses unchanged. Request-wise streams already index their priming event, so they need no change.Last-Event-IDstill replays the whole retained common cache, as before. Without a cursor the server cannot tell what the client already has, so that stays out of scope here. The event-store path is unchanged.saturating_sub), as before. This PR only removes the off-by-one and leaves eviction behaviour alone.Tests
tests/test_sse_concurrent_streams.rs::resume_does_not_replay_the_last_event_id: receives a notification on the standalone stream, drops it, resumes with that notification's id, and asserts the notification does not come back. It fails on main (Last-Event-ID 0 was already delivered and must not be replayed) and passes with the fix.session::local::resume_tests::resume_replays_only_events_after_last_event_id: a request-wise cache holding0/3,1/3,2/3resumed from1/3. On main it replays["1/3", "2/3"]; with the fix it replays["2/3"].test_sse_concurrent_streamspasses 18/18 (17/18 on main).test_streamable_http_priming(5),test_streamable_http_event_store(2),test_streamable_http_stale_session(4),test_streamable_http_reconnect_classification(10),test_streamable_http_disconnect_cancel(2),test_custom_headers(39),test_streamable_http_client_concurrency(20),test_streamable_http_limit_lifecycle(10),test_sep_2260_stream_enforcement(2),test_sep_2260_stream_routing(1),test_inflight_response_drain(2) and thermcplib tests (440 with the streamable HTTP client and server features) pass on macOS arm64.cargo fmt --checkis clean.AI disclosure: this PR was written with Claude Code (claude-opus-5-5): the investigation, the fix, the tests and this description. The test results above are from the runs described.