Description
When a model sends two apply_patch calls for the same file in one response, both calls can read the original file. Both report success, but the last write overwrites the first change.
I reproduced this with GPT-6.1 Sol and "permission": { "edit": "ask" }: both approval prompts showed the original file, I approved both, and only the second change was kept.
The edit tool already serializes same-file edits with a per-file lock (#23483), but apply_patch does not. Related but different: #31776 and PR #47956 concern a file changed outside OpenCode during approval.
Plugins
None
OpenCode version
1.18.34
Steps to reproduce
-
Create settings.txt with:
top = 0
middle = keep
bottom = 0
-
Create opencode.json with:
{
"$schema": "https://opencode.ai/config.json",
"permission": {
"edit": "ask"
}
}
-
Start OpenCode 1.18.34 and select GPT-6.1 Sol.
-
Send this prompt:
In settings.txt, change top = 0 to top = 1 and bottom = 0 to bottom = 2. Use two separate apply_patch calls, sent in parallel in the same response.
-
Confirm that both apply_patch calls appear in the same assistant response and that both approval requests show the original file.
-
Approve both requests.
Expected result
top = 1
middle = keep
bottom = 2
Actual result
Both calls report success, but the final file contains:
top = 0
middle = keep
bottom = 2
Screenshot and/or share link
No response
Operating System
macOS 26.3
Terminal
Terminal.app
Description
When a model sends two
apply_patchcalls for the same file in one response, both calls can read the original file. Both report success, but the last write overwrites the first change.I reproduced this with GPT-6.1 Sol and
"permission": { "edit": "ask" }: both approval prompts showed the original file, I approved both, and only the second change was kept.The
edittool already serializes same-file edits with a per-file lock (#23483), butapply_patchdoes not. Related but different: #31776 and PR #47956 concern a file changed outside OpenCode during approval.Plugins
None
OpenCode version
1.18.34
Steps to reproduce
Create
settings.txtwith:Create
opencode.jsonwith:{ "$schema": "https://opencode.ai/config.json", "permission": { "edit": "ask" } }Start OpenCode 1.18.34 and select GPT-6.1 Sol.
Send this prompt:
Confirm that both
apply_patchcalls appear in the same assistant response and that both approval requests show the original file.Approve both requests.
Expected result
Actual result
Both calls report success, but the final file contains:
Screenshot and/or share link
No response
Operating System
macOS 26.3
Terminal
Terminal.app