#tool: reference in prompt files is partially replaced, leaving trailing characters#306276
Merged
#tool: reference in prompt files is partially replaced, leaving trailing characters#306276
Conversation
Contributor
There was a problem hiding this comment.
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
fullLengthto computeOffsetRangefor 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. |
hediet
approved these changes
Mar 31, 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.
Fixes #306212