Skip to content

Return final answer text when snippet hydration errors - #316094

Merged
Bhavya U (bhavyaus) merged 3 commits into
microsoft:mainfrom
guomaggie:maggie/update-search-subagent-final-ans-parsing
May 15, 2026
Merged

Bhavya U (bhavyaus) merged 3 commits into
microsoft:mainfrom
guomaggie:maggie/update-search-subagent-final-ans-parsing

Conversation

@guomaggie

@guomaggie guomaggie commented May 12, 2026 •

Copy link
Copy Markdown
Contributor

Sometimes the model will return the hydrated snippet in a format that doesn't get parsed correctly.
If any parsing error occurs, the model should fail gracefully by appending the unparsed lines as-is so the main agent is still getting some information.

Testing:

  1. Raw subagent response no longer includes error after file + line, and we return the original unparsed line

  2. Misformatted response (with unrecognized file outside final answer tags)

image
  1. Misformatted response (with unrecognized file inside final answer tags)
image

Copilot AI review requested due to automatic review settings May 12, 2026 18:59

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Improves resilience of the Copilot search subagent snippet “hydration” step so that when the model output can’t be parsed or a referenced file can’t be opened, the tool returns the original text instead of appending a noisy error suffix. This helps the main agent still receive useful information even when the subagent response format drifts.

Changes:

  • Update parseFinalAnswerAndHydrate to keep the original response line verbatim when hydration fails.
  • Add unit tests covering (1) non-matching line formats and (2) matching lines that fail to open/hydrate, ensuring no error suffix is appended.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
extensions/copilot/src/extension/tools/node/searchSubagentTool.ts On hydration failure, preserves the model’s original line instead of adding an “unable to read file” suffix.
extensions/copilot/src/extension/tools/node/test/searchSubagentTool.spec.ts Adds coverage to ensure misformatted or unopenable snippet references are returned verbatim.

@bhavyaus
Bhavya U (bhavyaus) merged commit 7b21f80 into microsoft:main May 15, 2026
25 checks passed
@vs-code-engineering vs-code-engineering Bot added this to the 1.121.0 milestone May 15, 2026
@vs-code-engineering vs-code-engineering Bot locked and limited conversation to collaborators Jun 29, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants