Skip to content

write tool causes client to hang indefinitely when creating a new file #15675

Closed

Description

@javaabel

Description

Problem Description:
When using the write tool to create a new file, the client (IntelliJ IDEA) hangs indefinitely in the chat interface with a "waiting" indicator. The file is actually created successfully on disk, but the client never receives a completion signal. Manually clicking the "stop" button immediately reveals the created file.

In contrast, using the edit tool to modify an existing file or the bash tool to delete a file works perfectly – the client receives proper responses and the operation completes normally.

Environment:

  • OpenCode version: v1.2.15 (binary opencode-windows-x64.zip)
  • Client: IntelliJ IDEA using ACP protocol
  • OS: Windows11 (as per log paths)

Root Cause Analysis:
The write tool implementation lacks the necessary RPC response logic. After successfully writing the file, it should send a tool_call_update with status set to completed (or failed if an error occurs). However, no such update is transmitted, causing the client to wait indefinitely for a completion signal.

The edit and bash tools correctly send completion updates, which explains why those operations work without hanging.

This issue is independent of network timeouts or client-side problems; it is purely a server-side (agent) implementation flaw in the write tool.

Plugins

[email protected]

OpenCode version

v1.2.15 (binary opencode-windows-x64.zip)

Steps to reproduce

Key Log Evidence (from acp-transport-memory.log)

  1. write tool call that hangs (no completion)
    2026-03-02 15:39:23,641 [2836043] FINE - AcpTransport - IN: {"jsonrpc":"2.0","method":"session/update","params":{"sessionId":"ses_35283b57dffeWINHDUV6qYRQOw","update":{"sessionUpdate":"tool_call_update","toolCallId":"call_52f8706cb3434384a3905511","status":"in_progress","kind":"edit","title":"write","locations":[{"path":"D:\javaabel\Code\JavaCode\AI-DogV2\robot-platform\123.txt"}],"rawInput":{"content":"abc","filePath":"D:\javaabel\Code\JavaCode\AI-DogV2\robot-platform\123.txt"}}}}
    ... (no "completed" or "failed" update) ...
    2026-03-02 15:39:51,262 [2863664] FINE - AcpTransport - IN: {"jsonrpc":"2.0","method":"session/update","params":{"sessionId":"ses_35283b57dffeWINHDUV6qYRQOw","update":{"sessionUpdate":"tool_call_update","toolCallId":"call_52f8706cb3434384a3905511","status":"failed","kind":"edit","title":"write","rawInput":{"content":"abc","filePath":"D:\javaabel\Code\JavaCode\AI-DogV2\robot-platform\123.txt"},"content":[{"type":"content","content":{"type":"text","text":"Tool execution aborted"}}],"rawOutput":{"error":"Tool execution aborted"}}}}
    Note: The failed status only appears after the client sent a session/cancel request.

  2. edit tool call that completes normally
    2026-03-02 15:40:26,715 [2899117] FINE - AcpTransport - IN: {"jsonrpc":"2.0","method":"session/update","params":{"sessionId":"ses_35283b57dffeWINHDUV6qYRQOw","update":{"sessionUpdate":"tool_call_update","toolCallId":"call_47a04cc2904b43a8b63b5ccb","status":"in_progress","kind":"edit","title":"edit","locations":[{"path":"D:\javaabel\Code\JavaCode\AI-DogV2\robot-platform\123.txt"}],"rawInput":{"filePath":"D:\javaabel\Code\JavaCode\AI-DogV2\robot-platform\123.txt","edits":[{"op":"append","lines":"测试"}]}}}}
    2026-03-02 15:40:26,747 [2899149] FINE - AcpTransport - IN: {"jsonrpc":"2.0","method":"session/update","params":{"sessionId":"ses_35283b57dffeWINHDUV6qYRQOw","update":{"sessionUpdate":"tool_call_update","toolCallId":"call_47a04cc2904b43a8b63b5ccb","status":"completed","kind":"edit","content":[...]}}}

3. bash tool call that completes normally

