Skip to content

fix(cli): present ACP command failures to ACP clients - #65716

Open
liyihang866 wants to merge 4 commits into
anomalyco:devfrom
liyihang866:acp-command-errors
Open

liyihang866 wants to merge 4 commits into
anomalyco:devfrom
liyihang866:acp-command-errors

Conversation

@liyihang866

@liyihang866 liyihang866 commented Nov 23, 2026 •

Copy link
Copy Markdown

Issue for this PR

Closes #65715

Type of change

  • Bug fix

What does this PR do?

Over ACP, a failing slash command killed the prompt request and clients saw a
generic internal error. Two changes: the turn's command path now sends the
command's message as an agent_message_chunk and ends the turn normally
(matching the TUI's inline error display), and classify() maps
CommandExecutionError/CommandNotFoundError to structured ACP errors instead
of dying, so any missed path still reaches the client with the real message.

How did you verify your code works?

  • bun test test/acp from packages/cli (119 pass), including new tests:
    wire-level command failure → chunk + end_turn; subprocess tests against the
    real binary (bare /goal → usage message; goal set/replace → end_turn, no
    request error); classify unit tests
  • Also verified against the packaged linux-x64 binary via OPENCODE_ACP_TEST_BIN
  • Reviewer shortcut: cd packages/cli && bun test test/acp/command-error.subprocess.test.ts

Screenshots / recordings

n/a

Checklist

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

Added by the opencode bot (AI-generated).

Related: #54371

@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.

The fix works. Over ACP, a bare /goal on the base fails the whole session/prompt request with Internal error: Internal service failure. With this PR the usage message arrives as an agent_message_chunk and the turn ends with end_turn. I checked by running the new subprocess test against both checkouts, plus bun test test/acp (all pass) and tsc -b (clean).

Public API: unchanged. Only the way command failures are reported to ACP clients changes.

One small thing: the new CommandExecutionError branch in classify() isn't used by any current caller. Only session.command raises that error, and turn.ts now catches it first. It's harmless as a fallback, but you could drop it (and its unit test) to keep the change minimal. The one test I'd ask you to remove is noted inline.

Related: #54371

expect(JSON.stringify(update)).toContain("Usage: /goal")
}, 60_000)

test("setting and replacing a goal over ACP returns end_turn without a request error", async () => {

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.

This test already passes on the base branch (setting or replacing a goal never failed), so it doesn't cover this fix and only adds another run of the real binary. Please drop it. The bare /goal test above and the wire test in turn.test.ts cover the change.

@liyihang866

Copy link
Copy Markdown
Author

Thanks for reviewing and verifying. Pushed:

  • Dropped the CommandExecutionError branch from classify() and its test.
  • Kept CommandNotFoundError: reachable when a stale catalog lets a known command reach the server and the server no longer has it — but happy to drop it too if you'd rather keep the diff minimal.
  • Removed the goal set/replace subprocess test per the inline note.

bun test test/acp from packages/cli: 117 pass, tsc -b clean.

@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.

Still works as intended. On the base, the #65715 reproduction script fails a bare /goal with -32603 Internal service failure. With this PR it gets the usage text as an agent_message_chunk and end_turn. bun test test/acp passes and tsc -b is clean.

The set/replace goal subprocess test I flagged is gone, and the unused CommandExecutionError branch in classify() was removed along with its unit test. I have nothing further to raise.

Public API: unchanged.

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: slash-command errors fail the prompt request with an opaque internal error

1 participant