Skip to content

fix(acp): report only files as tool call locations - #62188

Open
neriousy wants to merge 1 commit into
devfrom
acp-directory-locations
Open

neriousy wants to merge 1 commit into
devfrom
acp-directory-locations

Conversation

@neriousy

@neriousy neriousy commented Nov 5, 2026

Copy link
Copy Markdown
Member

What was wrong

Over ACP, opencode reported directories as tool call locations. Zed opens a buffer for every location, so each update tried to read a folder as a file. On a remote worktree that shows up as reading bytes of the file "/var/www" / Binary files are not supported errors on every tool call update, which also adds load to an already unstable remote connection.

Root cause

toLocations in packages/cli/src/acp/tool.ts returned:

  • the working directory for every shell call (the session cwd when none was given),
  • the search root for glob, which is always a directory,
  • the path for grep and read, both of which also accept directories.

The permission request fallback in permission.ts also turned external_directory grants like /dir/* into a /dir location.

Fix

  • shell and glob no longer report locations. The shell working directory is still sent in rawInput.cwd.
  • locationFrom drops paths that exist and are directories. Paths that can't be inspected, such as a file a tool is about to create, are still reported.
  • The permission fallback uses the same helper and skips glob resources, so directory grants are no longer sent as locations.

Opencode does not send fs/read_text_file requests, so locations were the only source of these reads. Zed should still refuse to open a directory as a buffer (zed-industries/zed#48240). This PR only stops opencode from triggering that.

No feature flag: this is a bug fix.

How verified

  • New test in packages/cli/test/acp/translate.test.ts runs shell, glob, grep and read calls on a real temp directory and file through ACPTranslate.fold. It failed before the change (directory locations on the pending, in-progress and completed updates) and passes now. Existing assertions that expected directory locations were updated.
  • bun test on the ACP unit tests in packages/cli (97 pass) and bun typecheck in packages/cli.
  • Ran the end-to-end script from the issue (real opencode acp over stdio, mock model making a shell call and a grep on a directory). Before: BUG: opencode sent 6 directory location(s) to the ACP client. After: OK: no directory locations sent.

Visual

<svg xmlns="http://www.w3.org/2000/svg" width="240" height="72" viewBox="0 0 240 72" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
  <style>
    .dir{animation:fade 3s ease-in-out infinite}
    .file{animation:pulse 3s ease-in-out infinite}
    @keyframes fade{0%,30%{opacity:.9}55%,100%{opacity:.15}}
    @keyframes pulse{0%,40%{opacity:.5}60%,100%{opacity:1}}
    @media (prefers-reduced-motion:reduce){.dir,.file{animation:none}}
  </style>
  <g opacity=".5">
    <rect x="96" y="20" width="48" height="32" rx="6"/>
    <path d="M108 32h24M108 40h16"/>
  </g>
  <g class="dir" opacity=".15">
    <path d="M20 26h12l4 4h16v18H20z"/>
    <path d="M58 36h28" stroke-dasharray="3 4"/>
    <path d="M76 30l10 6-10 6"/>
    <path d="M30 56l12-12M42 56L30 44" opacity=".8"/>
  </g>
  <g class="file">
    <path d="M196 22h14l8 8v22h-22z"/>
    <path d="M210 22v8h8"/>
    <path d="M154 36h32"/>
    <path d="M176 30l10 6-10 6"/>
  </g>
</svg>

Closes #52952

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. I ran the issue's ACP stdio reproduction against a real opencode acp from source. On the base, the shell working directory and the grep directory were sent as locations on the pending, in-progress and completed updates (6 directory locations). With this change, no locations were sent for either call. The ACP tests in packages/cli pass (101) and tsc -b is clean.

Public API: unchanged. Only the content of ACP locations changes, and the shell working directory is still sent in rawInput.cwd.

No blocking concerns.

This branch has not been deployed

No deployments
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

1 participant