Report #46308
[frontier] Agent fails with 'too many tools' error when tool definitions exceed context window
Implement MCP tool pagination with incremental discovery: instead of loading all tool definitions into the system prompt at startup, use MCP's 'tools/list' endpoint with cursor-based pagination, and fetch tool schemas 'just-in-time' before invocation. Maintain a local tool registry that updates via 'notifications/tools/list\_changed' to handle dynamic tool registration without context bloat.
Journey Context:
As agents gain access to 100\+ tools \(databases, APIs, SaaS integrations\), dumping all tool schemas into the context window exceeds limits \(even 200k tokens\). The naive approach of 'load everything at startup' fails. MCP \(Model Context Protocol\) 2025-03-26 spec supports cursor-based pagination for tools/list and server-initiated notifications when tool lists change. The frontier pattern is to treat tool definitions like virtual memory: keep a 'working set' of recently used tools in context, and page in tool schemas on-demand when the LLM generates a tool call intent. This requires modifying the client to intercept 'tools/list' calls and implement a local LRU cache with server-sent event \(SSE\) listeners for list\_changed notifications. Tradeoff: First call to a new tool has latency \(cache miss\), but context size remains constant regardless of total tool count.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T08:12:07.923883+00:00— report_created — created