Skip to content

Add optional rejected edit memory to diffpatch prompt - #327367

Merged
Ulugbek Abdullaev (ulugbekna) merged 26 commits into
microsoft:mainfrom
bstee615:nes-rejection-annotations
Aug 7, 2026
Merged

Add optional rejected edit memory to diffpatch prompt#327367
Ulugbek Abdullaev (ulugbekna) merged 26 commits into
microsoft:mainfrom
bstee615:nes-rejection-annotations

Conversation

@bstee615

@bstee615 Benjamin Steenhoek (bstee615) commented Jul 24, 2026

Copy link
Copy Markdown
Member

Summary

Add opt-in memory.rejectedEdits model configuration option for PatchBased02.

  • Record rejected suggestions only when the originating suggestion enabled rejected-edit memory
  • Keep rejected suggestions separate from normal NES diff history in a bounded compact-hunk buffer
  • Annotate rejected edit-history hunks with <|rejected/|> and explain the annotation in the prompt

Rejection annotations are added to edit_diff_history as standalone entries. Toy example:

<|edit_diff_history|>
--- src/auth.ts
+++ src/auth.ts
@@ -12,1 +12,1 @@
-  if (user.isAdmin) {
+  if (user.role === 'admin') {

--- src/auth.ts
+++ src/auth.ts
@@ -18,1 +18,1 @@ <|rejected/|>   <-- This tag marks the entry as a rejection
-  return true;
+  return user.permissions.includes('deploy');

--- src/auth.ts
+++ src/auth.ts
@@ -18,1 +18,1 @@
-  return true;
+  return user.permissions.includes('read');
<|/edit_diff_history|>

// Addition to the postscript instructs the model what to do with rejections
... Adhere meticulously to the diff format. Edit history hunks whose header ends with \`${REJECTED_EDIT_TAG}\` are previous suggestions the developer rejected; avoid repeating them unless later context makes them clearly appropriate.

The rejection buffer retains at most three entries and 3,000 characters per entry. It stores only the changed line hunks. Adds an extra property sequence to preserve the order of edits and rejections.

TODOs:

  • Tune the amount of context given with rejected edits
  • Make rejected edits more token-efficient (e.g. by merging them with existing diff history entries rather than adding standalone entries)

Validation

Copilot AI review requested due to automatic review settings July 24, 2026 19:56

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds opt-in rejected-edit memory to PatchBased02 prompts.

Changes:

  • Captures up to three compact rejected edits.
  • Merges rejected and normal history chronologically with annotations.
  • Propagates model attribution through requests, caches, and telemetry.
Show a summary per file
File Description
extensions/copilot/src/platform/inlineEdits/test/common/xtabPromptOptions.spec.ts Tests configuration validation.
extensions/copilot/src/platform/inlineEdits/common/workspaceEditTracker/nesXtabHistoryTracker.ts Stores bounded rejected-edit history.
extensions/copilot/src/platform/inlineEdits/common/statelessNextEditProvider.ts Carries history and attribution.
extensions/copilot/src/platform/inlineEdits/common/dataTypes/xtabPromptOptions.ts Defines the memory option.
extensions/copilot/src/extension/xtab/test/node/diffHistoryForPrompt.spec.ts Tests annotated history rendering.
extensions/copilot/src/extension/xtab/test/common/promptCrafting.spec.ts Tests prompt integration.
extensions/copilot/src/extension/xtab/node/xtabProvider.ts Enables memory for PatchBased02.
extensions/copilot/src/extension/xtab/common/promptCrafting.ts Adds rejected history to prompts.
extensions/copilot/src/extension/xtab/common/diffHistoryForPrompt.ts Renders and budgets rejected hunks.
extensions/copilot/src/extension/inlineEdits/test/node/nextEditProviderTelemetry.spec.ts Updates telemetry expectations.
extensions/copilot/src/extension/inlineEdits/test/node/nextEditProviderSpeculative.spec.ts Updates speculative telemetry fixture.
extensions/copilot/src/extension/inlineEdits/test/node/nextEditProviderCaching.spec.ts Tests rejection attribution through cache.
extensions/copilot/src/extension/inlineEdits/test/node/nextEditCacheRebase.spec.ts Updates rebase telemetry fixture.
extensions/copilot/src/extension/inlineEdits/test/node/nextEditCacheCursorDistance.spec.ts Updates cursor-distance fixture.
extensions/copilot/src/extension/inlineEdits/test/node/nesXtabHistoryTracker.spec.ts Tests bounds and compaction.
extensions/copilot/src/extension/inlineEdits/node/nextEditResult.ts Exposes originating memory state.
extensions/copilot/src/extension/inlineEdits/node/nextEditProvider.ts Records qualifying rejections.

Review details

  • Files reviewed: 17/17 changed files
  • Comments generated: 1
  • Review effort level: Medium
Comment thread extensions/copilot/src/extension/xtab/common/promptCrafting.ts Outdated
Comment thread extensions/copilot/src/platform/inlineEdits/common/statelessNextEditProvider.ts Outdated
Comment thread extensions/copilot/src/platform/inlineEdits/common/dataTypes/xtabPromptOptions.ts Outdated
Comment thread extensions/copilot/src/extension/inlineEdits/node/nextEditProvider.ts Outdated
Comment thread extensions/copilot/src/extension/inlineEdits/node/nextEditProvider.ts Outdated
Comment thread extensions/copilot/src/extension/xtab/common/promptCrafting.ts Outdated
Comment thread extensions/copilot/src/extension/xtab/common/promptCrafting.ts
Comment thread extensions/copilot/src/extension/xtab/common/diffHistoryForPrompt.ts Outdated
Comment thread extensions/copilot/src/extension/xtab/common/diffHistoryForPrompt.ts Outdated
@ulugbekna
Ulugbek Abdullaev (ulugbekna) merged commit be449c2 into microsoft:main Aug 7, 2026
29 checks passed
@vs-code-engineering vs-code-engineering Bot added this to the 1.133.0 milestone Aug 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

6 participants