Skip to content

#tool: reference in prompt files is partially replaced, leaving trailing characters#306276

Merged
aeschli merged 2 commits intomainfrom
aeschli/primary-emu-374
Mar 31, 2026
Merged

#tool: reference in prompt files is partially replaced, leaving trailing characters#306276
aeschli merged 2 commits intomainfrom
aeschli/primary-emu-374

Conversation

@aeschli
Copy link
Copy Markdown
Contributor

@aeschli aeschli commented Mar 30, 2026

Fixes #306212

Copilot AI review requested due to automatic review settings March 30, 2026 09:57
@aeschli aeschli self-assigned this Mar 30, 2026
@vs-code-engineering vs-code-engineering bot added this to the Backlog milestone Mar 30, 2026
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

Fixes incorrect #tool: reference replacement in prompt/agent files by ensuring replacements cover the full matched reference (including the #tool: prefix), preventing leftover trailing characters in the resolved prompt text.

Changes:

  • Extend parsed body tool variable references with fullLength (full match length of #tool:<name>).
  • Use fullLength to compute OffsetRange for tool reference replacement in prompt resolution paths.
  • Update unit tests to validate the corrected ranges and match lengths.

Reviewed changes

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

Show a summary per file
File Description
src/vs/workbench/contrib/chat/common/promptSyntax/promptFileParser.ts Capture fullLength for each #tool: match and expose it via IBodyVariableReference.
src/vs/workbench/contrib/chat/common/promptSyntax/service/promptsServiceImpl.ts Use fullLength when computing replacement ranges for agent instructions tool references.
src/vs/workbench/contrib/chat/browser/widget/chatWidget.ts Use fullLength for prompt-file tool reference ranges when attaching slash-command prompt context.
src/vs/workbench/contrib/chat/browser/chatSessions/chatSessions.contribution.ts Same as chatWidget: compute tool reference ranges using fullLength.
src/vs/workbench/contrib/chat/test/common/promptSyntax/service/promptFileParser.test.ts Update expectations and add assertions verifying substring coverage of #tool:<name>.
src/vs/workbench/contrib/chat/test/common/promptSyntax/service/promptsService.test.ts Update expected variable references and tool reference ranges to reflect full replacement spans.

@aeschli aeschli marked this pull request as ready for review March 31, 2026 10:08
@aeschli aeschli enabled auto-merge (squash) March 31, 2026 10:27
@aeschli aeschli merged commit 295ea75 into main Mar 31, 2026
18 checks passed
@aeschli aeschli deleted the aeschli/primary-emu-374 branch March 31, 2026 10:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

#tool: reference in prompt files is partially replaced, leaving trailing characters

3 participants