Skip to content

Search subagent -- resolve relative and absolute paths#4429

Merged
roblourens merged 32 commits intomicrosoft:mainfrom
24anisha:anisha/search_abspath
Mar 18, 2026
Merged

Search subagent -- resolve relative and absolute paths#4429
roblourens merged 32 commits intomicrosoft:mainfrom
24anisha:anisha/search_abspath

Conversation

@24anisha
Copy link
Copy Markdown
Contributor

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.

Copilot AI review requested due to automatic review settings March 16, 2026 16:24
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

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 cwd into parseFinalAnswerAndHydrate() so hydration can attempt to resolve non-working paths against the workspace root.
  • Add a resolvedFilePath when 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.

@bpasero bpasero removed their assignment Mar 16, 2026
const startLine = parseInt(startLineStr, 10);
const endLine = parseInt(endLineStr, 10);

const resolvedFilePath = cwd && !filePath.startsWith(cwd)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

edited the implementation, which resolves this concern

@24anisha 24anisha marked this pull request as draft March 17, 2026 02:48
@24anisha 24anisha marked this pull request as ready for review March 18, 2026 16:39
@vs-code-engineering vs-code-engineering bot added this to the 1.113.0 milestone Mar 18, 2026
@roblourens roblourens added this pull request to the merge queue Mar 18, 2026
Merged via the queue into microsoft:main with commit 029fc2d Mar 18, 2026
9 checks passed
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.

6 participants