fix: avoid triggering toolset startup from emitToolsChanged callback#2323
Merged
dgageot merged 1 commit intodocker:mainfrom Apr 6, 2026
Merged
Conversation
emitToolsChanged uses a 5-second timeout context that races with slow toolset initialization (e.g. RAG file indexing). When an MCP server connects and fires OnToolsChanged before RAG finishes, the timeout causes a context deadline exceeded error and a spurious warning. Add Agent.StartedTools() that lists tools only from already-started toolsets without calling ensureToolSetsAreStarted(), and use it in emitToolsChanged so the callback never triggers initialization. Assisted-By: docker-agent
krissetto
approved these changes
Apr 4, 2026
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
When the TUI starts, RAG and MCP toolsets initialize concurrently. If an MCP server connects and fires
OnToolsChangedbefore RAG finishes file indexing,emitToolsChanged()creates a 5-second timeout context and callsCurrentAgentTools(), which triggersensureToolSetsAreStarted(). For projects with many files, RAG initialization exceeds 5 seconds, causing a spurious "context deadline exceeded" warning in the TUI.Fix
Add
Agent.StartedTools()that lists tools only from already-started toolsets without triggering initialization. Use it inemitToolsChanged()so the MCP callback never starts slow toolsets under a tight deadline. RAG continues to initialize normally through the startup path with a proper long-lived context.