Skip to content

fix: don't abort a turn when one MCP session can't list tools#61

Merged
mudler merged 1 commit into
mainfrom
fix/learn-mcp-resilience
Jul 4, 2026
Merged

fix: don't abort a turn when one MCP session can't list tools#61
mudler merged 1 commit into
mainfrom
fix/learn-mcp-resilience

Conversation

@localai-bot

Copy link
Copy Markdown
Collaborator

Problem

usableTools builds the turn's tool list by calling ListTools (and optionally ListPrompts) 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:

failed to get MCP tools: connection closed: calling "tools/list": client is closing: hanging GET: failed to reconnect

A single transiently-unhealthy session therefore kills an otherwise-fine turn. This is what broke /learn in 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 two return … fmt.Errorf(...) branches in the o.mcpSessions loop become xlog.Warn(...); continue.

Tests

go build ./... clean; go vet clean; the guideline/tool/mcp test set passes.

🤖 Generated with Claude Code

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]>
@mudler mudler merged commit 028ba66 into main Jul 4, 2026
2 of 3 checks passed
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.

2 participants