Skip to content

write tool hangs indefinitely in 1.4.6 (works in 1.4.3) #22872

Closed as not planned

Description

@DLME2024

OpenCode 1.4.6 — write tool hangs indefinitely

Summary

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'
# script
EOF

Tested, not affected

  • Bash tool with heredocs: works fine (12s for 828KB output)
  • Plain text streaming (no tool): works fine (73 tokens/sec)
  • MCP tool calls: works fine

Only write tool is affected.

Activity

  1. added
    core
    on Apr 16, 2026
  2. github-actions commented on Apr 16, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

    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.

  3. rekram1-node commented on Apr 16, 2026

    @rekram1-node
    Member

    I think your inference is just taking a long time, I cannot replicate your issue.

  4. rekram1-node commented on Apr 16, 2026

    @rekram1-node
    Member

    Are you sure you werent just prompted for external directory permission? Because that would block

  5. DLME2024 commented on Apr 16, 2026

    @DLME2024
    Author

    Thanks both — rekram1-node nailed it.

    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.

  6. DLME2024 commented on Apr 17, 2026

    @DLME2024
    Author

    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.

  7. rekram1-node commented on Apr 17, 2026

    @rekram1-node
    Member

    @DLME2024 it's the external_directory permission ur looking for prolly.

  8. rekram1-node commented on Apr 17, 2026

    @rekram1-node
    Member

    there are a lot of permissions options tho, by default external_directory is the only one that seems to bite u tho.

  9. DLME2024 commented on Apr 17, 2026

    @DLME2024
    Author

    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.

    Full working block:

    "permission": {
      "edit": "allow",
      "write": "allow",
      "bash": "allow",
      "external_directory": "allow"
    }

    Closing for real this time. Thanks @rekram1-node for the patience — you called it twice.

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

Metadata

Metadata

Assignees

Labels

core

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions