Skip to content

Commit 2f998b7

Browse files
timvisher-ddclaude
andcommitted
fix: resolve rebase conflicts with upstream session_state_changed and stopReason
The SDK now includes session_state_changed in its type union, so add it as a proper case arm instead of handling it in default. Replace the imported StopReason type with an inline union since it's only used for the local stopReason variable. Remove dead stopReason assignments in error_during_execution and error_max_* cases. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 3f4d42e commit 2f998b7

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/acp-agent.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ import {
4040
TerminalOutputResponse,
4141
WriteTextFileRequest,
4242
WriteTextFileResponse,
43-
StopReason,
4443
} from "@agentclientprotocol/sdk";
4544
import {
4645
CanUseTool,
@@ -511,7 +510,7 @@ export class ClaudeAcpAgent implements Agent {
511510

512511
session.promptRunning = true;
513512
let handedOff = false;
514-
let stopReason: StopReason = "end_turn";
513+
let stopReason: "end_turn" | "max_tokens" | "cancelled" = "end_turn";
515514
// Saved prompt response when consuming internal turns from background
516515
// task completions. See the "success" result handler below.
517516
let savedPromptResponse: PromptResponse | undefined;
@@ -647,6 +646,12 @@ export class ClaudeAcpAgent implements Agent {
647646
}
648647
case "task_progress":
649648
break;
649+
case "session_state_changed": {
650+
if (message.state === "idle") {
651+
return { stopReason, usage: sessionUsage(session) };
652+
}
653+
break;
654+
}
650655
default:
651656
unreachable(message, this.logger);
652657
break;
@@ -869,7 +874,6 @@ export class ClaudeAcpAgent implements Agent {
869874
message.errors.join(", ") || message.subtype,
870875
);
871876
}
872-
stopReason = "end_turn";
873877
break;
874878
}
875879
case "error_max_budget_usd":
@@ -881,7 +885,6 @@ export class ClaudeAcpAgent implements Agent {
881885
message.errors.join(", ") || message.subtype,
882886
);
883887
}
884-
stopReason = "max_turn_requests";
885888
break;
886889
default:
887890
unreachable(message, this.logger);

0 commit comments

Comments
 (0)