Scope tool search to request tools and tighten deferred tool handling#317707
Scope tool search to request tools and tighten deferred tool handling#317707PenguinDOOM wants to merge 11 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes tool-search deferral mismatches by introducing a request-scoped “tool manifest” that consistently classifies enabled tools as deferred vs non-deferred, then using that manifest to (1) scope tool-search results to tools actually deferred/available for the active request and (2) omit tool-search scaffolding/prompt guidance entirely when a request has zero deferred tools. This targets cases where models see tool suggestions (via tool search) that they cannot actually invoke in the current request.
Changes:
- Centralized request-scoped tool classification via
createRequestToolManifestand used it across endpoint body builders and tools services. - Tightened tool_search behavior: omit client tool_search machinery when no deferred tools exist; and enforce request-scoped context for
ToolSearchToolinvocation. - Added regression tests and updated prompt snapshots to reflect conditional tool_search guidance/reminders.
Reviewed changes
Copilot reviewed 26 out of 26 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| extensions/copilot/src/platform/endpoint/test/node/messagesApi.spec.ts | Adds coverage ensuring Messages API omits tool_search scaffolding when no tools are deferred. |
| extensions/copilot/src/platform/endpoint/node/test/responsesApiToolSearch.spec.ts | Adds coverage ensuring Responses API omits client tool_search tool when no tools are deferred. |
| extensions/copilot/src/platform/endpoint/node/responsesApi.ts | Uses request-scoped manifest to gate tool search deferral and tool_search inclusion for Responses API. |
| extensions/copilot/src/platform/endpoint/node/messagesApi.ts | Uses request-scoped manifest + model capability gating to skip tool_search when it would be ineffective. |
| extensions/copilot/src/extension/tools/vscode-node/toolsService.ts | Prunes tool_search from enabled tools when the request contains zero deferred tools. |
| extensions/copilot/src/extension/tools/node/toolSearchTool.ts | Scopes tool search candidates to deferred tools enabled for the active request; enforces resolveInput context. |
| extensions/copilot/src/extension/tools/node/test/toolSearchTool.spec.ts | New unit tests for request-scoped tool search behavior and explicit failure without resolveInput context. |
| extensions/copilot/src/extension/tools/node/test/testToolsService.ts | Aligns test tools service with request-scoped manifest and tool_search pruning behavior. |
| extensions/copilot/src/extension/tools/common/requestToolManifest.ts | New shared helper to classify active tools into deferred vs non-deferred for a request. |
| extensions/copilot/src/extension/prompts/node/agent/toolSearchInstructions.tsx | Makes tool_search guidance conditional on endpoint support, tool_search availability, and presence of deferred tools. |
| extensions/copilot/src/extension/prompts/node/agent/test/agentPrompt.spec.tsx | Adds tests for OpenAI prompt reminders to omit tool_search guidance when no deferred tools exist. |
| extensions/copilot/src/extension/prompts/node/agent/test/snapshots/agentPrompts-claude-sonnet-4.6/all_tools.spec.snap | Snapshot updates reflecting conditional removal of tool_search instructions / deferred tool list. |
| extensions/copilot/src/extension/prompts/node/agent/test/snapshots/agentPrompts-claude-sonnet-4.6/all_non_edit_tools.spec.snap | Snapshot updates reflecting conditional removal of tool_search instructions / deferred tool list. |
| extensions/copilot/src/extension/prompts/node/agent/test/snapshots/agentPrompts-claude-sonnet-4.5/all_tools.spec.snap | Snapshot updates reflecting conditional removal of deferred tool list + whitespace normalization. |
| extensions/copilot/src/extension/prompts/node/agent/test/snapshots/agentPrompts-claude-sonnet-4.5/all_non_edit_tools.spec.snap | Snapshot updates reflecting conditional removal of deferred tool list + whitespace normalization. |
| extensions/copilot/src/extension/prompts/node/agent/test/snapshots/agentPrompts-claude-opus-4.6/all_tools.spec.snap | Snapshot updates reflecting conditional removal of tool_search instructions / deferred tool list. |
| extensions/copilot/src/extension/prompts/node/agent/test/snapshots/agentPrompts-claude-opus-4.6/all_non_edit_tools.spec.snap | Snapshot updates reflecting conditional removal of tool_search instructions / deferred tool list. |
| extensions/copilot/src/extension/prompts/node/agent/test/snapshots/agentPrompts-claude-opus-4.5/all_tools.spec.snap | Snapshot updates reflecting conditional removal of deferred tool list + whitespace normalization. |
| extensions/copilot/src/extension/prompts/node/agent/test/snapshots/agentPrompts-claude-opus-4.5/all_non_edit_tools.spec.snap | Snapshot updates reflecting conditional removal of deferred tool list + whitespace normalization. |
| extensions/copilot/src/extension/prompts/node/agent/openai/hiddenModelMPrompt.tsx | Makes reminder tool_search guidance conditional using the shared predicate and tool deferral service. |
| extensions/copilot/src/extension/prompts/node/agent/openai/gpt55BasePrompt.tsx | Makes reminder tool_search guidance conditional using the shared predicate and tool deferral service. |
| extensions/copilot/src/extension/prompts/node/agent/openai/gpt54Prompt.tsx | Makes reminder tool_search guidance conditional using the shared predicate and tool deferral service. |
| extensions/copilot/src/extension/prompts/node/agent/defaultAgentInstructions.tsx | Extends reminder props to include availableTools for request-scoped tool_search reminder logic. |
| extensions/copilot/src/extension/prompts/node/agent/agentPrompt.tsx | Plumbs availableTools into reminder instruction props. |
| extensions/copilot/src/extension/intents/node/test/backgroundTodoEnablement.spec.ts | Adds regression coverage around publishing/explicitly disabling vscode_askQuestions in agent tools. |
| extensions/copilot/src/extension/intents/node/agentIntent.ts | Allows vscode_askQuestions tool in agent tool set by default (subject to request tool picker overrides). |
- add RED contracts for zero-deferred endpoint behavior - cover initial vscode_askQuestions publication in agent mode - add ToolSearchTool and getEnabledTools request-scope regressions
- add shared request-scoped deferred tool classification - prune tool_search when no deferred tools remain - publish vscode_askQuestions on initial agent requests
- capture deferred tool names from request context - isolate request snapshots on resolved input objects - filter search candidates to request-scoped deferred tools - fail explicitly when request-scoped context is missing
- gate responses and messages tool search on deferred availability - suppress prompt guidance unless tool_search is active for the request - keep endpoint and prompt behavior aligned on request-scoped signals
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <copilot@github.com>
30b8cc2 to
c1e2f77
Compare
|
I was able to confirm locally that there were no problems calling the tools with either GPT or Claude. |
Updated the comment in the 'createMessagesRequestBody tool search deferral' test to clarify the behavioral contract regarding the omission of the client-side tool_search scaffold when no request tool is deferred.
|
Thanks — the root cause is real and a good catch: a non-deferred tool (like askQuestions) getting pulled into a virtual group while defaultToolsGrouped + tool search are both active means it's never surfaced via tool_search_output, so the model can't call it. I'm going to pass on this PR as the fix, though. The actual fix is basically a one-line invariant ("non-deferred tools must never be grouped"), but this PR is ~1,100 lines across 31 files of request-scoped manifests, serialization, and prompt-gating changes that go well beyond the root cause and touch experimental tool-search internals we're actively iterating on. |
Summary
Testing
Review follow-up
fix(tool-grouping): keep non-deferred built-ins direct) was reviewed by Code-Review-subagent and approved.BuiltInToolGroupHandler/VirtualToolGrouperchanges.ToolCategory.Coresummary branch, and a note thatToolSearchstays direct in the new test because it is categorized asCore.Fixes #316779