Repository navigation
fix(server): omit cache hints for legacy peers - #1470
Conversation
|
@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. |
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. |
jokemanfire
left a comment
There was a problem hiding this comment.
Verified at 3e8ff9e by running the change, not from the description.
What I ran (Linux, 1.96)
cargo test -p rmcp --test test_result_type_wire --all-features— 13 passed, including the newstrip_removes_cache_hints_from_paginated_result.cargo test -p rmcp --test test_skills --features client,server— 16 passed, includinglist_skills_should_omit_cache_hints_for_legacy_peersandlist_skills_should_keep_cache_hints_the_handler_set_for_2026_07_28.- Note for anyone reproducing:
test_skills.rsstarts with#![cfg(not(feature = "local"))], so--all-featurescompiles it to 0 tests. The case you care about runs in thetest-no-localjob (cargo test -p rmcp --features "$FEATURES"withlocalremoved), which is what I approximated.
- Note for anyone reproducing:
cargo test -p rmcp --doc --all-features strip_cache_hints— the new doctest passes, so the example in the doc comment is real and not just prose.
Red without the production change — I deleted the result.strip_cache_hints_for_legacy_peer(); call at crates/rmcp/src/handler/server.rs:322 and reran the skill tests: list_skills_should_omit_cache_hints_for_legacy_peers fails with
left: (Some(60000), Some(Public))
right: (None, None)
and the other 15 still pass, so the test pins this call specifically and not something upstream of it. Restored afterwards.
Symmetry check — strip_cache_hints_for_legacy_peer (crates/rmcp/src/model.rs:5141-5149) covers exactly the seven variants that fill_missing_cache_hints touches (:5239-5257): list tools/prompts/resources/resource templates, read resource, list skills, get skill. That is the right set today.
Suggestion (non-blocking): keep the two lists from drifting. Both functions re-spell the same seven-arm match, one returning (&r.result_type, &mut r.ttl_ms, &mut r.cache_scope) and the other (&mut r.ttl_ms, &mut r.cache_scope). A private fn cache_hint_fields(&mut self) -> Option<(&mut Option<u64>, &mut Option<CacheScope>)> (and a result-type accessor for the fill side) would make a future cacheable result impossible to fill but not strip. Cheap now, and this file already carries three near-identical matches.
PR body asks — "This affects every cacheable result, not just skills" is true of the match arms, but only ListToolsResult is exercised end-to-end; either say that the other six share the same arm, or make the wire test a small table over the variants. Also, the body has no linked issue: if this was found while reviewing something else, one line naming it is enough, since it is a wire-shape fix that belongs in the changelog.
The behaviour itself I agree with: the hints did not exist before 2026-07-28, and dropping them for an older peer follows the precedent already set by strip_result_type_for_legacy_peer and strip_non_object_output_for_legacy_peer.
Motivation and Context
The 2026-07-28 branch fills missing hints, but the older branch had no counterpart that removes explicit ones. This affects every cacheable result, not just skills.
How Has This Been Tested?
Added tests
Breaking Changes
None.
Types of changes
Checklist