fix: don't abort a turn when one MCP session can't list tools#61
Merged
Conversation
usableTools returned an error if ANY mcpSession's ListTools/ListPrompts failed, so a single session that is momentarily unavailable (mid-reconnect, or being closed/rebuilt by a config reload — surfaced by the go-sdk as "client is closing: hanging GET: failed to reconnect") aborted the whole turn. This is what broke /learn in dante-desktop. Skip the unhealthy session for this turn and log a warning; its tools return once it is healthy again. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
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.
Problem
usableToolsbuilds the turn's tool list by callingListTools(and optionallyListPrompts) on every MCP session. If any one session fails, it returns an error that aborts the whole turn.When a session is momentarily unavailable — mid-reconnect, or being closed/rebuilt by a config reload — the go-sdk surfaces this as:
A single transiently-unhealthy session therefore kills an otherwise-fine turn. This is what broke
/learnin dante-desktop (its skills/config MCP client is rebuilt at turn start).Fix
Skip the unhealthy session for that turn (log a warning +
continue) instead of aborting. Its tools/prompts return on the next turn once the session is healthy again; other sessions are unaffected.guidelines.go— the tworeturn … fmt.Errorf(...)branches in theo.mcpSessionsloop becomexlog.Warn(...); continue.Tests
go build ./...clean;go vetclean; the guideline/tool/mcp test set passes.🤖 Generated with Claude Code