Repository navigation
Open
Labels
Description
Summary
When opencode runs as an ACP agent server inside Zed connected to a remote (SSH/devcontainer) worktree, the session produces a stream of failing file reads for paths that are directories (/var/www, /var/www/app/css, /var/www/app/js), and Zed's remote server ends up restarting. The root cause appears to be on the Zed side (zed-industries/zed#48240), so this issue is for tracking/coordination and to check whether opencode can guard the pattern.
Environment
- opencode:
v2.0.18, ACP mode (opencode acp) - Client: Zed
1.22.0+stable.364(remote devcontainer over SSH), host Ubuntu 24.04 - Plugin:
superpowers@git+https://github.com/obra/superpowers.git
What happens
- Zed's
Zed.logrecords, repeatedly:ERROR [acp_thread] RPC request OpenBufferByPath failed: Binary files are not supportedERROR [acp_thread] no worktree found for id N(dozens of times)
- Zed's remote server log records
type:OpenBufferByPath, error:reading bytes of the file "/var/www"(the worktree directory), plus/var/www/app/cssand/var/www/app/js(also directories), and 42×Binary files are not supported. - The remote server restarts ~9× (
stdin read failed: unexpected end of file), which invalidates worktree IDs, after which theno worktree found for id Nchurn begins. - User-visible symptoms: UI actions stop responding, the input caret blinks very fast, panels render blank, and opening a file takes ~30 s.
Expected
- Failed ACP file-access requests on directory paths should not cascade into repeated reads, and worktree-id invalidation after a remote-server restart should not cause a retry storm.
Actual
- Repeated failing reads and retries; the client becomes unresponsive during the episode.
Additional Context
- Cross-reference: OpenBufferByPath tries to read project directory as file on remote SSH (Claude Code stuck at Loading) zed-industries/zed#48240 — "OpenBufferByPath tries to read project directory as file on remote SSH". That issue is agent-agnostic; it has only been reported with Claude Code so far. This report adds opencode as another affected ACP agent.
- If this is entirely Zed-side, feel free to close as upstream — filing to track the integration and share the reproduction.
Activity
github-actions commentedon Oct 3, 2026
This issue might be a duplicate of existing issues. Please check:
Francis13CR commentedon Oct 3, 2026
Source-level follow-up: which side produces the directory paths
Following the trace, the failing
OpenBufferByPathcalls come from Zed's ACP tool-call location resolution:crates/acp_thread/src/acp_thread.rs—ToolCall::resolve_locationcallsproject.open_buffer(path)for everyToolCallLocationthe agent attaches to a tool call (acp_thread.rs:1262-1281;resolve_locationsinvoked at3466/3552/3621).So the Zed-side bug is that it tries to open a directory path as a buffer. From the opencode side, the relevant detail is that our tools' reported locations can be directories, e.g. the worktree root
/var/www,/var/www/app/css,/var/www/app/js(all directories), which is what triggers it.If opencode emits
ToolCallLocationentries from list/glob/grep-style operations, it would help to:This is only a defensive improvement — the primary fix belongs in Zed (zed-industries/zed#48240). Cross-referencing so both sides have the mechanism.
Francis13CR commentedon Oct 3, 2026
Thanks. Re #33510: that issue was auto-closed by the inactivity bot ("automatically closed after 60 days of no activity… if the issue is still relevant please open a new one"), not fixed. This is that re-report: the problem is still present and reproducible on v2.0.18.
I traced it to the current code.
packages/opencode/src/acp/tool.tstoLocationsstill returns directory paths:That maps exactly to what Zed logs in my session over a remote worktree at
/var/www:bash/shell→reading bytes of the file "/var/www"(the shell workdir) — 164×grep/glob→reading bytes of the file "/var/www/app/js"and"/var/www/app/css"(search roots)Binary files are not supportedZed then calls
open_bufferon each location and logs the failure for every tool-call update. On a remote connection this also destabilizes the client: remote-server restarts,no worktree found for id N, andreceived chunk for buffer ... without initial state.packages/opencode/test/acp/tool.test.tsonly coversread/edit, so nothing guards the directory cases.Suggested fix (same as originally proposed in #33510):
bash/shellworkdir location — it's already available viarawInput.cwd.grep/glob/context, only emit a location when the resolved path is a file, not a directory.toLocationsnever returns directory paths forbash/grep/glob.The Zed-side counterpart is zed-industries/zed#48240 (Zed should also refuse to
open_buffera directory).Francis13CR commentedon Oct 3, 2026
Related observation: in-flight turns marked
interruptedwhen the ACP server restartsSeparate from the directory-location issue, but observed in the same session — recording it here since it's the ACP/session surface.
When the ACP server restarts/reconnects (Zed window reload, or the remote connection dropping), an in-flight turn is recorded as
idlewithoutcome=interrupted, and the client surfaces it as canceled/empty — i.e. it looks like the user aborted it.Evidence from the container-side store (
session_message, typeidle):{"outcome":"interrupted"}at the exact moment the server loggedwatcher stoppedfor all watched paths plusInterruptError: All fibers interrupted without erroron/api/event, right before a new serverrunstarted. The correspondingsession_v2.idle_outcomewasinterrupted.This may be expected behavior on a client reconnect rather than a bug, but a distinct "connection lost / canceled by disconnect" state would avoid the turn looking like a user cancellation. Downstream of zed-industries/zed#48240 (remote client instability causing the reconnects).
opencodejr commentedon Oct 27, 2026
Thanks for the detailed report and the Zed cross-reference. I could reproduce the opencode side of this on v2.0.18, and it still happens on the latest
dev(45b53fe).What I did:
opencode acpwith a minimal ACP client over stdio and a mock model that makes oneshellcall (ls, no workdir) and onegrepcall on a subdirectory.locationsthat opencode sends intool_call/tool_call_update.In both versions, the project directory (for
shell) and the grep directory come back as tool-call locations, and they are sent again on the in-progress and completed updates. Zed opens a buffer for each location. On a remote worktree that is exactly the failingreading bytes of the file "/var/www"/Binary files are not supportedread in your logs, so opencode makes the Zed-side problem (zed-industries/zed#48240) worse. I couldn't run Zed here, so I didn't see the remote-server restarts or the retry storm themselves.The script below reproduces it. #52956 fixed the same thing for v1 (it reported only file locations) but was never merged, so the fix still needs to be done in v2. I've passed this on to the maintainers.
Reproduction script (acp-e2e.ts)
Run it:
bun acp-e2e.ts