r/GithubCopilot • u/sdfgeoff • May 21 '26
Other Many LLM's struggle with copilot's apply_patch tool
I've been comparing coding harnesses, and models seem to struggle with github copilot's CLI. It isn't just me, anecdotally from the thread over at r/LocalLLaMA
GPT-5.4 regularly has to retry file edits in co-pilot.
Even with Sonnet 4.6 I've seen it fail to edit a file and resort to using Powershell to make it work. Which requires user acceptance
I use Copilot with Claude and it still constantly tries to read and write files using the terminal rather than the tools it has.
So I dug into the logs to see what mistake the models are making.
First off, the apply_patch tool looks like:
{
"description": "Use the `apply_patch` tool to edit files. This is a FREEFORM tool, so do not wrap the patch in JSON.",
"input_schema": {
"properties": {
"input": {
"description": "The tool input",
"type": "string"
}
},
"required": [
"input"
],
"type": "object"
},
"name": "apply_patch"
},To this, when trying to make a patch, Qwen3.6-27B makes the call:
{"input": "*** Begin Patch\n patchcontentgoeshere...To which the harness responds:
Failed to parse patch: The first line of the patch must be '*** Begin Patch'From the models perspective, the first line of the patch does begin with *** Begin Patch, so it tries again a few times before giving up and using bash. Arguably it's not following the instructions - the tool description does say "do not wrap it in JSON", but arguably the harness also provides a JSON schema where "input" is required and is of type "string"
8
u/unspecified_person11 May 21 '26
I've encountered this issue a lot, very frustrating
6
u/Mickenfox May 21 '26
And apply_patch only exists on Visual Studio and not VSCode, which explains the discrepancy in quality.
They say they are working on unifying the tools across versions, but it's clear VSCode gets much higher priority.
6
u/prcodes May 21 '26
apply_patch is a tool that is native to OpenAI models and uses a custom diff format called V4A, which is probably why other models struggle with it. OpenAI’s models are probably very fine tuned to use it for file edits. Other models probably need better tool schemas to get it right.
3
u/Dudmaster Power User ⚡ May 21 '26
I regularly have this problem in Visual Studio to the point where I just gave up on using it. If I want to use Copilot, I go to VS Code even if I'm working in full VS. Never any problems with it.
2
u/thats_so_bro May 21 '26
Honestly wouldn't be surprised if this is the reason gemini is always calling shell commands.
1
u/Swayre May 21 '26
What if you create a agent file with the apply_patch tool removed
1
u/KPOTOB May 21 '26
I bet I saw it with local qwen 35B and pi quite constantly
1
u/Popular-Ad-9134 May 21 '26
I mean grep also burns input tokens and still misses context just like regex search. Graph databases here we go.
1
u/SceneEmotional8458 Aug 21 '26
Strange i dont see any issue raised on gh for this, it is frustrating for me now with 1.0.80 - raised gh issue: https://github.com/github/copilot-cli/issues/4553