fix: sanitize apply content before file edits#12015
fix: sanitize apply content before file edits#12015yzlu0917 wants to merge 1 commit intocontinuedev:mainfrom
Conversation
💡 Codex Reviewcontinue/core/llm/llms/Ollama.ts Line 514 in 5a511e6 This now always attaches Line 230 in 5a511e6
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Summary
<think>...</think>blocks and Harmony protocol wrappers before apply/edit content is treated as file contentapplyCodeBlock()input and add regression tests covering both<think>contamination and Harmonyanalysis/finalchannel outputWhy
When upstream local-model stacks leak reasoning into the assistant content field, Continue's apply flow can treat that reasoning as the edit itself. In the worst case that means file edits and previews include model thoughts or Harmony control tokens instead of code.
This hardens the apply path against two concrete contamination patterns reported in
#10783:<think>...</think>reasoning blocksanalysisandfinalchannel wrappersValidation
npm run vitest -- util/stripReasoningFromApplyContent.vitest.ts edit/lazy/applyCodeBlock.vitest.tsincoreCloses #10783
Summary by cubic
Sanitizes apply/edit content to strip
<think>blocks and Harmony wrappers so model reasoning never gets written to files, previews, or search/replace results. Closes #10783.stripReasoningFromApplyContent()incore/utilto remove<think>blocks and extract the Harmonyfinalchannel (and strip tokens).core/edit/lazy/applyCodeBlockandextensions/vscode/src/apply/ApplyManagerso deterministic apply, diff previews, search/replace, and empty-file writes use clean text.Written for commit 5a511e6. Summary will update on new commits.