Skip to content

[Story] Threshold gate and Task.attachedMcpToolNames #578

Open

Description

@edelauna

Context

This wires `ToolRouter` (#577) into the task build path: when the scoped MCP tool count exceeds a threshold, only the top-K tools ranked by the initial task text are injected into the API call. The `mcp_load` escape hatch (#579) is added in the next story; this story establishes the data structure and the gate.

Depends on #577. Part 1 of 2 — see also #579.

Partially closes: RooCodeInc/Roo-Code#11990.

Developer Notes

  • Add `attachedMcpToolNames: Set` to `Task` state (persisted with task history so the set survives re-attach).
  • In `src/core/task/build-tools.ts`: after `getMcpServerTools()` produces `mcpTools`, check `mcpTools.length` against `mcp.dynamicLoad.threshold` (new setting, default 50; replaces the existing `MAX_MCP_TOOLS_THRESHOLD = 60` in `packages/types/src/mcp.ts`).
    • Under threshold: existing path unchanged.
    • Over threshold: call `ToolRouter.attachInitial(taskText, scopedTools, initialK)`, initialise `Task.attachedMcpToolNames`, filter the API `tools` array to only attached names.
  • Add setting `mcp.dynamicLoad.initialK` (default 30).
  • Remove the `too_many_tools_warning` block from `src/core/task/Task.ts:1811` — the new flow supersedes it (the UI replacement comes in [Story] Replace TooManyToolsWarning with DynamicToolsStatus indicator #581).

Acceptance Criteria

  • `Task.attachedMcpToolNames` persisted and restored on re-attach
  • Under threshold: API tools array unchanged
  • Over threshold: API tools array contains only attached tools + native tools (no `mcp_load` yet — that's [Story] mcp_load native tool (dynamic tool attachment escape hatch) #579)
  • `too_many_tools_warning` message removed from Task
  • New settings `mcp.dynamicLoad.threshold` and `mcp.dynamicLoad.initialK` registered in schema
  • Integration test: 100 mock MCP tools → initial API call has ≤ initialK MCP tools + native tools

Activity

  1. changed the title [-][Story] W1.4a — Threshold gate and Task.attachedMcpToolNames[/-] [+][Story] Threshold gate and Task.attachedMcpToolNames[/+] on Jun 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions