Skip to content

Commit 35b14bb

Browse files
committed
fix(agents): report recovered compaction runs as completed
1 parent 6cfc05a commit 35b14bb

2 files changed

Lines changed: 16 additions & 4 deletions

File tree

‎src/agents/embedded-agent-runner/run/attempt-session-cleanup.test.ts‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,19 @@ describe("cleanupEmbeddedAttemptSessionPhase", () => {
9797
expect(input.emitDiagnosticRunCompleted).toHaveBeenCalledWith("completed", null, undefined);
9898
});
9999

100+
it("keeps compaction timeout observations abort-like only for cleanup", async () => {
101+
const input = createInput();
102+
const readState = input.readState;
103+
input.readState = () => ({ ...readState(), timedOutDuringCompaction: true });
104+
105+
await cleanupEmbeddedAttemptSessionPhase(input as never);
106+
107+
expect(hoisted.cleanupEmbeddedAttemptResources).toHaveBeenCalledWith(
108+
expect.objectContaining({ aborted: true }),
109+
);
110+
expect(input.emitDiagnosticRunCompleted).toHaveBeenCalledWith("completed", null, undefined);
111+
});
112+
100113
it("emits the before-agent blocked status and owner", async () => {
101114
const input = createInput({
102115
readState: () => ({

‎src/agents/embedded-agent-runner/run/attempt-session-settle.ts‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -175,17 +175,16 @@ export async function cleanupEmbeddedAttemptSessionPhase(
175175
const finalState = input.readState();
176176
const cleanupFailure = cleanupError;
177177
const beforeAgentRunBlocked = finalState.beforeAgentRunBlockedBy !== undefined;
178+
const diagnosticTerminalAborted =
179+
finalState.aborted || finalState.timedOut || finalState.idleTimedOut;
178180
input.emitDiagnosticRunCompleted?.(
179181
cleanupFailure
180182
? "error"
181183
: beforeAgentRunBlocked
182184
? "blocked"
183185
: finalState.promptError
184186
? "error"
185-
: finalState.aborted ||
186-
finalState.timedOut ||
187-
finalState.idleTimedOut ||
188-
finalState.timedOutDuringCompaction
187+
: diagnosticTerminalAborted
189188
? "aborted"
190189
: "completed",
191190
cleanupFailure ?? finalState.promptError,

0 commit comments

Comments
 (0)