Skip to content

Return final answer text when snippet hydration errors#316094

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

Return final answer text when snippet hydration errors#316094
bhavyaus merged 3 commits into
microsoft:mainfrom
guomaggie:maggie/update-search-subagent-final-ans-parsing

Conversation

@guomaggie
Copy link
Copy Markdown
Contributor

@guomaggie guomaggie commented May 12, 2026

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
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

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.

@guomaggie guomaggie marked this pull request as draft May 12, 2026 21:02
@guomaggie guomaggie marked this pull request as ready for review May 14, 2026 17:33
@24anisha 24anisha assigned bhavyaus and unassigned jruales May 14, 2026
@bhavyaus 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants