Repository navigation
Conversation
Contributor
|
This pull request is awaiting maintainer assignment. Linked PRs stay open while maintainers triage the issue; this check remains failing until assignment. Per CONTRIBUTING.md, an external PR must reference an issue that's assigned to its author. To get there:
Once you're assigned and the link is present, this check is re-run automatically. Previously gate-closed PRs also reopen — no further action needed. Maintainers: reopen this PR or remove the |
Generated with AI assistance (GLM agent).
BlueX888
force-pushed
the
fix/prep-caching-call-tool-session-state-leak
branch
from
October 8, 2026 10:15
cd56de8 to
bdb0257
Compare
Collaborator
|
Closing with #5574: sessions without a token sharing a cache partition is the intended behavior. |
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.
Description
ResponseCachingMiddlewarepartitioned its cache entries by the caller's access token, but not by MCP session. Session-scoped state is per-session by contract —Context.set_state/get_statekey it by session id — so with the middleware installed, a second session'stools/callwas served the first session's cached answer even after it had stored its own value, and likewise forresources/read/prompts/gethandlers that read state. The token partition added for #4037 stopped one user's filtered view reaching another user; this was the same defect one level down, inside a single token partition.The
tools/call,resources/read, andprompts/getcache keys now also mix in the session's established id, resolved by a newContext._established_session_idthat followssession_id's resolution order without its generate-and-cache tail — so transports with no stable session identity keep sharing a session-less partition instead of losing the cache entirely. List methods keep their per-token key: list handlers never observe session state.Testing, on main @ 0ebabc0: the new
TestSessionAwareCachingregression tests fail without the change (assert 'session-a-secret' == 'session-b-secret') and pass with it;uv run pytest tests/server/middleware/test_caching.py→ 80 passed;uv run pytest tests/server/ tests/tasks/→ 4160 passed with 8 pre-existing proxy-network failures that fail identically on unchanged main;uv run prek run --all-files→ all enforced checks pass.Closes #5574
Generated with AI assistance (GLM agent); found through local code inspection and reproduction.
Contribution type
Checklist
uv run prek run --all-filesand all checks pass