[BUG] Named teammates (Agent name:) get the turn-start tool pool and miss MCP servers that connect later in the turn

Status Open
Reported on v2.1.287
Maintainer reply None cached
Activity 0 comments · opened Oct 2, 2026

Version: 2.1.287 (macOS, native build)

Bug

When the Agent tool is called with name (an in-process teammate), the teammate's tools come from toolUseContext.rootToolSurface.tools. That pool is captured once, when the main session starts processing the current turn (_buildToolUseContextWith → rootToolSurface:{tools: computeToolPoolFresh().tools, …}). The main loop's mid-turn MCP refresh (tengu_mcp_tools_refreshed_mid_turn) only replaces options.tools, never rootToolSurface. The teammate gets no refreshTools either, so the stale pool lasts for the teammate's whole life.

At startup the first turn begins while MCP servers are still pending. So any named teammate spawned in that turn gets no tools from servers that connect later, even minutes later:

  • Its deferred-tools list lacks them.
  • ToolSearch select:mcp__<server>__<tool> returns "No matching deferred tools found".
  • Its MCP instructions block, which is built from the live mcpClients, still describes those servers. The agent is told about servers it cannot reach.

Unnamed subagents are not affected. They build their pool from live appState.mcp.tools at spawn (assembleToolPool(…getAppState().mcp.tools…)). requiredMcpServers does not help either, because its wait and check run after the spawnTeammate branch.

Repro

  1. Configure a few stdio/http MCP servers.
  2. Run claude "In one message spawn two Agents: one with no name, one with name 'probe' and run_in_background true. Each runs ToolSearch select:mcp__<server>__<tool> and reports found or not found."
  3. The unnamed agent finds the tool. The named one does not. The named one still misses it when spawned minutes later in the same turn, after /mcp shows every server connected.
  4. Spawn the named agent from a second turn instead: it finds the tool.

Expected

Named teammates resolve tools from live MCP state at spawn, as unnamed subagents do, and ideally wait for pending servers.

Suggested fix

  • Smallest: in the in-process teammate runner, derive availableTools from live state, as the subagent path does via assembleToolPool, instead of u.rootToolSurface.tools.
  • Alternative: refresh rootToolSurface alongside options.tools in the mid-turn refresh. This is wider, because other readers use it.

View original on GitHub ↗