fix(mcp): honour deferred flag from transport_config - #794
Open
jaaacki wants to merge 1 commit into
Open
Conversation
Every MCP server was constructed with deferred: Some(false), so no tool was ever marked deferred. ToolSearch filters tool_defs on .filter(|d| d.deferred), so it always matched an empty set and returned "No deferred tools matching" regardless of query, tool count, or how the server was installed. aionrs supports the flag per server (McpServerConfig::deferred, defaulting to true when omitted) and registers ToolSearchTool unconditionally, so the feature was reachable in the engine but never enabled by the host. Read the flag from the same transport_config JSON that command/args/env/url/ headers already come from. An absent key still yields false, so existing behaviour is unchanged; an explicit true opts a server in. Scoped to row_to_mcp_server_config (DB-configured servers). Session-scoped and internal team servers are left as-is. Refs iOfficeAI#793
17 tasks
Author
|
Heads-up: the CI workflow on this PR is sitting at
No |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #793.
Problem
ToolSearchcan never return a result.crates/aion-tools/src/tool_search.rsfilters on.filter(|d| d.deferred), but every MCP server is built withdeferred: Some(false), so the set is always empty — whileaionrsstill registersToolSearchToolunconditionally (crates/aion-agent/src/bootstrap.rs:361) and the system prompt still tells the model that deferred tools exist.Models that follow that instruction loop on it. Measured across ~20 sessions on 2.1.50: glm-5.2 made 204 ToolSearch calls for 17 real tool calls; gpt-5.5 made 0.
aionrssupports the flag per server (McpServerConfig::deferred, defaulting totruewhen omitted) and honours it incrates/aion-mcp/src/tool_proxy.rs:135. The capability is fully implemented in the engine — the host just never lets a value through.Change
Read
deferredfrom the sametransport_configJSON thatcommand/args/env/url/headersalready come from:and use it in the three
McpServerConfigconstructions insiderow_to_mcp_server_config.false, so current behaviour is byte-identical for every existing server. Nothing is opted in implicitly.row_to_mcp_server_config(DB-configured servers).session_server_to_mcp_server_configtakes a typed transport enum with nowhere to carry the flag, andteam_mcp_to_configis an internal server where non-deferred looks intentional — both left untouched.Tests
Two added next to the existing
row_to_mcp_server_configtest:row_to_mcp_server_config_defaults_deferred_to_false— absent key staysfalserow_to_mcp_server_config_honours_explicit_deferred—"deferred": truecomes throughWhy it matters
With this, an operator can defer large MCP servers so their tools become name-only stubs retrievable through
ToolSearch, instead of every schema entering the system prompt on every turn. On a deployment with ~1,300 tools across 12 servers, that is the difference between a subset being reachable and all of them.Note
I don't have a Rust toolchain on this machine, so this has not been compiled or tested locally — the diff is mechanical and the tests reuse the existing
make_row/test_broadcasterhelpers, but please let CI confirm. Happy to adjust scope (e.g. plumb the flag through the session/team paths too) if you'd prefer.