published fresh until

Why is OpenCode stuck on 'Preparing write...' and what helps?

Summary If OpenCode hangs at Preparing write... or reports an aborted tool execution, split large writes and inspect the saved file; an October 30 user report on 2.2.2 describes silent truncation after success.

Not for OpenCode shell approval rules; see opencode-permissions-allow-ask-deny

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

As of November 2026, split large writes and inspect the resulting file. Do first: interrupt the stalled write and request smaller chunks; a 2.2.2 user report also describes silent truncation after a success result.

The problem

OpenCode shows "Preparing write..." and then hangs or prints "Tool execution aborted", mostly when the model writes a large new file such as a plan or spec. The GitHub issue (opened 2026-01-29 by yinzhou-jc) was closed as a duplicate on 2026-10-01. Commenters saw it with GitHub Copilot models, Anthropic models via several providers, DeepSeek and Kimi; some said Gemini and GLM worked.

What a member said

On 2026-10-01 an OpenCode member closed it as a duplicate of #18108, saying a stuck "Preparing write..." usually means the tool call was cut off at the model's output token limit and OpenCode neither reports that clearly nor recovers. The author of #18108 (a user's analysis, not an official statement) adds that the default output cap is 32,000 tokens and that thinking tokens share the budget, so large files can be truncated even when they look small. On 2026-10-11 a maintainer closed #18108 as not planned in a sweep of every issue filed against OpenCode 1, asking people to reopen or file again if it still happens on 2.0. One commenter on #11112 reported the same symptom on OpenCode v2.0.19 on 2026-09-29. A later report in #18108 on 2026-10-30 describes a different failure on 2.2.2: a large write reported success but left a truncated file; an edit also reportedly left its file unchanged. This is a user report, not a maintainer diagnosis of the 2.2.2 behavior.

One commenter suggested it may sometimes be slow rather than frozen: with a captured session they said waiting long enough let the write finish, and several asked for a progress or token counter. That is an opinion, not a maintainer finding.

What commenters report helping

  • Ask for smaller writes: tell the session, or put it in AGENTS.md, to write big documents in batches or to split the file. Commenters reported this working with Opus and Sonnet 4.6, but it is a mitigation, one said not 100%.
  • Raise the output limit: The V1 CLI reference lists the environment variable OPENCODE_EXPERIMENTAL_OUTPUT_TOKEN_MAX ("Max output tokens for LLM responses"), and the model docs show limit.output in model config. The environment variable is documented for V1; neither doc says this fixes the hang; it is a lever consistent with the member's explanation. Do not set it above what your model supports.
  • Switch model or tool: a commenter found that after interrupting and asking the model to use edit instead of write, it worked.
  • Reported, riskier: one commenter set edit to deny and bash to allow in the permission config so the model writes through shell commands. That removes the edit approval path, so only consider it if you accept the bash risk; see the thread on OpenCode permissions.

Caveats

#18108 was filed against OpenCode 1.x and closed in the 2.0 sweep, while #11112 was closed as a duplicate on 2026-10-01 and has a later report from v2.0.19, so closure alone does not establish a fix. The October 30 report adds a reason to inspect the saved file even after a tool reports success; its author recommends smaller edits, chunked assembly and reading the file back.

Sources

Started from a post by @yinzhou-jc, packaged by the editor. Original post

Subjects

More in agent workflows

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# Why is OpenCode stuck on 'Preparing write...' and what helps?
Summary: If OpenCode hangs at `Preparing write...` or reports an aborted tool execution, split large writes and inspect the saved file; an October 30 user report on `2.2.2` describes silent truncation after success.
Copy for agent
get the whatworks thread opencode-stuck-preparing-write-output-token-limit and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread opencode-stuck-preparing-write-output-token-limit
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp/login and sign me in so I have an account. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp/login && claude mcp login whatworks
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp/login && codex mcp login whatworks