External tool_search_tool override (overridesBuiltInTool: true) is bypassed on the generic-client tool search path

未關閉
#5,579 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

評估

難度
4/5
預估耗時
3-5 天
新手友好度
48/100
Issue 類型
缺陷
描述清晰度
描述清楚
活躍度
活躍
技術堆疊
python
領域
tooling

研究方向

Start by tracing the generic-client tool-search path and how it handles the registered tool_search_tool override; compare it with the OpenAI client path, where the issue says the override is invoked. Reproduce with toolSearch enabled and inspect events.jsonl for external_tool.requested and tool_search.activated. Done when the generic-client path invokes the host handler and activates its returned toolReferences.

由索引模型根據 Issue 內容生成。

描述

area:models area:tools

Summary

When an SDK host registers a custom tool_search_tool with overridesBuiltInTool: true and enables toolSearch: { enabled: true }, models on the generic-client tool-search path bypass the external override and run the runtime's built-in full-text search instead.

On GPT models in the same runtime process and with the exact same session configuration, external_tool.requested fires and invokes the host's custom tool_search_tool handler as documented.

Environment

  • @github/copilot-sdk: 1.0.29
  • Bundled Copilot runtime (copilotVersion in session events): 1.0.107
  • OS: Windows x64

Steps to Reproduce

  1. Create a Copilot SDK session with toolSearch: { enabled: true }, enough deferred tools (e.g., >30 MCP/external tools) to trigger deferral, and a custom tool_search_tool override:
await client.createSession({
  model,
  toolSearch: { enabled: true },
  mcpServers: { /* server(s) exposing deferred tools */ },
  tools: [
    {
      name: "tool_search_tool",
      description: "Custom tool search override",
      parameters: {
        type: "object",
        properties: {
          query: { type: "string" },
          limit: { type: "number" },
        },
        required: ["query"],
      },
      overridesBuiltInTool: true,
      skipPermission: true,
      defer: "never",
      handler: async (args, invocation) => ({
        resultType: "success",
        toolReferences: [/* custom-ranked tool names */],
        textResultForLlm: "...",
      }),
    },
  ],
});
  1. Send a prompt that requires discovering a deferred tool in two sessions inside the same runtime process:

    • Session A: a GPT model (uses the OpenAI client tool-search path).
    • Session B: a non-GPT / non-Claude model, such as a BYOK OpenAI-compatible local model (uses the generic-client tool-search path).
  2. Inspect events.jsonl for both sessions when tool_search_tool executes.

Expected Behavior

Both sessions invoke the registered tool_search_tool override (overridesBuiltInTool: true), emitting external_tool.requested / external_tool.completed and activating the toolReferences returned by the host's handler.

Actual Behavior

  • Session A (GPT model): tool.execution_start (tool_search_tool) → external_tool.requested → external_tool.completed → tool.execution_complete. The host's custom handler runs and controls tool ranking/activation.
  • Session B (non-GPT / non-Claude model): tool.execution_start (tool_search_tool) → hook.start/hook.end (preToolUse) → tool_search.activated (strategy: "generic-client") → hook.start/hook.end (postToolUse) → tool.execution_complete with detailedContent: "Client-side tool search loaded 5 tool(s).".
    • external_tool.requested never fires.
    • The runtime executes its built-in full-text search instead of the host's override.

Impact

Hosts that customize tool_search_tool (for example, to apply domain ranking or custom selection semantics) get consistent tool discovery on GPT models, but silently lose their custom search logic on any model routed through generic-client (including BYOK / local models).

主要語言
Python
星號
11.5k
分支
2k
平均合併
6 小時 34 分鐘
30 天內合併 PR
3

環境準備

  • 沒有 Dockerfile 或 Docker Compose 檔案
  • 沒有 Pull Request 範本
  • 閱讀貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

github/copilot-cli 的其他 Issue

查看 github/copilot-cli 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。