copilot-cli icon indicating copy to clipboard operation
copilot-cli copied to clipboard

OverridesBuiltInTool is ignored for store_memory / vote_memory; calls run the built-in memory executor

Open toliaqat opened this issue 1 month ago • 1 comments

Describe the bug

An SDK host can register an external tool named store_memory (or vote_memory) with overridesBuiltInTool: true. The runtime plans the override and removes the built-in from the tool list the model sees. However, when the model calls the tool, the runtime runs the built-in memory executor instead of the host's tool, including the built-in memory permission flow. The host's handler is never invoked. No error or warning is raised.

Overrides of other built-ins, such as read_file, work as expected.

Root cause

  • Planning (session/tool_initialization.rs, plan_eager_tool_initialization): memory tools are added to the built-in list there, so session_local_external_tool_overrides_json correctly marks store_memory as overridden. The model is offered the host's definition.
  • Dispatch (tools/session_tool_invoker.rs, external_override_definition): an override is honoured only when is_runtime_builtin is true. That check uses registry::get_builtin_tool_descriptor(name) plus a few special cases (rg, lsp, task, shell tools).
  • store_memory and vote_memory are materialized by the tool catalog and aren't returned by get_builtin_tool_descriptor. See registry::is_catalog_materialized_builtin_tool_name, which lists them explicitly.
  • external_override_definition therefore returns Ok(None) and execute_tool_result falls through to the built-in memory handler.
  • Planning and dispatch disagree about which names are overridable built-ins. Any other catalog-materialized name not otherwise special-cased (lexical_code_search, semantic_code_search, canvas tools) may be affected the same way.

Affected version

1.0.13

Steps to reproduce the behavior

  1. Using the .NET SDK (reported on 1.0.13), create a session with memory enabled.
  2. Register an external tool named store_memory with OverridesBuiltInTool = true and a handler that logs its invocation. Optionally register read_file the same way as a control.
  3. Prompt the agent to remember a fact, for example "Remember that our build command is make ci."
  4. Observe that the host store_memory handler is never called and the built-in memory permission request is raised instead. A read_file override in the same session is invoked normally.

Expected behavior

When a host registers store_memory / vote_memory with overridesBuiltInTool: true:

  • calls go to the host's external tool handler, and
  • the built-in memory executor and its permission prompt are not used.

More generally, the set of names accepted as overridable at planning time should match the set honoured at dispatch.

Additional context

  • SDK: GitHub Copilot SDK for .NET 1.0.13 (reporter). Root cause verified against current main.
  • Workaround: disable built-in memory (Memory = new MemoryConfiguration { Enabled = false }) and register memory tools under distinct names.

toliaqat avatar Oct 06 '26 17:10 toliaqat

Thanks for the precise root-cause write-up. This is fixed in Copilot CLI v1.0.96 (Copilot SDK v1.0.21 and later): external tools registered as store_memory or vote_memory with overridesBuiltInTool: true are now dispatched to your host handler instead of the built-in memory executor and its permission prompt. If you still see the built-in memory tool run on the latest version, feel free to reopen.

Triaged as part of a Copilot SDK backlog review, with help from GitHub Copilot.

patniko avatar Oct 26 '26 20:10 patniko