Skip to content

NES: more detailed speculation prediction for patch-based prompts#320107

Merged
ulugbekna merged 2 commits into
mainfrom
ulugbekna/more-detailed-speculation
Jun 5, 2026
Merged

NES: more detailed speculation prediction for patch-based prompts#320107
ulugbekna merged 2 commits into
mainfrom
ulugbekna/more-detailed-speculation

Conversation

@ulugbekna
Copy link
Copy Markdown
Contributor

@ulugbekna ulugbekna commented Jun 5, 2026

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

  • New PatchModelPrediction enum + experiment config chat.advanced.inlineEdits.xtabProvider.patchModelPredictionKind with four variants:
    • FilePath (today's behavior, default) — path/to/file:
    • CurrentLinepath:N\n-<line>
    • CurrentLineReplacedpath:N\n-<line>\n+
    • CurrentLineCompletedpath:N\n-<line>\n+<line>
  • getPredictionContents plumbs cursorLineOffset (0-based, matching Patch.lineNumZeroBased parsed by XtabCustomDiffPatchResponseHandler) and cursorLineInEditWindowOffset through to the CustomDiffPatch branch.
  • Guards against out-of-range cursorLineInEditWindowOffset so we never emit a literal -undefined into the prompt — falls back to the FilePath shape in that case.
  • Renames cursorOriginalLinesOffsetcursorLineInEditWindowOffset across xtabProvider.ts to match what the value actually represents.
  • Tests for all four CustomDiffPatch variants plus the fallback path.

fixes https://github.com/microsoft/vscode-internalbacklog/issues/7871

Copilot AI review requested due to automatic review settings June 5, 2026 13:39
@ulugbekna ulugbekna enabled auto-merge (squash) June 5, 2026 13:39
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

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.patchModelPredictionKind to 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

Comment thread extensions/copilot/src/platform/inlineEdits/common/dataTypes/xtabPromptOptions.ts Outdated
Comment thread extensions/copilot/src/platform/inlineEdits/common/dataTypes/xtabPromptOptions.ts Outdated
Comment thread extensions/copilot/src/extension/xtab/node/xtabProvider.ts Outdated
Comment thread extensions/copilot/src/extension/xtab/node/xtabProvider.ts
- 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
@ulugbekna ulugbekna merged commit 47d4f06 into main Jun 5, 2026
25 checks passed
@ulugbekna ulugbekna deleted the ulugbekna/more-detailed-speculation branch June 5, 2026 14:35
@vs-code-engineering vs-code-engineering Bot added this to the 1.124.0 milestone Jun 5, 2026
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.

3 participants