Skip to content

write: full-file write reports success but file on disk is silently truncated (2.2.2) #60561

Closed as not planned

Description

@gianvoci

Description

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

  1. Have an agent perform a single write of a ~80 KB / ~1600-line file (a PowerShell script in our case).
  2. The tool call returns success.
  3. 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.

Actual Behavior

  • write reports success; on-disk content is truncated (~80 KB → ~57 KB).
  • 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

  1. Have an agent perform a single write of a ~80 KB / ~1600-line file (a PowerShell script in our case).
  2. The tool call returns success.
  3. The file on disk is ~57 KB / 1285 lines — the tail is cut at a syntactically valid boundary.

Screenshot

No response

Operating System

windwos 11

Terminal

windows terminal

Activity

  1. opencodejr commented on Oct 30, 2026

    @opencodejr
    Contributor

    Thanks for the report, @gianvoci.

    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:

    1. the content the model sent (or that a plugin passed on) was already ~57 KB,
    2. a formatter configured for .ps1 rewrote the file after the write, or
    3. another write or edit touched the same file at the same time (see edit and write can silently lose a concurrent successful file update #60509 below). This could also explain the edit that reported "1 replacement" while the file stayed unchanged.

    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.

    Related issues, most likely first:

  2. gianvoci commented on Oct 30, 2026

    @gianvoci
    Author

    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.

  3. opencodejr commented on Nov 2, 2026

    @opencodejr
    Contributor

    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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions