Skip to content

Report MCP servers joining or leaving a run - #33

Merged
pathscale merged 2 commits into
masterfrom
fix/report-mcp-tool-changes
Aug 19, 2026
Merged

pathscale merged 2 commits into
masterfrom
fix/report-mcp-tool-changes

Conversation

@pathscale

Copy link
Copy Markdown
Owner

Claude announces each change to the tool catalogue as an attachment record carrying deferred_tools_delta. Nothing matched that record type, so it fell through claude() to an empty vec and no event was ever emitted.

That silence is the problem. Measured on one AgencyZero session, a single connector flapped seven times, each drop taking 85 tools out of the catalogue and each recovery putting them back, with the session id unchanged and no terminal record throughout. The run was healthy the whole time, and a host watching for events saw nothing at all. A host with an idle watchdog cannot tell that from a run that has wedged, which is how a working turn gets torn down and reported to the user as a disconnect.

Event::ToolsChanged { added, removed, pending } reports it, so a host can keep such a run alive and collapse a flapping server into one line rather than one per change.

Two details the record's shape forces

readdedNames repeats addedNames rather than naming a third group, so counting both would double every recovery.

A delta that moves nothing is not reported. A server can announce itself as pending and settle without its catalogue ever changing, and a host redrawing on each such record would flicker for no reason.

Version

A patch. This adds an enum variant and changes no existing behaviour.

Tests

Two, both from records captured off claude 2.1.212: a server dropping and rejoining, and the empty-delta and non-tool-attachment cases staying quiet.

meh added 2 commits August 19, 2026 12:10
Claude announces each change to the tool catalogue as an `attachment`
record carrying `deferred_tools_delta`. Nothing matched that record type,
so it fell through `claude()` to an empty vec and no event was ever
emitted.

That silence is the problem. Measured on one AgencyZero session, a single
connector flapped seven times, each drop taking 85 tools out of the
catalogue and each recovery putting them back, with the session id
unchanged and no terminal record throughout: the run was healthy the whole
time and a host watching for events saw nothing at all. A host with an
idle watchdog cannot tell that from a run that has wedged.

`Event::ToolsChanged { added, removed, pending }` reports it, so a host can
keep such a run alive and collapse a flapping server into one line rather
than one per change.

Two details the shape of the record forces. `readdedNames` repeats
`addedNames` rather than naming a third group, so counting both would
double every recovery. And a delta that moves nothing is not reported at
all, because a server can announce itself as pending and settle without
its catalogue ever changing, and a host redrawing on each such record
would flicker for no reason.

A patch rather than a minor: this adds an enum variant and changes no
existing behaviour.
It reads the record and returns events without touching parser state, so
`&mut self` was unused and `clippy::unused_self` rejected it under
`-D warnings`. The neighbouring parsers take `&mut self` because they
genuinely mutate; this one does not, and an associated function says so.
@pathscale
pathscale merged commit ba93f6f into master Aug 19, 2026
1 check passed
@pathscale
pathscale deleted the fix/report-mcp-tool-changes branch August 19, 2026 05:23
@pathscale
pathscale restored the fix/report-mcp-tool-changes branch August 25, 2026 17:47
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