AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.
fix(backend): stop registering baseline-only MCP TodoWrite on the SDK server (#13548)
Ubbe4276741397c1
diff --git a/autogpt_platform/backend/backend/copilot/permissions.py b/autogpt_platform/backend/backend/copilot/permissions.pyindex 8156866071..3581d8ca8b 100644--- a/autogpt_platform/backend/backend/copilot/permissions.py+++ b/autogpt_platform/backend/backend/copilot/permissions.py@@ -157,7 +157,8 @@ the model as available tools.# baseline mode ships an MCP-wrapped platform version# (``tools/todo_write.py``), while SDK mode still uses the CLI-native# original via ``_SDK_BUILTIN_ALWAYS`` in ``sdk/tool_adapter.py`` — the-# MCP copy is filtered out there. ``Task`` remains an SDK-only built-in+# MCP copy is never registered there (``BASELINE_ONLY_MCP_TOOLS``).+# ``Task`` remains an SDK-only built-in# (for queue-backed context-isolation on baseline, use ``run_sub_session``# instead).SDK_BUILTIN_TOOL_NAMES: frozenset[str] = frozenset(diff --git a/autogpt_platform/backend/backend/copilot/sdk/tool_adapter.py b/autogpt_platform/backend/backend/copilot/sdk/tool_adapter.pyindex cc9915003f..dd5aeac982 100644--- a/autogpt_platform/backend/backend/copilot/sdk/tool_adapter.py+++ b/autogpt_platform/backend/backend/copilot/sdk/tool_adapter.py@@ -854,7 +854,12 @@ def create_copilot_mcp_server(sdk_tools = []for tool_name, base_tool in TOOL_REGISTRY.items():- if tool_name in hidden:+ # Baseline-only wrappers (TodoWrite) must not be registered here:+ # SDK mode uses the CLI-native built-ins, and these names are+ # excluded from ``allowed_tools`` — advertising an MCP copy the CLI+ # can never approve makes the model call it, receive a permission+ # denial, and silently abandon the feature (e.g. the task checklist).+ if tool_name in hidden or tool_name in BASELINE_ONLY_MCP_TOOLS:continuehandler = create_tool_handler(base_tool)schema = _build_input_schema(base_tool)@@ -1066,10 +1071,14 @@ DANGEROUS_PATTERNS = [# Platform-tool names whose MCP wrappers must NOT be exposed to SDK mode.# Baseline ships an MCP ``TodoWrite`` for model-flexibility parity; SDK mode# keeps using the CLI-native built-in listed in ``_SDK_BUILTIN_ALWAYS`` so-# there is no double exposure. Public (no leading underscore) so a future-# refactor renaming it is visible at both call sites —-# ``permissions.apply_tool_permissions`` maps short tool names back to the-# CLI built-in form for SDK mode.+# there is no double exposure. These names are both excluded from+# ``allowed_tools`` (see ``_registry_mcp_tools``) AND skipped during MCP+# server registration in ``create_copilot_mcp_server`` — filtering the+# allowed list alone still advertises the tool to the model, which then+# calls it and hits an unapprovable permission prompt. Public (no leading+# underscore) so a future refactor renaming it is visible at both call+# sites — ``permissions.apply_tool_permissions`` maps short tool names back+# to the CLI built-in form for SDK mode.BASELINE_ONLY_MCP_TOOLS: frozenset[str] = frozenset({"TodoWrite"})diff --git a/autogpt_platform/backend/backend/copilot/sdk/tool_adapter_test.py b/autogpt_platform/backend/backend/copilot/sdk/tool_adapter_test.pyindex fe29e146f4..864c858656 100644--- a/autogpt_platform/backend/backend/copilot/sdk/tool_adapter_test.py+++ b/autogpt_platform/backend/backend/copilot/sdk/tool_adapter_test.py@@ -18,6 +18,7 @@ from backend.util.truncate import truncatefrom .tool_adapter import (_MCP_MAX_CHARS,_STRIP_FROM_LLM,+ BASELINE_ONLY_MCP_TOOLS,SDK_DISALLOWED_TOOLS,_make_truncating_wrapper,_strip_llm_fields,@@ -1235,8 +1236,24 @@ class TestCreateCopilotMcpServerHidden:server = create_copilot_mcp_server()registered = await self._registered_tool_names(server)for short in TOOL_REGISTRY:+ if short in BASELINE_ONLY_MCP_TOOLS:+ continueassert short in registered+ @pytest.mark.asyncio+ async def test_baseline_only_tools_never_registered(self):+ """Baseline-only MCP wrappers (TodoWrite) must not register on the+ SDK server. They are excluded from ``allowed_tools`` (SDK mode uses+ the CLI-native built-ins), so advertising them makes the model call+ a tool the CLI can never approve — it answers "Claude requested+ permissions to use mcp__copilot__TodoWrite, but you haven't granted+ it yet" and the model silently abandons the checklist."""+ assert "TodoWrite" in BASELINE_ONLY_MCP_TOOLS+ for use_e2b in (False, True):+ server = create_copilot_mcp_server(use_e2b=use_e2b)+ registered = await self._registered_tool_names(server)+ assert not BASELINE_ONLY_MCP_TOOLS & registered+@pytest.mark.asyncioasync def test_builder_blocked_tools_hidden(self):server = create_copilot_mcp_server(hidden_tool_names=BUILDER_BLOCKED_TOOLS)@@ -1257,6 +1274,8 @@ class TestCreateCopilotMcpServerHidden:registered = await self._registered_tool_names(server)# All real tools still register.for short in TOOL_REGISTRY:+ if short in BASELINE_ONLY_MCP_TOOLS:+ continueassert short in registered@staticmethoddiff --git a/autogpt_platform/backend/backend/copilot/tools/todo_write.py b/autogpt_platform/backend/backend/copilot/tools/todo_write.pyindex 6047281e10..3d6c1d5999 100644--- a/autogpt_platform/backend/backend/copilot/tools/todo_write.py+++ b/autogpt_platform/backend/backend/copilot/tools/todo_write.py@@ -9,7 +9,8 @@ on subsequent turns.Baseline needs this as a platform tool because OpenAI-compatible providers(Kimi, GPT, Grok, Gemini) do not ship a built-in equivalent. The SDK pathcontinues to use the CLI's native ``TodoWrite`` — the MCP-wrapped version-of this tool is filtered out of SDK's allowed_tools list (see+of this tool is never registered on the SDK MCP server and is filtered out+of SDK's allowed_tools list (see ``BASELINE_ONLY_MCP_TOOLS`` in``sdk/tool_adapter.py``) to avoid name shadowing."""