Skip to content

[code mode] defer mcp tools from exec description#17287

Draft
sayan-oai wants to merge 6 commits intodev/sayan/namespace-refactor-2from
dev/sayan/code-mode-deferred-tool-guidance
Draft

[code mode] defer mcp tools from exec description#17287
sayan-oai wants to merge 6 commits intodev/sayan/namespace-refactor-2from
dev/sayan/code-mode-deferred-tool-guidance

Conversation

@sayan-oai
Copy link
Copy Markdown
Collaborator

WIP

in non-code-mode, all MCP tools (custom and app-contributed) are hidden behind tool_search now to avoid context bloat.

In code_mode_only however, all tools, including MCP tools, are added to the description of the exec tool, causing bloat.

This change hides them from the description but keeps them in ALL_TOOLS and as runtime-callable. It adds instructions telling the model to write code to search over ALL_TOOLS to find the MCP tools it wants.

Will explore adding a searchTools() fn to code mode as a more polished version (so the model doesn't have to write code every time), as the normal responsesapi one is not present in code mode.

Tests

added regression test, testing locally.

Comment on lines +287 to +295
let call = if let Some(mcp_tool_call) = tool_runtime.resolve_mcp_tool_call(&tool_name).await {
match serialize_function_tool_arguments(&tool_name, input) {
Ok(raw_arguments) => ToolCall {
tool_name: mcp_tool_call.dispatch_name,
call_id,
tool_namespace: mcp_tool_call.dispatch_namespace,
payload: ToolPayload::Mcp {
server: mcp_tool_call.tool_info.server_name,
tool: mcp_tool_call.tool_info.tool.name.to_string(),
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we have to do this because directly accessible mcp tools are keyed in the registry as {qualified_tool_name} (i.e. mcp__ologs__get_logs), but deferred mcp tools are keyed as {namespace}:{name} (i.e. mcp__ologs__:get_logs).

this is because responsesapi's tool_search returns namespaced tools, but that concept is not required for MCPs otherwise. since MCPs can now be discovered via tool_search, we have to support both, but right now they are not uniform and this is a headache for callers.

I think it'd make sense to register all MCPs with namespaces to simplify.

@sayan-oai sayan-oai force-pushed the dev/sayan/code-mode-deferred-tool-guidance branch from 6dac0a1 to 388d9d5 Compare April 13, 2026 13:24
@sayan-oai sayan-oai changed the base branch from main to dev/sayan/namespace-refactor-2 April 13, 2026 13:53
@sayan-oai sayan-oai force-pushed the dev/sayan/namespace-refactor-2 branch 3 times, most recently from 0dec148 to 558bd7f Compare April 15, 2026 08:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants