Repository navigation
Studio: list large MCP tool schemas compactly and load the full schema on demand - #11046
Conversation
… schema, page mcp_tool_schema
|
This rewrites the description and parameter schema that large MCP tools present to the model, which changes what the model reads on every turn, and drops enums and nested properties from the listing. Could you confirm tool-call accuracy on a compacted server such as Notion against the current full listing before I review? |
|
I measured it, and the compacted listing does cost tool-call accuracy on Notion. Setup: upstream
A correct call has the right tool, arguments valid against the full schema, and the requested values. On the five tools that are not compacted, the first call was correct for 4/5 with the full listing and 5/5 with the compacted one, for both models. What goes wrong: the losses are the nested and union parameters the compact listing drops.
Neither model ever called Per-task results, the harness, tasks and scorer: https://github.com/NilayYadav/unsloth-staging/tree/evidence-pr11046/evidence/pr-11046/accuracy What this means for the PR: compacting unconditionally would make Notion worse for anyone whose context window already fits the full listing, so I'm changing the approach before asking for review:
I'll rerun the same 29 tasks against that change, including the compacted path, and post the numbers here. |
|
Follow-up to the numbers above. Pushed in ab222ac:
Same harness, tasks and Notion catalog as before, run on ab222ac: 100K context: the listing stays full. 64K context (65,536 tokens):
So the compacted path is still below the full listing, but it is only used when the full listing cannot be served at all. Returning the schema on a rejected call recovered most of the gap for 30B-A3B and some of it for 4B. Controls on uncompacted tools were 5/5 for both models. One greedy sample per task, as before. Per-task results: https://github.com/NilayYadav/unsloth-staging/tree/evidence-pr11046/evidence/pr-11046/accuracy |
# Conflicts: # studio/MCP.md # tests/studio/playwright_queue_localization.py
|
Thanks for the accuracy numbers and for limiting compaction to catalogs that would not otherwise fit. On the compacted path, Qwen3-4B still gets 48% of calls right against 76% with the full listing, so could you check whether keeping nested and union parameters for the most-used tools closes some of that gap before I review? |
# Conflicts: # studio/MCP.md
Some MCP servers expose tools with very large parameter schemas. Notion's 44-tool catalog adds about 65,000 tokens to every request, more than the whole context window of many local models, so a one word prompt is refused before the model sees it. This is the problem reported in #10997.
What changes
mcp_tool_schema, which returns a tool's full description and JSON Schema on demand, paged when it is longer than the room left for a tool result.Accuracy (Notion catalog, 29 single-action tasks, Q4_K_M, temperature 0)
Harness: a stdio stand-in serving Notion's real catalog that validates every call against the tool's real
inputSchema. main cannot serve these requests at 64K, so it is measured at 100K as the full-listing reference.At 64K on Notion, 5 of 44 tools are compacted when no tokenizer is loaded, and fewer when the loaded GGUF measures the listing exactly. On a 32K window 11 are compacted.
Tests
studio/backend/tests/test_mcp_servers.pycovers the full listing when it fits, compacting only the largest tools needed, the compact form, the summary, when the schema tool is offered, the missing argument and rejected call paths, argument typing by the full schema, and the schema tool itself (138 passed).Before / after in the chat UI
Notion's catalog connected through a local stdio stand-in, Qwen3-4B-Instruct-2507 Q4_K_M loaded at a 65,536-token window, same prompt on both sides. Before (merge base 7617fc3): the request is refused with "Message too long: 194720 tokens exceeds the 65536-token context window". After (2712645): the model calls Notion's keyword search and replies, with the context meter at 44.5k of 65.5k.