@devries-cameron20 / t3code Mirror · read-only / commits / 2b65ffb641
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 22, 02:00 UTC

fix(server): steering during a Claude compaction shows it stopped, not failed (#33291)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

Theo Browne committed Nov 9, 2026 at 02:51 UTC 2b65ffb641f152fadf443096bad7f4a0677caae4
2 files changed +50 -15
apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts
+42 -8
@@ -8728,13 +8728,23 @@ describe("ClaudeAdapterV2 background wake turns", () => {
8728 it.effect.each([
8729 { outcome: "result", turnStatus: "completed", itemStatus: "failed" },
8730 { outcome: "interrupt", turnStatus: "interrupted", itemStatus: "interrupted" },
8731 + { outcome: "interrupt_aborted", turnStatus: "interrupted", itemStatus: "interrupted" },
8732 { outcome: "query_exit", turnStatus: "failed", itemStatus: "failed" },
8733 ] as const)(
8734 "settles unfinished compaction before the $outcome terminal receipt",
8735 ({ outcome, turnStatus, itemStatus }) =>
8736 Effect.gen(function* () {
8737 + const interruptSent = yield* Deferred.make<void>();
8738 + const abortReported = yield* Deferred.make<void>();
8739 const harness = yield* makeWakeHarnessWithOptions({
8740 close: (sdkMessages) => Queue.shutdown(sdkMessages),
8741 + ...(outcome === "interrupt_aborted"
8742 + ? {
8743 + interrupt: Deferred.succeed(interruptSent, undefined).pipe(
8744 + Effect.andThen(Deferred.await(abortReported)),
8745 + ),
8746 + }
8747 + : {}),
8748 });
8749 const attemptId = RunAttemptId.make(`claude-compact-${outcome}`);
8750 yield* harness.runtime.startTurn(
@@ -8758,15 +8768,34 @@ describe("ClaudeAdapterV2 background wake turns", () => {
8768 );
8769 if (outcome === "query_exit") {
8770 yield* Queue.shutdown(harness.sdkMessages);
8761 - } else if (outcome === "interrupt") {
8771 + } else if (outcome === "interrupt" || outcome === "interrupt_aborted") {
8772 const idAllocator = yield* IdAllocator.IdAllocatorV2;
8763 - yield* harness.runtime.interruptTurn({
8764 - providerThread: harness.providerThread,
8765 - providerTurnId: idAllocator.derive.providerTurn({
8766 - driver: ClaudeAdapterV2.CLAUDE_PROVIDER,
8767 - nativeTurnId: `turn:${attemptId}`,
8768 - }),
8769 - });
8773 + const interrupting = yield* harness.runtime
8774 + .interruptTurn({
8775 + providerThread: harness.providerThread,
8776 + providerTurnId: idAllocator.derive.providerTurn({
8777 + driver: ClaudeAdapterV2.CLAUDE_PROVIDER,
8778 + nativeTurnId: `turn:${attemptId}`,
8779 + }),
8780 + })
8781 + .pipe(Effect.forkScoped);
8782 + if (outcome === "interrupt_aborted") {
8783 + // The CLI reports the aborted compaction as failed.
8784 + yield* Deferred.await(interruptSent);
8785 + yield* harness.offerAndWait(
8786 + claudeSdkFrame({
8787 + type: "system",
8788 + subtype: "status",
8789 + status: null,
8790 + compact_result: "failed",
8791 + compact_error: "API Error: Request was aborted.",
8792 + uuid: "00000000-0000-4000-8000-000000000223",
8793 + session_id: WAKE_NATIVE_SESSION,
8794 + }),
8795 + );
8796 + yield* Deferred.succeed(abortReported, undefined);
8797 + }
8798 + yield* Fiber.join(interrupting);
8799 } else {
8800 yield* Queue.offer(
8801 harness.sdkMessages,
@@ -8787,6 +8816,11 @@ describe("ClaudeAdapterV2 background wake turns", () => {
8816 const [running, settled] = updates;
8817 assert.equal(running?.status, "running");
8818 assert.equal(settled?.status, itemStatus);
8819 + assert.equal(
8820 + settled?.title,
8821 + itemStatus === "failed" ? "Context compaction failed" : "Context compaction stopped",
8822 + );
8823 + if (outcome === "interrupt_aborted") assert.isUndefined(settled?.summary);
8824 assert.equal(settled?.id, running?.id);
8825 assert.equal(settled?.ordinal, running?.ordinal);
8826 assert.deepEqual(settled?.startedAt, running?.startedAt);
apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts
+8 -7
@@ -9179,9 +9179,12 @@ export const makeClaudeAdapterV2 = Effect.fn("makeClaudeAdapterV2")(function* (
9179 (message.compact_result !== undefined ||
9180 (message.status === null && message.permissionMode === undefined))
9181 ) {
9182 + // The CLI reports a compaction it aborted for our interrupt as failed.
9183 + const failed =
9184 + message.compact_result === "failed" &&
9185 + !(yield* Ref.get(interruptedTurns)).has(context.providerTurnId);
9186 if (message.compact_result !== undefined) {
9183 - context.compactionFailure =
9184 - message.compact_result === "failed" ? { message: message.compact_error } : null;
9187 + context.compactionFailure = failed ? { message: message.compact_error } : null;
9188 }
9189 if (context.compaction?.status === "running") {
9190 const now = yield* DateTime.now;
@@ -9190,18 +9193,16 @@ export const makeClaudeAdapterV2 = Effect.fn("makeClaudeAdapterV2")(function* (
9193 status:
9194 message.compact_result === "success"
9195 ? "completed"
9193 - : message.compact_result === "failed"
9196 + : failed
9197 ? "failed"
9198 : "interrupted",
9199 title:
9200 message.compact_result === "success"
9201 ? "Context compacted"
9199 - : message.compact_result === "failed"
9202 + : failed
9203 ? "Context compaction failed"
9204 : "Context compaction stopped",
9202 - ...(message.compact_result === "failed" && message.compact_error
9203 - ? { summary: message.compact_error }
9204 - : {}),
9205 + ...(failed && message.compact_error ? { summary: message.compact_error } : {}),
9206 completedAt: now,
9207 updatedAt: now,
9208 };