Skip to content

Stamp a real freshness hint on cacheable results - #523

Merged
alistair3149 merged 2 commits into
masterfrom
cacheable-result-hints
Jul 30, 2026
Merged

Stamp a real freshness hint on cacheable results#523
alistair3149 merged 2 commits into
masterfrom
cacheable-result-hints

Conversation

@alistair3149

@alistair3149 alistair3149 commented Jul 30, 2026

Copy link
Copy Markdown
Member

Sets the SDK's cacheHints option so cacheable 2026-07-28 results (tools/list, resources/list, resources/templates/list, resources/read, server/discover) carry ttlMs: 60000, cacheScope: 'private' instead of the default ttlMs: 0. Everything cacheable changes only on a reconcile pass, and subscribed clients hear about that through listChanged events — the TTL only bounds staleness for clients that poll, and a stale entry is benign: the call it leads to still validates server-side. Private scope because the lists reflect the deployment's wiki configuration. Responses to pre-2026 clients are unaffected, and a test pins that.

To decide: the 60-second TTL. Longer would be defensible for mostly-static deployments; shorter mostly defeats the point.

Verified: an end-to-end test drives a real 2026-07-28 client against the era-routing handler and asserts the hint on tools/list, resources/list, and a resources/read result (written first, confirmed failing against the ttlMs: 0 default); full suite green. Smoke-tested over a real HTTP server from the built dist: a client pinned to 2026-07-28 sees ttlMs: 60000 / cacheScope: "private" on both list results.

🤖 Generated with Claude Code

Tool and resource lists, wiki resource reads, and discovery answers only
change when a reconcile pass runs, and subscribed clients learn of that
through listChanged events. Give them a 60-second ttlMs instead of the
default 0 so polling clients can cache between calls, with private scope
because the lists reflect this deployment's wiki configuration.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@alistair3149
alistair3149 force-pushed the cacheable-result-hints branch from 57a59e2 to d465ce8 Compare July 30, 2026 18:51
A resources/read result now asserts the per-operation hint — the one
operation where a per-registration hint would take precedence, so a
future registerResource cacheHint cannot silently shadow it. The
legacy-era test asserts hints stay off 2025-era responses.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@alistair3149
alistair3149 marked this pull request as ready for review July 30, 2026 18:56
@alistair3149
alistair3149 merged commit e7de46f into master Jul 30, 2026
1 check passed
@alistair3149
alistair3149 deleted the cacheable-result-hints branch July 30, 2026 18:56
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.

1 participant