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: full-file write reports success but file on disk is silently truncated (2.2.2) #60561
Summary
A write of a large file returns success, but the file on disk is silently truncated. No error, no truncation signal, no recovery offered. A separate case: an edit reports "1 replacement" success while the file is completely unchanged on disk.
Environment
opencode version: 2.2.2 (latest channel)
OS: Windows 11 build 26300 (win32 x64)
Terminal: Windows Terminal — Shell: pwsh
Remote model via provider API (GLM-5.3 / deepinfra), subagent session
Active plugins: compaction, deepinfra-costs, ponytail, opencode-claude
Reproduction
Have an agent perform a single write of a ~80 KB / ~1600-line file (a PowerShell script in our case).
The tool call returns success.
The file on disk is ~57 KB / 1285 lines — the tail is cut at a syntactically valid boundary.
Expected Behavior
Either the file is written in full, or the tool reports failure/truncation with a recovery path.
The truncated file parses cleanly (PowerShell AST parser: 0 errors) while missing the entry point and 7 functions that the surviving code still calls — syntax-level verification gives a false green.
Separately, an edit call reported "1 replacement" success with the file completely unchanged on disk.
Additional Context
Distinct from the abort/doom-loop outcomes tracked in #18108 (closed as 1.x-era): in this variant the truncation is a silent success, so the model never learns it should retry. Workaround we enforce: targeted edits only, mandatory read-back after every write, chunked on-disk assembly for large files. Related: #19604, #29779.
Plugins
No response
OpenCode version
2.2.2
Steps to reproduce
Have an agent perform a single write of a ~80 KB / ~1600-line file (a PowerShell script in our case).
The tool call returns success.
The file on disk is ~57 KB / 1285 lines — the tail is cut at a syntactically valid boundary.
In 2.2.2 the write tool writes the content argument it receives to disk exactly as given; there is no size limit or truncation step. So a write reporting success while leaving a shorter file is most likely caused by one of these:
the content the model sent (or that a plugin passed on) was already ~57 KB,
a formatter configured for .ps1 rewrote the file after the write, or
To narrow it down, could you share, in your own words:
Tool call content: Did the content of the truncated write call really hold the full ~1600 lines? You can check by exporting the session (opencode export <sessionID>) and looking at the length of that tool call's content, or by expanding the tool call in the UI.
Other agents: Were other subagents or the parent session running at the same time and possibly writing to or editing the same file?
Formatter: Do you have a formatter configured that applies to .ps1 files?
Plugins: Does it still happen with the plugins disabled (especially ponytail, opencode-claude and compaction)?
Logs: Any log lines from around the write and the no-op edit.
You can reply here with the details, or edit the issue. If you edit it, please also leave a comment saying you've updated it so we know you're done editing.
Retracting this one — the session export settles it, and it's on our side, not the harness. No write tool call ever targeted the file: it was assembled via shell WriteAllText and the agent's own splice logic dropped the tail between two #region markers; the separate "edit no-op" also shows applied and verified in the export. No formatter, no concurrency in the timeline. The only harness-level hardening relevant to anything we saw is the transaction lock in #60552 — happy to leave this closed as not planned. Sorry for the noise.
Closing this for now, since we haven't heard back. In 2.2.2 the write tool writes the content it receives to disk exactly as given. To find the cause we needed to know four things: whether that tool call's content really held the full ~1600 lines, whether another agent was writing to the same file at the same time, whether a formatter is set up for .ps1 files, and whether it still happens with the plugins disabled.
If you can share those details, or it happens again, please reply here or open a new issue and we'll take another look. A concurrent update to the same file can also produce a silent success. That problem is tracked in #60509 (fix PR #60552), so you may want to follow it. Thanks for the report!
Activity
opencodejr commentedon Oct 30, 2026
Thanks for the report, @gianvoci.
In 2.2.2 the
writetool writes thecontentargument it receives to disk exactly as given; there is no size limit or truncation step. So a write reporting success while leaving a shorter file is most likely caused by one of these:contentthe model sent (or that a plugin passed on) was already ~57 KB,.ps1rewrote the file after the write, orTo narrow it down, could you share, in your own words:
contentof the truncatedwritecall really hold the full ~1600 lines? You can check by exporting the session (opencode export <sessionID>) and looking at the length of that tool call'scontent, or by expanding the tool call in the UI..ps1files?ponytail,opencode-claudeandcompaction)?You can reply here with the details, or edit the issue. If you edit it, please also leave a comment saying you've updated it so we know you're done editing.
Related issues, most likely first:
editandwritecan silently lose a concurrent update to the same file, while both report success (open fix PR: fix(core): take the write tool's transaction lock #60552)writeon Windows (2.2.0) never runs because the turn is cut offgianvoci commentedon Oct 30, 2026
Retracting this one — the session export settles it, and it's on our side, not the harness. No write tool call ever targeted the file: it was assembled via shell WriteAllText and the agent's own splice logic dropped the tail between two #region markers; the separate "edit no-op" also shows applied and verified in the export. No formatter, no concurrency in the timeline. The only harness-level hardening relevant to anything we saw is the transaction lock in #60552 — happy to leave this closed as not planned. Sorry for the noise.
opencodejr commentedon Nov 2, 2026
Closing this for now, since we haven't heard back. In 2.2.2 the
writetool writes thecontentit receives to disk exactly as given. To find the cause we needed to know four things: whether that tool call'scontentreally held the full ~1600 lines, whether another agent was writing to the same file at the same time, whether a formatter is set up for.ps1files, and whether it still happens with the plugins disabled.If you can share those details, or it happens again, please reply here or open a new issue and we'll take another look. A concurrent update to the same file can also produce a silent success. That problem is tracked in #60509 (fix PR #60552), so you may want to follow it. Thanks for the report!