Skip to content

Fix tool_search bookkeeping when resuming from stateful marker#314217

Merged
bhavyaus merged 3 commits intomainfrom
dev/bhavyau/fix-tool-search-stateful-marker
May 4, 2026
Merged

Fix tool_search bookkeeping when resuming from stateful marker#314217
bhavyaus merged 3 commits intomainfrom
dev/bhavyau/fix-tool-search-stateful-marker

Conversation

@bhavyaus
Copy link
Copy Markdown
Collaborator

@bhavyaus bhavyaus commented May 4, 2026

Fixes #313899

When resuming from a Responses API previous_response_id, the assistant message carrying the stateful marker (and the tool_search_call it emitted) was being sliced out of the input. Bookkeeping (toolSearchCallIds, toolSearchLoadedTools) was populated only while iterating that post-marker slice, so the subsequent tool result was incorrectly serialized as function_call_output instead of tool_search_output, leaving deferred MCP tool definitions unloaded on the server. The model would acknowledge the names returned by tool_search but couldn't actually invoke the tool.

Pre-scan the full messages[] for tool_search calls and their results before applying the slice.

Pre-scan the full message history before applying the previous_response_id slice, so tool_search_call ids and loaded tool names are remembered even when the assistant message that emitted the tool_search call carries the stateful marker (and is therefore dropped from the post-marker slice). Without this, the subsequent tool result was serialized as a plain function_call_output instead of tool_search_output, leaving deferred MCP tool definitions unloaded on the server and the model unable to invoke them.

Fixes #313899
Copilot AI review requested due to automatic review settings May 4, 2026 20:04
@bhavyaus bhavyaus enabled auto-merge (squash) May 4, 2026 20:05
@bhavyaus bhavyaus added the ~release-cherry-pick Trigger: cherry-pick this PR to the latest release branch label May 4, 2026
@bhavyaus bhavyaus added this to the 1.119.0 milestone May 4, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes a Responses API resume bug where tool_search bookkeeping was lost when the assistant message containing the stateful marker (and its tool_search_call) was sliced out, causing subsequent tool results to be serialized incorrectly and deferred MCP tools to remain unloaded server-side.

Changes:

  • Pre-scans the full raw message history to collect tool_search call IDs and loaded deferred tool names before applying stateful-marker/compaction slicing.
  • Adds a regression test covering the “marker drops tool_search_call from post-marker slice” scenario (issue #313899).
Show a summary per file
File Description
extensions/copilot/src/platform/endpoint/node/responsesApi.ts Pre-scan full message history to preserve tool_search bookkeeping across stateful-marker resume slicing.
extensions/copilot/src/platform/endpoint/node/test/responsesApiToolSearch.spec.ts Adds a regression test ensuring tool_search_output serialization and MCP tool namespacing still work when the marker slices out the tool_search_call.

Copilot's findings

  • Files reviewed: 2/2 changed files
  • Comments generated: 1

Comment thread extensions/copilot/src/platform/endpoint/node/responsesApi.ts Outdated
@vs-code-engineering
Copy link
Copy Markdown
Contributor

This PR will be automatically cherry-picked to release/1.119 when merged.

@bhavyaus bhavyaus merged commit 932dd11 into main May 4, 2026
25 of 27 checks passed
@bhavyaus bhavyaus deleted the dev/bhavyau/fix-tool-search-stateful-marker branch May 4, 2026 20:58
@vs-code-engineering vs-code-engineering Bot added release-cherry-pick Automated cherry-pick between release and main branches and removed ~release-cherry-pick Trigger: cherry-pick this PR to the latest release branch labels May 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release-cherry-pick Automated cherry-pick between release and main branches

Projects

None yet

Development

Successfully merging this pull request may close these issues.

tool_search isn't working for mcp tools on gpt-5.5

3 participants