Skip to content

fix(acp): omit directory paths from tool-call locations - #52956

Closed
Francis13CR wants to merge 1 commit into
anomalyco:devfrom
Francis13CR:acp/omit-directory-locations
Closed

Francis13CR wants to merge 1 commit into
anomalyco:devfrom
Francis13CR:acp/omit-directory-locations

Conversation

@Francis13CR

@Francis13CR Francis13CR commented Oct 3, 2026 •

Copy link
Copy Markdown

Issue for this PR

Closes #52952

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

toLocations in packages/opencode/src/acp/tool.ts returned directories as tool-call locations: the shell working directory for bash/shell, and the search root for grep/glob/context.

ACP clients open a buffer for each reported location. On a remote project (Zed + zed-remote-server), opening a directory fails (reading bytes of the file "/var/www" / Binary files are not supported). Because these locations are re-sent on every running tool-call update, the client retries continuously, which floods the connection and desyncs the agent panel — a turn that actually finishes on the server gets shown as canceled.

This reports only file locations:

  • bash/shell: the workdir location is dropped. It is still exposed via rawInput.cwd.
  • grep/glob/context/external_directory and read/edit/write: paths that resolve to a directory are filtered out. A path that doesn't exist (for example a write target) is kept, since it isn't known to be a directory.

The now-unused cwd parameter of toLocations is removed; callers still pass the workdir to rawInput.

How did you verify your code works?

From packages/opencode: bun test test/acp/tool.test.ts → 10 pass.

I updated the existing bash expectations (the workdir is no longer a location) and added a regression test that creates a real temp directory and file and asserts the directory is filtered while the file is kept.

Screenshots / recordings

Not a UI change.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

`toLocations` reported directories as tool-call locations: the resolved
working directory for `bash`/`shell`, and the search root for
`grep`/`glob`/`context`.

ACP clients treat `locations` as file references and open a buffer for
each one. On a remote project (for example Zed with zed-remote-server)
opening a directory fails (`reading bytes of the file "<dir>"` /
`Binary files are not supported`), and because locations are re-sent on
every running tool-call update, the client retries on every update. This
floods the connection, causes foreground hangs, and can desync the agent
panel so a turn that actually completes is shown as canceled.

Only report locations that are files:

- `bash`/`shell`: drop the workdir location. It is already exposed via
  `rawInput.cwd`, so nothing is lost.
- `grep`/`glob`/`context`/`external_directory` and `read`/`edit`/`write`:
  filter out paths that resolve to a directory. Unknown paths (such as a
  `write` target that does not exist yet) are kept, since they are not
  known to be directories.

The now-unused `cwd` parameter of `toLocations` is removed; callers keep
passing the workdir to `rawInput`, which still surfaces it.
@github-actions

github-actions Bot commented Oct 3, 2026

Copy link
Copy Markdown
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@github-actions github-actions Bot added the needs:compliance This means the issue will auto-close after 2 hours. label Oct 3, 2026
@github-actions

github-actions Bot commented Oct 3, 2026

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

@github-actions

github-actions Bot commented Oct 3, 2026

Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

@thdxr

thdxr commented Oct 10, 2026

Copy link
Copy Markdown
Member

This branch has been upgraded to V2. We're no longer taking PRs for V1. If you think this is still relevant, please port it over and open it for V2.

— from 𝕺𝖕𝖊𝖓𝕮𝖔𝖉𝖊

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

acp: directory paths cause failing file reads over Zed remote worktree

2 participants