Skip to content

fix(vmcp): keep session tool map on partial backend sweep - #7192

Open
HankGrimm wants to merge 1 commit into
stacklok:mainfrom
HankGrimm:fix/vmcp-partial-tool-resync
Open

HankGrimm wants to merge 1 commit into
stacklok:mainfrom
HankGrimm:fix/vmcp-partial-tool-resync

Conversation

@HankGrimm

Copy link
Copy Markdown

Summary

Fixes #6829.

When a backend flips unhealthy⇄healthy, resyncSessionsOnBackendHealthChange fans a tools resync out to every live session, and resyncSessionTools replaces the session's tool store with the freshly aggregated set. Best-effort aggregation logs and continues on a per-backend query failure, so if a still-healthy backend fails its capability query mid-sweep (transient timeout/401), its tools are silently omitted from the re-derived set — and the replacement drops them from the session until the next health transition (-32602 tool not found).

Change

  1. AggregationMetadata.Partial reports whether the sweep was incomplete (at least one backend in the set failed its live query), set in AggregateCapabilities as len(capabilities) < len(backends).
  2. core.Discover surfaces it via DiscoverCapabilities.Partial, from the same aggregatedView the List* methods read.
  3. resyncSessionTools keeps the existing tool store when the sweep was partial, instead of replacing it — the next health change or backend-notification resync retries with a fresh sweep.

Discover and ListTools share the capability cache key (identity + forwarded headers + health-filtered backend set), so the partial flag Discover reports comes from the same aggregation ListTools reads for the re-derived set.

Tests

  • TestDefaultAggregator_AggregateCapabilities_Partial — a sweep where one backend fails is reported partial; a complete sweep is not.
  • TestResyncSessionTools_KeepsExistingToolsOnPartialSweep — a partial sweep leaves the existing tool store untouched (no SetSessionTools call).

🤖 Generated with Claude Code

A health-driven (or list_changed) session resync re-derives the advertised
tool set and REPLACES the session's tool store with it. When a backend that
is still considered healthy fails its live capability query mid-sweep,
best-effort aggregation omits that backend's tools, so the replacement would
drop them until the next health transition (stacklok#6829).

Report sweep completeness from the aggregator (AggregationMetadata.Partial),
surface it through core.Discover, and have resyncSessionTools keep the
existing tool store when the sweep was partial — the next health change or
backend-notification resync retries with a fresh sweep.

Co-Authored-By: Claude Code <noreply@anthropic.com>
@HankGrimm
HankGrimm force-pushed the fix/vmcp-partial-tool-resync branch from 801bf5b to 8b6d70e Compare November 21, 2026 12:19

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant