Skip to content

fix(dispatcher): advance mint counter past caller-supplied IDs (#3126) - #3237

Open
elang2 wants to merge 1 commit into
modelcontextprotocol:mainfrom
elang2:fix/dispatcher-id-collision
Open

fix(dispatcher): advance mint counter past caller-supplied IDs (#3126)#3237
elang2 wants to merge 1 commit into
modelcontextprotocol:mainfrom
elang2:fix/dispatcher-id-collision

Conversation

@elang2

@elang2 elang2 commented Aug 3, 2026

Copy link
Copy Markdown

Summary

  • When a caller supplies an integer request ID, eagerly advance _next_id to max(_next_id, supplied_id) in both JsonRpcDispatcher and DirectDispatcher
  • Prevents minted IDs from colliding with previously-completed caller-supplied IDs (spec requires IDs MUST NOT be reused within a session)
  • Minimal 2-line fix per dispatcher — no behavioral change for string-only IDs

Test plan

  • 4 new regression tests (2 per dispatcher via pair_factory parametrization)
  • All 894 tests pass
  • Covers both in-flight and completed caller-supplied ID scenarios

Fixes #3126

…ontextprotocol#3126)

When a caller supplies an integer request ID via CallOptions["request_id"],
advance the monotonic mint counter past it so future auto-minted IDs never
collide with a previously-used supplied ID. This satisfies the JSON-RPC spec
requirement that request IDs MUST NOT be reused within the same session.

Applied to both JSONRPCDispatcher and DirectDispatcher.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 3 files

Re-trigger cubic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dispatcher mints a request id already used by a completed caller-supplied request (spec: ids MUST NOT be reused in a session)

1 participant