fix(agents): report recovered compaction runs as completed

This commit is contained in:
Peter Steinberger
2026-08-12 20:51:29 -07:00
parent 6cfc05ae2f
commit 35b14bb547
2 changed files with 16 additions and 4 deletions
@@ -97,6 +97,19 @@ describe("cleanupEmbeddedAttemptSessionPhase", () => {
expect(input.emitDiagnosticRunCompleted).toHaveBeenCalledWith("completed", null, undefined);
});
it("keeps compaction timeout observations abort-like only for cleanup", async () => {
const input = createInput();
const readState = input.readState;
input.readState = () => ({ ...readState(), timedOutDuringCompaction: true });
await cleanupEmbeddedAttemptSessionPhase(input as never);
expect(hoisted.cleanupEmbeddedAttemptResources).toHaveBeenCalledWith(
expect.objectContaining({ aborted: true }),
);
expect(input.emitDiagnosticRunCompleted).toHaveBeenCalledWith("completed", null, undefined);
});
it("emits the before-agent blocked status and owner", async () => {
const input = createInput({
readState: () => ({
@@ -175,6 +175,8 @@ export async function cleanupEmbeddedAttemptSessionPhase(
const finalState = input.readState();
const cleanupFailure = cleanupError;
const beforeAgentRunBlocked = finalState.beforeAgentRunBlockedBy !== undefined;
const diagnosticTerminalAborted =
finalState.aborted || finalState.timedOut || finalState.idleTimedOut;
input.emitDiagnosticRunCompleted?.(
cleanupFailure
? "error"
@@ -182,10 +184,7 @@ export async function cleanupEmbeddedAttemptSessionPhase(
? "blocked"
: finalState.promptError
? "error"
: finalState.aborted ||
finalState.timedOut ||
finalState.idleTimedOut ||
finalState.timedOutDuringCompaction
: diagnosticTerminalAborted
? "aborted"
: "completed",
cleanupFailure ?? finalState.promptError,