Skip to content

fix(server): omit cache hints for legacy peers - #1470

Merged
DaleSeo merged 3 commits into
mainfrom
DaleSeo/legacy-cache-hints
Nov 20, 2026
Merged

DaleSeo merged 3 commits into
mainfrom
DaleSeo/legacy-cache-hints

Conversation

@DaleSeo

@DaleSeo DaleSeo commented Nov 17, 2026 •

Copy link
Copy Markdown
Member

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

  • 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-handler Handler implementation changes labels Nov 17, 2026
@github-actions

Copy link
Copy Markdown
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.

@DaleSeo
DaleSeo marked this pull request as ready for review November 17, 2026 15:23
@DaleSeo
DaleSeo requested a review from a team as a code owner November 17, 2026 15:23
@DaleSeo DaleSeo self-assigned this Nov 17, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-19T20:41:47.883956Z 38b06b4 New commits
🔒 Security Review ✅ Completed 2026-11-19T20:43:25.718477Z 38b06b4 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@jokemanfire jokemanfire left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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 new strip_removes_cache_hints_from_paginated_result.
  • cargo test -p rmcp --test test_skills --features client,server — 16 passed, including list_skills_should_omit_cache_hints_for_legacy_peers and list_skills_should_keep_cache_hints_the_handler_set_for_2026_07_28.
    • Note for anyone reproducing: test_skills.rs starts with #![cfg(not(feature = "local"))], so --all-features compiles it to 0 tests. The case you care about runs in the test-no-local job (cargo test -p rmcp --features "$FEATURES" with local removed), which is what I approximated.
  • 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.

@DaleSeo
DaleSeo requested a review from jokemanfire November 19, 2026 20:43

@tsarlandie-oai tsarlandie-oai left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM.

@DaleSeo
DaleSeo merged commit 459cb4f into main Nov 20, 2026
24 checks passed
@DaleSeo
DaleSeo deleted the DaleSeo/legacy-cache-hints branch November 20, 2026 01:34
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-handler Handler implementation changes T-test Testing related changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants