Search subagent -- resolve relative and absolute paths#4429
Merged
roblourens merged 32 commits intomicrosoft:mainfrom Mar 18, 2026
Merged
Search subagent -- resolve relative and absolute paths#4429roblourens merged 32 commits intomicrosoft:mainfrom
roblourens merged 32 commits intomicrosoft:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Updates the Search subagent tool to better handle file paths returned by the model by introducing a cwd parameter for path resolution during snippet hydration.
Changes:
- Pass
cwdintoparseFinalAnswerAndHydrate()so hydration can attempt to resolve non-working paths against the workspace root. - Add a
resolvedFilePathwhen opening documents and when emitting hydrated “File:” output lines. - Tighten the “last turn” prompt to explicitly request absolute-path code references.
Reviewed changes
Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/extension/tools/node/searchSubagentTool.ts | Adds cwd-aware path handling when hydrating <final_answer> file references into code snippets. |
| src/extension/prompts/node/agent/searchSubagentPrompt.tsx | Updates final-turn instruction text to request absolute-path code references. |
connor4312
reviewed
Mar 16, 2026
| const startLine = parseInt(startLineStr, 10); | ||
| const endLine = parseInt(endLineStr, 10); | ||
|
|
||
| const resolvedFilePath = cwd && !filePath.startsWith(cwd) |
Member
There was a problem hiding this comment.
this
- Doesn't account for case insensitivity
- Never allows the subagent to return a path outside the cwd
Logic like this should probably only be applied to non-absolute paths
Contributor
Author
There was a problem hiding this comment.
edited the implementation, which resolves this concern
connor4312
approved these changes
Mar 18, 2026
dmitrivMS
approved these changes
Mar 18, 2026
roblourens
approved these changes
Mar 18, 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.
Currently, the search subagent expects the model to return absolute paths to the relevant code snippets. With this change, it will try prepending the cwd to the file paths if the paths as-is don't point to any files.