Repository navigation
fix(cli): present ACP command failures to ACP clients - #65716
liyihang866 wants to merge 4 commits into
Conversation
There was a problem hiding this comment.
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 () => { |
There was a problem hiding this comment.
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.
3ed297d to
8525bdb
Compare
|
Thanks for reviewing and verifying. Pushed:
|
There was a problem hiding this comment.
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.
Issue for this PR
Closes #65715
Type of change
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_chunkand ends the turn normally(matching the TUI's inline error display), and
classify()mapsCommandExecutionError/CommandNotFoundErrorto structured ACP errors insteadof dying, so any missed path still reaches the client with the real message.
How did you verify your code works?
bun test test/acpfrompackages/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, norequest error); classify unit tests
OPENCODE_ACP_TEST_BINcd packages/cli && bun test test/acp/command-error.subprocess.test.tsScreenshots / recordings
n/a
Checklist
Added by the opencode bot (AI-generated).
Related: #54371