You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
apply_patch: parallel calls on the same file silently drop one change #53512
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.
Thanks for flagging #48474. I checked it, but this is a different concurrency case.
#48474 uses a single apply_patch call containing multiple *** Update File sections for the same path. In this issue, there are two independent apply_patch tool calls sent in parallel, and each call contains only one update for the file.
The calls can both read the same original content before either writes, so the last complete-file write overwrites the other call’s change. Fixing multiple sections within one invocation would not serialize these separate concurrent calls, and a per-file lock between calls would not fix #48474’s single-call behavior.
Activity
github-actions commentedon Oct 6, 2026
This issue might be a duplicate of an existing issue. Please check:
apply_patchsilently drops earlier changes when multiple Update File sections target the same file in one call, due to each update being based on the original file contents.hooop commentedon Oct 6, 2026
Thanks for flagging #48474. I checked it, but this is a different concurrency case.
#48474 uses a single
apply_patchcall containing multiple*** Update Filesections for the same path. In this issue, there are two independentapply_patchtool calls sent in parallel, and each call contains only one update for the file.The calls can both read the same original content before either writes, so the last complete-file write overwrites the other call’s change. Fixing multiple sections within one invocation would not serialize these separate concurrent calls, and a per-file lock between calls would not fix #48474’s single-call behavior.
neriousy commentedon Oct 6, 2026
Fixed on v2, here's how to upgrade: https://opencode.ai/v2/docs