Repository navigation
Replies: 1 comment 1 reply
|
Thanks again for such a clear write-up of this, @chagwood! For anybody who finds this later: I went the per-request route instead of a general size limit (I wrote up why over on #385), and that change is in #387.
This will be in the next release, which should be out sometime in the next few days. |
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
The problem
Nothing limits how much text an MCP tool returns.
search_simplereturns every match in every matching file, and Obsidian's simple search matches each query word separately, so a query made of common words over an ordinary vault can come back as megabytes of JSON.I hit this with Open WebUI 0.11.4 and a local model with a 262,144-token context window. A single
search_simplecall ("SSH rejects the fleet key",contextLength: 120) returned 9 files and 3,159 matches, about 1.4 MB of JSON (on the order of 350k tokens). That one result was bigger than the model's whole context window. The next request failed withprompt (524094 tokens) leaves no room to answer in the context (262144). Because the result is saved in the chat history, every retry failed the same way, and the conversation was unrecoverable after two user turns.The client can't handle this today. Open WebUI has no limit on tool output size (open-webui#30110), and its context compaction never runs between tool calls inside a single answer (open-webui#27599). Lowering
contextLengthdoesn't help much either, because the number of matches stays the same.Proposal
An opt-in Advanced settings → Maximum MCP tool result size (characters) setting, off (0) by default:
McpHandler.text(), so it covers every text-returning MCP tool, including tools that extensions add. The REST API isn't affected.[Result truncated: ...], giving the original size and suggesting how to narrow the request.I've opened a PR with an implementation, tests, and docs so there's something concrete to look at: #385. I'm happy to rework it, or move it into an extension, if you'd rather take a different direction, for example a per-request
limit/maxMatchesPerFileonsearch_simpleinstead of a setting, or as well as one.All reactions