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 hangs indefinitely in 1.4.6 (works in 1.4.3) #22872
The write tool in OpenCode 1.4.6 hangs indefinitely on any content size (verified with 20-char content). The tool call enters "running" state with the content in its input, but never transitions to "completed". Works fine in 1.4.3.
Environment
OpenCode 1.4.6 (Docker container: node:20-slim base, Linux x86_64)
Anthropic Sonnet 4.6 provider
No LSP configured (pyright not installed in container)
Reproduction
Create a session and ask Milo to write a tiny file:
curl -X POST http://127.0.0.1:4096/session/$SES/message \
-d '{"parts":[{"type":"text","text":"Use the write tool to create /tmp/hello.py containing: print(\"hello\")"}]}'
Tool state after 60s:
tool=write status=running
input.filePath=/tmp/hello.py
input.content=print("hello")
No output, no time.end
File is not created on disk.
Suspected cause
PR #21901 refactored WriteTool from Tool.define to Tool.defineEffect with LSP service integration:
Yields LSP.Service in the outer Effect.gen
Calls lsp.touchFile and lsp.diagnostics on the written file
If no LSP is configured or auto-detected, the Effect chain may not complete.
Workaround
Use bash with heredocs instead of write:
timeout 120 python3 << 'EOF'# scriptEOF
Tested, not affected
Bash tool with heredocs: works fine (12s for 828KB output)
Plain text streaming (no tool): works fine (73 tokens/sec)
This issue might be a duplicate of existing issues. Please check:
LSP server spawn hangs indefinitely when download/build fails, blocking all file tools #20824: Describes the exact same root cause — LSP server spawn hanging indefinitely in a container environment blocks getClients() which is called by touchFile() after every Write tool execution, causing the tool to hang in "running" state permanently. The environment (container with blocked/no network) and mechanism match closely.
If your issue is specifically triggered by the LSP integration added in PR #21901 (as you suspect), #20824 in particular covers the same scenario in detail.
Our opencode.json has permission.edit: "ask". Milo writes PDF/Excel scripts to /tmp/ (outside the project WORKDIR /workspace). In server mode with no UI to answer the external-directory permission prompt, the write tool hangs forever waiting for approval.
Our pattern was:
python3 << PYEOF # bash heredoc — works in 1.4.6
...
PYEOF
versus the skill guidance to use write tool for the script file. The bash path avoids the permission gate entirely.
So this is NOT a 1.4.6 regression — the permission gate has likely always existed; we just didn't hit it on 1.4.3 because our skill pushed Milo toward write AFTER the upgrade.
Fix on our side: change edit: "ask" → edit: "allow" in opencode.json, or handle the external-directory approval via the server API. Closing this as not-a-bug from OpenCode's side.
For anyone else hitting this: symptom is write tool stuck in "running" state indefinitely with no output and file not created on disk. Check permission.edit in your agent config.
Reopening with correction — my closing comment was wrong.
After setting permission.edit: "allow" and permission.write: "allow" in opencode.json, the write tool STILL hangs in our container. Tested with print("ok") (11 chars) — 60s timeout, file never created on disk.
So permissions were not the cause. This looks like the LSP spawn hang (#20824) — our Linux container doesn't have a Python LSP installed, and the write tool's post-write LSP.touchFile() → getClients() → await inflight hangs when no LSP is available to spawn.
Workaround: we route document generation through bash heredocs which don't call LSP. That works fine.
Leaving this open since #20824's fix (timeout on LSP spawn inflight, or bypass touchFile when no LSP configured) would resolve it. Apologies for the noise in closing prematurely.
Confirmed fix: adding \"external_directory\": \"allow\" to the agent's permission block solved it. Write tool completed in 2.0s and file was created on disk.
Setting just edit and write to allow was insufficient — the external directory check is a separate permission key that specifically governs writes outside WORKDIR. Fully our config bug, not OpenCode.
Activity
github-actions commentedon Apr 16, 2026
This issue might be a duplicate of existing issues. Please check:
getClients()which is called bytouchFile()after every Write tool execution, causing the tool to hang in "running" state permanently. The environment (container with blocked/no network) and mechanism match closely.writetool causes client to hang indefinitely when creating a new file #15675:writetool hangs indefinitely when creating a new file (no completion signal sent).If your issue is specifically triggered by the LSP integration added in PR #21901 (as you suspect), #20824 in particular covers the same scenario in detail.
rekram1-node commentedon Apr 16, 2026
I think your inference is just taking a long time, I cannot replicate your issue.
rekram1-node commentedon Apr 16, 2026
Are you sure you werent just prompted for external directory permission? Because that would block
test: add reproducer for write tool hanging on slow LSP initialize (#…
test: add reproducer for Npm.which-forever hang in Pyright spawn
fix: bound LSP diagnostic enrichment in write/edit/apply_patch (#22872)
DLME2024 commentedon Apr 16, 2026
Thanks both — rekram1-node nailed it.
Our
opencode.jsonhaspermission.edit: "ask". Milo writes PDF/Excel scripts to/tmp/(outside the project WORKDIR/workspace). In server mode with no UI to answer the external-directory permission prompt, the write tool hangs forever waiting for approval.Our pattern was:
versus the skill guidance to use
writetool for the script file. The bash path avoids the permission gate entirely.So this is NOT a 1.4.6 regression — the permission gate has likely always existed; we just didn't hit it on 1.4.3 because our skill pushed Milo toward
writeAFTER the upgrade.Fix on our side: change
edit: "ask"→edit: "allow"inopencode.json, or handle the external-directory approval via the server API. Closing this as not-a-bug from OpenCode's side.For anyone else hitting this: symptom is write tool stuck in "running" state indefinitely with no output and file not created on disk. Check
permission.editin your agent config.DLME2024 commentedon Apr 17, 2026
Reopening with correction — my closing comment was wrong.
After setting
permission.edit: "allow"andpermission.write: "allow"inopencode.json, the write tool STILL hangs in our container. Tested withprint("ok")(11 chars) — 60s timeout, file never created on disk.So permissions were not the cause. This looks like the LSP spawn hang (#20824) — our Linux container doesn't have a Python LSP installed, and the write tool's post-write
LSP.touchFile()→getClients()→await inflighthangs when no LSP is available to spawn.Workaround: we route document generation through bash heredocs which don't call LSP. That works fine.
Leaving this open since #20824's fix (timeout on LSP spawn inflight, or bypass
touchFilewhen no LSP configured) would resolve it. Apologies for the noise in closing prematurely.rekram1-node commentedon Apr 17, 2026
@DLME2024 it's the external_directory permission ur looking for prolly.
rekram1-node commentedon Apr 17, 2026
there are a lot of permissions options tho, by default external_directory is the only one that seems to bite u tho.
DLME2024 commentedon Apr 17, 2026
Confirmed fix: adding
\"external_directory\": \"allow\"to the agent'spermissionblock solved it. Write tool completed in 2.0s and file was created on disk.Setting just
editandwritetoallowwas insufficient — the external directory check is a separate permission key that specifically governs writes outside WORKDIR. Fully our config bug, not OpenCode.Full working block:
Closing for real this time. Thanks @rekram1-node for the patience — you called it twice.
test: add reproducer for write tool hanging on slow LSP initialize (a…
test: add reproducer for Npm.which-forever hang in Pyright spawn
fix: bound LSP diagnostic enrichment in write/edit/apply_patch (anoma…