Skip to content

vMCP backend revision cache has no success/TTL re-probe (stale on stateless redeploy) #5992

Closed

Description

@JAORMX

Part of #5743 / follow-up to the go-sdk v1.7 / MCP 2026-07-28 adoption (#5754). Surfaced by the Opus review panel.

Context

httpBackendClient caches each backend's negotiated MCP revision (probeRevision → setRevision). The cache self-corrects only on error (dispatch → isRevisionMismatch → reclassify), not on success and with no TTL.

The gap

If a backend is first probed Legacy (2025-11-25, stateful) and is later redeployed stateless/Modern (2026-07-28), the cache stays pinned Legacy indefinitely:

  • Wire behavior stays correct — the go-sdk v1.7 client's Connect is Modern-first and negotiates Modern transparently even on vMCP's "Legacy" code path (via server/discover), so calls still hit the right protocol. This is why it's not a correctness bug.
  • But CachedRevision (which feeds CRD status / telemetry read-models) reports Legacy forever — an operator-facing status inaccuracy — and every call pays the heavier per-call legacy initialize + discover + subscribe + Close handshake instead of using the lighter stateless path.

The reverse and dangerous direction — a Modern-cached backend redeployed stateful/Legacy — is self-corrected: discover now lacks 2026-07-28 → errModernNegotiatedDown → isRevisionMismatch (Modern arm) → reclassify → Legacy. So only the Legacy→Modern transition is left stale.

Proposed fix

Add a TTL-based re-probe (or success-path re-validation) to the revision cache so a redeployed backend's revision is refreshed, correcting both the telemetry/status inaccuracy and the per-call handshake overhead. The code already carries a NOTE deferring this.

Also worth a test

The "stale Legacy cache is harmless" property is currently pinned only for ListCapabilities (forwarding=false). The forwarding CallTool path (WithContinuousListening standalone GET stream) against a real stateless Modern backend is untested — low risk, but the harmlessness claim is asserted more broadly than it's covered.

Generated with Claude Code

Activity

  1. self-assigned this
    on Jul 25, 2026
  2. added
    needs-triage
    on Jul 25, 2026
  3. removed
    needs-triage
    on Jul 27, 2026
  4. JAORMX commented on Aug 4, 2026

    @JAORMX
    CollaboratorAuthor

    Current state of this issue after the go-sdk v1.7 adoption work: mostly obsolete, with one narrow residual gap.

    What's already fixed (issue's premises are stale)

    The issue predates the in-band self-heal that shipped in legacyInit (pkg/vmcp/client/client.go:1507-1536, with TestListCapabilities_MisCachedLegacy_SelfHealsViaSDKNegotiation and TestLegacyInit_SelfHealsRevisionCache):

    • A Legacy-cached backend redeployed genuinely Modern self-heals in-band: the go-sdk client negotiates Modern on the Legacy path, legacyInit reads the negotiated version off every initialize, and — gated by a confirming probeRevision — flips the cache. Both the wire behavior AND the status/telemetry read-model (CachedRevision → health monitor → CRD status) correct themselves on the next call.
    • The "also worth a test" half shipped: TestCallTool_MisCachedLegacy_ForwardingAgainstStatelessBackend covers the forwarding CallTool path against a real stateless Modern backend.

    So the indefinite-stale-Legacy scenario the issue describes only survives in one narrow shape:

    The residual gap: modernHintRefuted is permanent

    A backend that lied once — negotiates 2026-07-28 on the Legacy initialize but answers server/discover with a Legacy-shaped body (github-mcp-server v1.6.0 is the field example, #6154) — gets recorded in modernHintRefuted so the confirming probe runs once rather than on every call. That memory is never evicted. If such a backend is later redeployed as a genuinely Modern backend (hint and discover now agree), the refuted flag skips the confirming probe forever and the cache stays Legacy.

    Impact is bounded: wire behavior stays correct (SDK negotiates Modern transparently on the Legacy path — same harmlessness argument as the original issue), but CachedRevision reports Legacy indefinitely and every call pays the heavier handshake.

    Options

    1. TTL or cap the refutation memory — re-allow the confirming probe periodically (e.g. once per N minutes per backend) instead of never. A lying backend then costs one extra probe per window instead of per call; a redeemed backend self-heals within one window. Small, targeted change in legacyInit.
    2. Clear the refutation on any successful Modern discover — no new machinery: if a later probe (driven by dispatch's reclassify path) ever returns Modern, drop the flag. Doesn't fully close the gap (nothing drives that probe while the flag suppresses it) unless paired with (1).
    3. Close as acceptable — bounded harm (status accuracy + handshake weight, not correctness), and the 2026-07-28 adoption makes the lying-backend population shrink over time.

    My recommendation: option 1 — it's ~15 lines and removes the last unbounded staleness in the revision cache. Happy to implement if that sounds right.

  5. added a commit that references this issue on Aug 5, 2026
    63a0a9b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions