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
Write tool fails silently on large files (~1000+ lines) #19604
The Write tool has started failing silently when writing files approximately 1000+ lines long. The tool call appears to execute but returns a failure/abort with no error message. This happens consistently — multiple retries produce the same result.
Impact
High — this drastically reduces productivity for any task that involves creating documentation or large code files. The user has to manually notice the repeated failures and intervene with guidance to write in sections.
Reproduction
Have the agent attempt to write a markdown file that would be ~800-1200+ lines in a single Write tool call
The tool call fails/aborts silently — no content is written, no error message is returned
Retrying produces the same failure
Workaround
Writing the file in smaller sections (create with first ~300-400 lines, then use Edit to append subsequent sections) works reliably. But the agent doesn't do this automatically — the user has to catch the failure pattern and instruct the agent to use this approach.
Expected behavior
Either:
Write should handle files of any reasonable size (at least up to several thousand lines), OR
Write should return a clear error message when the content exceeds a size limit, so the agent can automatically fall back to writing in sections
Additional context
This appears to be a recent regression — large file writes worked previously
Interesting this particular file it was having issues writing wasn't related to a very long file, it was 574 lines total so maybe it's related to context being too large that it needs to include when writing the file?
opencode had said this when it successfully wrote the file in pieces:
Good — the splice worked. The locked decisions table is in hub-people-design.md (lines 55-97) with all 41 rows, properly formatted. The 703A source has the verbose originals. Now let me read the source material for the next sections I need to add.
Heads-up — #24529 looks like a related-but-distinct bug in the same area. There the edit tool does write the file to disk, but a downstream crash (output.args.filePath undefined) marks the call Failed in the TUI while the model still receives Edit applied successfully. and proceeds. PR #24537 is open with a fix.
Different symptom from this one (here, no content is written and the model never sees an error), but same theme of tool failures not propagating cleanly. I just commented there confirming a second setup hitting it, in case the maintainers want to cross-reference.
This is such a frequent issue for me. I use opencode for a lot of research and quick POCs and that involves writing large files. OpenCode fails to write quite consistently.
Instructing it to write in batches is the only way around it. But it's not efficient because that involves unnecessary back and forth.
in my experience i observed edit/write tools may fail when vram is too tight or if model too dumb. as a workaround i added to system prompt to just use shell/pwsh for editing/creating files, but that sometimes also fails for complex text (eg quotes back ticks etc). currently using qwen 3.6 27b on rtx 4080 super. playing with context size and gpu offload can help at some extent
Looks like I found the issue in my setup: I am using the opencode-tool-search plugin to reduce context usage by deferring tool descriptions. Maybe that plugin is not compatible any more with the latest OpenCode release.
After uninstalling the plugin, things are working a lot better again.
EDIT: I have to amend my findings. While at first it seemed to have solved a few issues, using OpenCode without the tool search plugin for more tasks showed that it did not really help. Similar to what others mentioned above, it works fine for "smaller writes" but fails when writing a lot of text/code.
This is not model specific, all our used models have the same issue. It fails on our small self-hosted model (Qwen Coder 30B), on larger hosted models (e.g. GPT OSS 120B) and even on the models provided by the OpenCode team (e.g. Big Pickle).
I experienced the same issue right now when trying to write a PRD after a grilling session.
After having no other choice I prompted my agent to write 10 Lines at a time. This actually worked but used a ton of tool calls for a 35K document.
What I experienced. There seemed to also be a confusion since I renamed a file which had a different name in the context. It seemed to have a problem with that aswell.
I found the following in the opencode logs:
I've updated to 1.18 the other day and it seems to work a lot better. I tried several times to let it write larger Markdown files and that worked without any issues.
I've updated to 1.18 the other day and it seems to work a lot better. I tried several times to let it write larger Markdown files and that worked without any issues.
I've been using opencode for about 30 minutes after using Codex and Claude Code the last few weeks. already had the write fail issue. I'm on version 1.18.4. Luckily I know about it and can quickly give it a number that doesn't slow it down too much and it can keep working.
I ran into this today using some of the most expensive models. This burned a lot of my Zen funds re-debugging this. It would be great if the write Failed errors provided some description of what went wrong.
I also get this bug, but theres no failures at all, the model keeps looping, thinking it needs to write the file. Experiencing this with Kimi K3 (custom provider). When i tell it to write it in parts, that it might be a bug, it all of a sudden writes the files fine and stops looping.
Closing as a duplicate of #18108. Large write calls usually fail because the tool call gets cut off at the model's output token limit, and OpenCode doesn't report that clearly or recover from it. Please follow and 👍 there.
Activity
github-actions commentedon Mar 29, 2026
This issue might be a duplicate of existing issues. Please check:
Please review those issues and comment if yours is distinct.
jdocker8 commentedon Mar 29, 2026
Interesting this particular file it was having issues writing wasn't related to a very long file, it was 574 lines total so maybe it's related to context being too large that it needs to include when writing the file?
opencode had said this when it successfully wrote the file in pieces:
jdocker8 commentedon Mar 30, 2026
Examples of the issue in my 2 current sessions:
jdocker8 commentedon May 6, 2026
Heads-up — #24529 looks like a related-but-distinct bug in the same area. There the
edittool does write the file to disk, but a downstream crash (output.args.filePathundefined) marks the call Failed in the TUI while the model still receivesEdit applied successfully.and proceeds. PR #24537 is open with a fix.Different symptom from this one (here, no content is written and the model never sees an error), but same theme of tool failures not propagating cleanly. I just commented there confirming a second setup hitting it, in case the maintainers want to cross-reference.
phitonthel commentedon May 6, 2026
Can confirm, having a similar issue with
writetooljdocker8 commentedon May 22, 2026
I wanted to mention I still see this issue on a regular basis, including another example from today:
amirasyraf commentedon May 30, 2026
This is such a frequent issue for me. I use opencode for a lot of research and quick POCs and that involves writing large files. OpenCode fails to write quite consistently.
Instructing it to write in batches is the only way around it. But it's not efficient because that involves unnecessary back and forth.
Devilstriker-v2 commentedon Jun 2, 2026
Also having the same issue. Any plans to fix it, as this is probably(at least for me) the most annoying in the moment.
ChanifRusydi commentedon Jun 4, 2026
Also having the same issue, although no silently and rather intermittently.
The error message in my case is as follows :
Orqino commentedon Jun 9, 2026
What is the status of this topic? Can't believe that this is not the most annoying bug for everyone at the moment.
lorenzoridolfi commentedon Jun 23, 2026
I am experiencing the same issue. It's a major bug, and the OpenCode team does not seem to be giving it the necessary attention required to fix it.
lorenzoridolfi commentedon Jun 23, 2026
With version 1.17.9, the situation is even worse, and the problem occurs much more often!
shochdoerfer commentedon Jun 29, 2026
I have the same issues with 1.17.11. Can't get any work done today ;(
SynapseScribe commentedon Jun 29, 2026
in my experience i observed edit/write tools may fail when vram is too tight or if model too dumb. as a workaround i added to system prompt to just use shell/pwsh for editing/creating files, but that sometimes also fails for complex text (eg quotes back ticks etc). currently using qwen 3.6 27b on rtx 4080 super. playing with context size and gpu offload can help at some extent
shochdoerfer commentedon Jun 30, 2026
Looks like I found the issue in my setup: I am using the opencode-tool-search plugin to reduce context usage by deferring tool descriptions. Maybe that plugin is not compatible any more with the latest OpenCode release.
After uninstalling the plugin, things are working a lot better again.
EDIT: I have to amend my findings. While at first it seemed to have solved a few issues, using OpenCode without the tool search plugin for more tasks showed that it did not really help. Similar to what others mentioned above, it works fine for "smaller writes" but fails when writing a lot of text/code.
This is not model specific, all our used models have the same issue. It fails on our small self-hosted model (Qwen Coder 30B), on larger hosted models (e.g. GPT OSS 120B) and even on the models provided by the OpenCode team (e.g. Big Pickle).
lraubuch commentedon Jul 2, 2026
I experienced the same issue right now when trying to write a PRD after a grilling session.
After having no other choice I prompted my agent to write 10 Lines at a time. This actually worked but used a ton of tool calls for a 35K document.
What I experienced. There seemed to also be a confusion since I renamed a file which had a different name in the context. It seemed to have a problem with that aswell.
I found the following in the opencode logs:
bateau84 commentedon Jul 4, 2026
i am experiencing the same thing on version 1.17.13
shochdoerfer commentedon Jul 18, 2026
I've updated to 1.18 the other day and it seems to work a lot better. I tried several times to let it write larger Markdown files and that worked without any issues.
jdocker8 commentedon Jul 20, 2026
I've been using opencode for about 30 minutes after using Codex and Claude Code the last few weeks. already had the write fail issue. I'm on version 1.18.4. Luckily I know about it and can quickly give it a number that doesn't slow it down too much and it can keep working.
jpedrick commentedon Jul 28, 2026
I ran into this today using some of the most expensive models. This burned a lot of my Zen funds re-debugging this. It would be great if the
write Failederrors provided some description of what went wrong.brambora69123 commentedon Aug 27, 2026
I also get this bug, but theres no failures at all, the model keeps looping, thinking it needs to write the file. Experiencing this with Kimi K3 (custom provider). When i tell it to write it in parts, that it might be a bug, it all of a sudden writes the files fine and stops looping.
neriousy commentedon Oct 1, 2026
Closing as a duplicate of #18108. Large
writecalls usually fail because the tool call gets cut off at the model's output token limit, and OpenCode doesn't report that clearly or recover from it. Please follow and 👍 there.