2026-03-02 15:56:59,301 [3891703] FINE - AcpTransport - IN: {"jsonrpc":"2.0","method":"session/update","params":{"sessionId":"ses_35279d2c4ffeMLMaiiDATnI363","update":{"sessionUpdate":"tool_call_update","toolCallId":"call_64ea5e96379b46b1854a2251","status":"in_progress","kind":"execute","title":"bash","locations":[],"rawInput":{"command":"rm "D:\javaabel\Code\JavaCode\AI-DogV2\robot-platform\abc.txt"","description":"删除abc.txt文件"}}}}
2026-03-02 15:56:59,611 [3892013] FINE - AcpTransport - IN: {"jsonrpc":"2.0","method":"session/update","params":{"sessionId":"ses_35279d2c4ffeMLMaiiDATnI363","update":{"sessionUpdate":"tool_call_update","toolCallId":"call_64ea5e96379b46b1854a2251","status":"completed","kind":"execute","content":[...]}}}

Screenshot and/or share link

https://www.jetbrains.com/help/ai-assistant/2025.3/acp.html#install-agent-from-registry

acp.json:
{
"agent_servers": {
"OpenCode": {
"command": "D:\javaabel\Develop\opencode\opencode.exe",
"args": ["acp"]
}
}
}

Image

Operating System

windows 11

Terminal

No response

Activity

  1. added
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on Mar 2, 2026
  2. github-actions commented on Mar 2, 2026

    @github-actions
    Contributor

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

  3. minshiwu commented on Mar 2, 2026

    @minshiwu

    I also encountered this bug. As a result, the client UI hangs when the edit operation is performed and cannot be entered.

  4. sashimi409 commented on Mar 12, 2026

    @sashimi409

    Also running into this. I am trying to use JetBrains IDEs and as soon as I hit a new file write, I am stopped and have to break my workflow.

  5. removed
    bugSomething isn't working
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on May 3, 2026
  6. gzlo commented on May 6, 2026

    @gzlo

    I'm hitting this same bug consistently on v1.14.39 (Linux, TUI mode, provider opencode-go). Here's full forensic evidence from a live hung process — confirmed root cause is the missing RPC completion signal after tool calls complete.


    🔄 Reproduction

    • Any edit/write tool call in TUI interactive mode
    • Agent prepares edit → executes it → formatter runs → spinner spins forever
    • Process stays in State: R (running) consuming ~66% CPU indefinitely

    🔬 Live Process Forensics (captured while hung)

    Process state: State: R (running) — pure CPU busy-loop, NOT I/O blocked
    CPU: 66% sustained on one core
    read_bytes: 0 — zero disk I/O, confirming it's a spin, not waiting
    Threads: 18 total, all sleeping in futex_wait except main thread spinning in Bun JS runtime

    GDB backtrace of main thread:

    #0  0x000000000422dee6 in ?? ()   ← Bun JS runtime, no syscall → JavaScript-level spin
    

    All 17 other threads blocked in pthread_cond_timedwait (futex).

    Orphaned child process:

    PID 79063: node /path/to/prettier --write
    State: S (sleeping), UTIME=49ms    ← completed its work instantly
    stdout → socket (pipe to parent)   ← parent never closed pipe / reaped child
    

    The prettier formatter finished in 49ms of user time but was never reaped because the parent's event loop never processed the exit signal.


    📋 Exact Log Cutoff

    The log file freezes at this exact line — nothing after:

    INFO  04:06:07 +340ms service=bus type=message.part.updated publishing
    

    No message.completed, no tool.completed, no session.updated, no error. The bus published the edit result but the turn-completion event never arrives.


    ⚙️ Configuration (sanitized)

    "server": { "timeout": 30000, "keepAlive": false, "sseTimeout": 60000 },
    "provider": { "opencode-go": { "options": { "timeout": 60000 } } },
    "permission": { "write": "allow", "edit": "allow" },
    "formatter": { "prettier": { "command": ["prettier", "--write"] } }

    🔗 Cross-referenced Issues

    This appears to be a chain of interacting bugs:

    Issue Role
    #15675 (this) Tool write doesn't send status: completed RPC → root cause
    #19023 time.completed: undefined leaves sessions in permanent "Thinking"
    #13841 Provider timeout field is .optional() without .default() → no failsafe
    #17516 opencode run also hangs post-tool-call (same mechanism, different entry)

    🩹 Temporary Workaround

    Disabling auto-formatting and switching to "write": "ask" reduces the hit rate but doesn't eliminate it. The only reliable mitigation is an external watchdog that kills processes with stale logs + sustained high CPU.

    Happy to provide more detail or test patches.

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions