NES: more detailed speculation prediction for patch-based prompts#320107
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds an experiment-controlled switch to vary the “predicted output” hint sent to the Xtab patch-based (CustomDiffPatch) prompting strategy, enabling measurement of whether richer speculative hints improve latency/quality. It introduces a new PatchModelPrediction enum/config, plumbs cursor/line offsets into getPredictionContents, and expands unit coverage for the new variants and fallback behavior.
Changes:
- Added
PatchModelPrediction(with validator) to represent multiple prediction shapes for patch-based prompts. - Registered a new experiment-based setting
chat.advanced.inlineEdits.xtabProvider.patchModelPredictionKindto control the prediction shape. - Updated Xtab provider prediction generation to include cursor line info for
CustomDiffPatch, and added/updated tests to cover all variants and out-of-range fallback.
Show a summary per file
| File | Description |
|---|---|
| extensions/copilot/src/platform/inlineEdits/common/dataTypes/xtabPromptOptions.ts | Adds PatchModelPrediction enum and validator used to select the patch prediction shape. |
| extensions/copilot/src/platform/configuration/common/configurationService.ts | Registers the new experiment-based config key for selecting patch prediction kind. |
| extensions/copilot/src/extension/xtab/test/node/xtabProvider.spec.ts | Updates getPredictionContents tests to cover all CustomDiffPatch variants and fallback behavior. |
| extensions/copilot/src/extension/xtab/node/xtabProvider.ts | Plumbs cursor offsets into prediction generation and implements richer CustomDiffPatch prediction strings with bounds guarding. |
Copilot's findings
- Files reviewed: 4/4 changed files
- Comments generated: 4
- Rewrite PatchModelPrediction JSDoc in conventional style; note line numbers are 0-based - Skip patchModelPredictionKind experiment lookup when responseFormat is not CustomDiffPatch - Rename cursorOriginalLinesOffset -> cursorLineInEditWindowOffset on UnifiedXmlInsertContext and its handler
vijayupadya
approved these changes
Jun 5, 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.
Adds an experiment-based knob to vary the "predicted output" speculation we send to the patch-based xtab model, so we can measure whether a richer hint improves first-token latency or accuracy.
What changed
PatchModelPredictionenum + experiment configchat.advanced.inlineEdits.xtabProvider.patchModelPredictionKindwith four variants:FilePath(today's behavior, default) —path/to/file:CurrentLine—path:N\n-<line>CurrentLineReplaced—path:N\n-<line>\n+CurrentLineCompleted—path:N\n-<line>\n+<line>getPredictionContentsplumbscursorLineOffset(0-based, matchingPatch.lineNumZeroBasedparsed byXtabCustomDiffPatchResponseHandler) andcursorLineInEditWindowOffsetthrough to theCustomDiffPatchbranch.cursorLineInEditWindowOffsetso we never emit a literal-undefinedinto the prompt — falls back to theFilePathshape in that case.cursorOriginalLinesOffset→cursorLineInEditWindowOffsetacrossxtabProvider.tsto match what the value actually represents.CustomDiffPatchvariants plus the fallback path.fixes https://github.com/microsoft/vscode-internalbacklog/issues/7871