Report MCP servers joining or leaving a run - #33
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Claude announces each change to the tool catalogue as an
attachmentrecord carryingdeferred_tools_delta. Nothing matched that record type, so it fell throughclaude()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
readdedNamesrepeatsaddedNamesrather 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.