Fix incorrect stop reason after tool call rejection (#153)

We were mapping tool call rejections to actual "refusals" which isn't
quite right in ACP.

Also filters out more of these status messages that Claude is returning.
This commit is contained in:
Ben Brandt
2025-11-13 11:19:48 +01:00
committed by GitHub
parent 7e0d2c9506
commit 6a0d0b5522
4 changed files with 18 additions and 6 deletions

View File

@@ -377,12 +377,14 @@ export class ClaudeAcpAgent implements Agent {
return { stopReason: "end_turn" };
}
case "error_during_execution":
return { stopReason: "refusal" };
return { stopReason: "end_turn" };
case "error_max_budget_usd":
case "error_max_turns":
return { stopReason: "max_turn_requests" };
default:
return { stopReason: "refusal" };
unreachable(message);
}
break;
}
case "stream_event": {
for (const notification of streamEventToAcpNotifications(
@@ -420,7 +422,13 @@ export class ClaudeAcpAgent implements Agent {
break;
}
// Skip these user messages for now, since they seem to just be messages we don't want in the feed
if (message.type === "user" && typeof message.message.content === "string") {
if (
message.type === "user" &&
(typeof message.message.content === "string" ||
(Array.isArray(message.message.content) &&
message.message.content.length === 1 &&
message.message.content[0].type === "text"))
) {
break;
}