Skip to content

feat: let ACP client expose the input/output properly#11303

Open
validatedev wants to merge 17 commits intoanomalyco:devfrom
validatedev:fix/acp-show-proper-run-command-message
Open

feat: let ACP client expose the input/output properly#11303
validatedev wants to merge 17 commits intoanomalyco:devfrom
validatedev:fix/acp-show-proper-run-command-message

Conversation

@validatedev
Copy link
Copy Markdown
Contributor

@validatedev validatedev commented Jan 30, 2026

What does this PR do?

Fixes #10998.

Old behavior: we sent a tool_call at pending with kind: "execute". As the tool ran, updates carried the content plus a completed rawOutput. Zed relied on kind: "execute" to render the blue "run command" box, but the actual command (rawInput) only appeared after completion, so you couldn't see what was running.

New behavior: the first tool_call now reflects the tool part's actual status (e.g. in_progress when the tool is already running on first observation) and carries the full rawInput — including the resolved working directory for bash — so Zed can show the command and where it's running before output lands. Subsequent tool_call_updates fill in streaming content and the final rawOutput (stdout/stderr). kind is set to other (not execute), which removes the blue run-box styling and instead exposes rawInput/rawOutput as collapsible panels.

How did you verify your code works?

By running Zed's ACP inferface via:

    "OpenCode (ACP Dev)": {
      "type": "custom",
      "command": "bun",
      "args": [
        "run",
        "--cwd",
        "/Users/validate/Developer/personal/opencode/packages/opencode",
        "--conditions=browser",
        "./src/index.ts",
        "acp",
      ],
      "env": {},
    },

Screenshot

Old Behavior

CleanShot 2026-01-30 at 01 21 56@2x

New Behavior

CleanShot 2026-04-23 at 23 30 31@2x

@github-actions
Copy link
Copy Markdown
Contributor

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

No duplicate PRs found

@rekram1-node
Copy link
Copy Markdown
Collaborator

Can you explain the changes, it looks like quite a bit

@validatedev
Copy link
Copy Markdown
Contributor Author

any update @rekram1-node @adamdotdevin? I don't have any problems with this, works much better than the old structure (aligns other Zed ACP + Zed Agent interfaces)

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors the ACP (Agent Client Protocol) client implementation to properly expose tool input/output information to ACP clients like Zed. The main change addresses issue #10998 where command details weren't visible in the Zed UI.

Changes:

  • Refactored tool call/result formatting into a centralized tool-format.ts module with structured formatting logic for different tool types
  • Changed tool call emission timing from pending to running state with full rawInput (command + cwd) included upfront
  • Updated tool kind from "execute" to "other" for bash/shell/terminal commands

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 8 comments.

File Description
packages/opencode/src/acp/tool-format.ts New module containing centralized tool formatting logic with toolCallFromPart and toolResultFromPart functions
packages/opencode/src/acp/parse-command.ts New helper module for formatting bash/shell/terminal commands with title, kind, and locations
packages/opencode/src/acp/agent.ts Refactored to use new formatting functions; removed old toToolKind and toLocations helpers; added emittedToolCalls tracking to prevent duplicate emissions
packages/opencode/test/acp/parse-command.test.ts Added tests for ParseCommand.format function

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/opencode/src/acp/agent.ts Outdated
Comment thread packages/opencode/src/acp/agent.ts Outdated
Comment thread packages/opencode/src/acp/agent.ts Outdated
Comment thread packages/opencode/src/acp/tool-format.ts Outdated
Comment thread packages/opencode/src/acp/tool-format.ts Outdated
Comment thread packages/opencode/src/acp/tool-format.ts Outdated
Comment thread packages/opencode/src/acp/agent.ts Outdated
Comment thread packages/opencode/src/acp/agent.ts Outdated
…pers

- Remove parse-command.ts in favor of logic consolidated in tool-format.ts
- Rewrite tool-format helpers (toolCallFromPart, toolResultFromPart,
  permissionDisplayInfo, fenceWith) as the single source of truth for
  tool call formatting
- Adapt agent.ts to dev's post-namespace-refactor layout (flat exports
  with `export * as ACP` self-reexport, ProviderID/ModelID branded types,
  Hash.fast, InstallationVersion, ConfigMCP.Info)
- Drop listSessions `unstable_` prefix to match SDK method name
- Guard sendUsageUpdate against missing providerID/modelID
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 7 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/opencode/src/acp/agent.ts
Comment thread packages/opencode/test/acp/tool-format.test.ts
Comment thread packages/opencode/test/acp/tool-format.test.ts
Comment thread packages/opencode/test/acp/tool-format.test.ts
Comment thread packages/opencode/src/acp/tool-format.ts
Comment thread packages/opencode/src/acp/tool-format.ts Outdated
Comment thread packages/opencode/src/acp/agent.ts
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/opencode/src/acp/tool-format.ts Outdated
Comment thread packages/opencode/src/acp/agent.ts
Comment thread packages/opencode/src/acp/tool-format.ts
- `read` tool: treat `offset` as 1-based (matches the read tool schema);
  previously off-by-one in the displayed line range and location.
- `toolStart`: derive the initial `tool_call` status from
  `part.state.status` (pending/in_progress/completed/failed) instead of
  always emitting `pending`, so the first event reflects reality.
- `bash`: fall back to the session cwd in both `locations` and
  `rawInput` when the model omits `workdir`, so Zed always shows where
  a command runs.
Guards against callers outside the zod-validated tool boundary (MCP tools, permission display, tests) producing NaN/Infinity titles like '(NaN - NaN)' in read ranges.
…ool status

- Extract the bash-output hashing and content-block assembly into a single
  `runningContent(sessionId, part)` helper, and call it from both the
  `message.part.updated` live path and the `processMessage` replay path.
  Previously the replay path (loadSession/forkSession) emitted the output
  verbatim without seeding `bashSnapshots`, so the first live update after
  replay would re-emit the same content. The helper guarantees both paths
  stay in lockstep.
- Replace the 4-level nested ternary in `toolStart` with a
  `Record<ToolPart state status, ToolCallStatus>` map plus a \`satisfies\`
  constraint, so adding a new tool-part state would be a compile error.
- Cover the new contract with three tests: replay + live dedupe on
  identical bash output, first `tool_call` emitted at \`completed\` when a
  tool part is already completed on first observation, and the analogous
  \`failed\` status for error parts.
@validatedev
Copy link
Copy Markdown
Contributor Author

@adamdotdevin I really want this to be merged, and it works without any issues. Could you please review and/or merge if you have time? I've been waiting 3 months. The PR only affects the ACP part. I can fix it if you don't like any parts of the PR, and it fixes a real issue which should not be happening (and other providers' ACP clients do not have such issues).

@jiwangyihao
Copy link
Copy Markdown

I'm also seeing this in Zed ACP mode: bash tool calls show only the human-readable description (for example, Shows concise working tree status) but not the actual command being executed.

This makes permission review and debugging difficult, because users cannot tell which command is about to run without digging into logs. It looks like the same issue reported in #10998 and #14034; both were auto-closed, but the behavior is still relevant.

Could this PR be reviewed/merged, or could maintainers clarify what is blocking it?

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Run Command message won't display command ran in Zed

4 participants