Skip to content

apply_patch fails to replace the whole contet of files #281733

@tamuratak

Description

@tamuratak

Version: 1.107.0-insider (Universal)
Commit: 6b29ec0
Date: 2025-12-05T22:20:51.110Z
Electron: 39.2.3
ElectronBuildId: 12895514
Chromium: 142.0.7444.175
Node.js: 22.21.1
V8: 14.2.231.21-electron.0
OS: Darwin arm64 24.6.0

Name: GitHub Copilot Chat
Id: GitHub.copilot-chat
Description: AI chat features powered by Copilot
Version: 0.35.2025120504
Publisher: GitHub
VS Marketplace Link: https://marketplace.visualstudio.com/items?itemName=GitHub.copilot-chat

Using gpt-5-mini.

apply_patch fails to replace the entire content of files. At the beginning of its argument, the string '```markdown' appears, which may be causing the issue. When that string is removed, apply_patch works correctly.

  1. Create a file t.md
    "type": "git",
    "url": "https://github.com/tamuratak/vscode-able.git"
  },
  "engines": {
    "vscode": "^1.106.1"
  },
  "files": [
    "pyodide/pyodide/*.json",
    "pyodide/pyodide/*.ts",
    "pyodide/pyodide/*.js",
    "pyodide/pyodide/*.mjs",
    "pyodide/pyodide/*.wasm",
    "pyodide/pyodide/micropip*",
    "node_modules",
    "out",
    "LICENSE"
  ],
  "capabilities": {
    "virtualWorkspaces": true,
    "untrustedWorkspaces": {
      "supported": true
    }
  },
  "enabledApiProposals": [
    "embeddings",
    "chatParticipantAdditions",
    "chatProvider",
    "languageModelSystem",
    "languageModelThinkingPart"
  ],
  "contributes": {
    "authentication": [
      {
        "id": "gemini_api",
        "label": "Gemini (with Able)"
      },
      {
        "id": "openai_api",
  1. Tell Agent
- When using apply_patch, please note that Delete File is not supported. 
- Replace the whole content of #file:t.md  with the following. 

```
a

b

c

```
  1. After edited, t.md becomes
    "type": "git",
    "url": "https://github.com/tamuratak/vscode-able.git"
  },
  "engines": {
    "vscode": "^1.106.1"
  },
  "files": [
    "pyodide/pyodide/*.json",
    "pyodide/pyodide/*.ts",
    "pyodide/pyodide/*.js",
    "pyodide/pyodide/*.mjs",
    "pyodide/pyodide/*.wasm",
    "pyodide/pyodide/micropip*",
    "node_modules",
    "out",
    a

    b

    c

The argument of apply_patch begins with '```markdown', which might causes the issue.

id   : call_WKUiqipxAAZWKqUMhJjwARKL__vscode-1764995950953
tool : apply_patch
args : {
  "input": "*** Begin Patch
*** Update File: /Users/tamura/src/github/vscode-able/t.md
@@
-```markdown
-
-    \"type\": \"git\",
-    \"url\": \"https://github.com/tamuratak/vscode-able.git\"
-  },
-  \"engines\": {
-    \"vscode\": \"^1.106.1\"
-  },
-  \"files\": [
-    \"pyodide/pyodide/*.json\",
-    \"pyodide/pyodide/*.ts\",
-    \"pyodide/pyodide/*.js\",
-    \"pyodide/pyodide/*.mjs\",
-    \"pyodide/pyodide/*.wasm\",
-    \"pyodide/pyodide/micropip*\",
-    \"node_modules\",
-    \"out\",
-    \"LICENSE\"
-  ],
-  \"capabilities\": {
-    \"virtualWorkspaces\": true,
-    \"untrustedWorkspaces\": {
-      \"supported\": true
-    }
-  },
-  \"enabledApiProposals\": [
-    \"embeddings\",
-    \"chatParticipantAdditions\",
-    \"chatProvider\",
-    \"languageModelSystem\",
-    \"languageModelThinkingPart\"
-  ],
-  \"contributes\": {
-    \"authentication\": [
-      {
-        \"id\": \"gemini_api\",
-        \"label\": \"Gemini (with Able)\"
-      },
-      {
-        \"id\": \"openai_api\",
+a
+
+b
+
+c
+
*** End Patch",
  "explanation": "Replace entire file content with the three requested lines"
}

__When_using_apply_patch__please_note_that_Delete__logs.chatreplay.json

panel_editAgent_9de6a602.copilotmd

Metadata

Metadata

Assignees

Labels

bugIssue identified by VS Code Team member as probable bug

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions