Return final answer text when snippet hydration errors#316094
Merged
bhavyaus merged 3 commits intoMay 15, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
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
parseFinalAnswerAndHydrateto 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
approved these changes
May 15, 2026
dmitrivMS
approved these changes
May 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
Raw subagent response no longer includes error after file + line, and we return the original unparsed line
Misformatted response (with unrecognized file outside final answer tags)