@@ -5120,6 +5120,13 @@ describe("ClaudeAdapterV2 background wake turns", () => {
51205120 apiErrorStatus: 429,
51215121 shown: true,
51225122 },
5123+ {
5124+ name: "keeps the CLI's API error frame when the turn is interrupted",
5125+ text: "API Error: rejected",
5126+ apiErrorStatus: 400,
5127+ terminalReason: "aborted_streaming" as const,
5128+ shown: true,
5129+ },
51235130 ])("$name", (input) =>
51245131 Effect.gen(function* () {
51255132 const harness = yield* makeWakeHarness;
@@ -5144,14 +5151,17 @@ describe("ClaudeAdapterV2 background wake turns", () => {
51445151 result: input.text,
51455152 isError: true,
51465153 apiErrorStatus: input.apiErrorStatus,
5147- terminalReason: "api_error",
5154+ terminalReason: "terminalReason" in input ? input.terminalReason : " api_error",
51485155 }),
51495156 ]);
51505157
51515158 const terminal = yield* Queue.take(harness.terminalReceipts);
5152- assert.equal(terminal.status, "failed");
5153- if (terminal.status !== "failed") return;
5154- assert.equal(terminal.failure.message === input.text.slice(0, 500).trim(), !input.shown);
5159+ assert.equal(terminal.status, "terminalReason" in input ? "interrupted" : "failed");
5160+ if (terminal.status === "failed") {
5161+ assert.equal(terminal.failure.message === input.text.slice(0, 500).trim(), !input.shown);
5162+ } else {
5163+ assert.equal(terminal.failure, null);
5164+ }
51555165 const assistantTexts = harness.events.flatMap((event) =>
51565166 event.type === "message.updated" && event.message.role === "assistant"
51575167 ? [event.message.text]
0 commit comments