From 6c7a6ff1c49062a874eeb23ba5fc4adcbd2cc26d Mon Sep 17 00:00:00 2001 From: Peter Lee Date: Sun, 28 Jun 2026 03:55:56 -0500 Subject: [PATCH] fix(cron): propagate cleanupCliLiveSessionOnRunEnd to isolated cron CLI branch (#97227) * fix(cron): propagate cleanupCliLiveSessionOnRunEnd to isolated cron CLI branch * test(cron): add CLI interim retry coverage for isolated cron cleanup flag Verify cleanupCliLiveSessionOnRunEnd is passed on both the initial and retry CLI runs during isolated cron interim-ack retry loops. Proves the inner boundary is safe: each runCliAgent call creates a fresh context, so cleanup cannot affect the retry's live session. * fix(cron): remove unused variable in interim retry test Co-Authored-By: Claude Opus 4.8 (1M context) * test(cron): trim redundant cleanup retry coverage --------- Co-authored-by: Claude Opus 4.8 (1M context) Co-authored-by: Peter Steinberger --- src/cron/isolated-agent/run-executor.ts | 1 + src/cron/isolated-agent/run.session-key-isolation.test.ts | 2 ++ 2 files changed, 3 insertions(+) diff --git a/src/cron/isolated-agent/run-executor.ts b/src/cron/isolated-agent/run-executor.ts index 70e80009b02e..e12ca8baeca2 100644 --- a/src/cron/isolated-agent/run-executor.ts +++ b/src/cron/isolated-agent/run-executor.ts @@ -322,6 +322,7 @@ export function createCronPromptExecutor(params: { agentId: params.agentId, trigger: "cron", jobId: params.job.id, + cleanupCliLiveSessionOnRunEnd: params.job.sessionTarget === "isolated", sessionFile, workspaceDir: params.workspaceDir, config: params.cfgWithAgentDefaults, diff --git a/src/cron/isolated-agent/run.session-key-isolation.test.ts b/src/cron/isolated-agent/run.session-key-isolation.test.ts index 0a7d2bc63197..76cbc19f1b65 100644 --- a/src/cron/isolated-agent/run.session-key-isolation.test.ts +++ b/src/cron/isolated-agent/run.session-key-isolation.test.ts @@ -198,6 +198,7 @@ describe("runCronIsolatedAgentTurn isolated session identity", () => { promptCacheKey?: string; bootstrapContextMode?: string; bootstrapContextRunKind?: string; + cleanupCliLiveSessionOnRunEnd?: boolean; }; expect(runRequest.sessionId).toBe("isolated-cli-run-1"); expect(runRequest.sessionKey).toBe("agent:default:cron:cli-monitor:run:isolated-cli-run-1"); @@ -205,6 +206,7 @@ describe("runCronIsolatedAgentTurn isolated session identity", () => { expect(runRequest.promptCacheKey).toBeUndefined(); expect(runRequest.bootstrapContextMode).toBe("lightweight"); expect(runRequest.bootstrapContextRunKind).toBe("cron"); + expect(runRequest.cleanupCliLiveSessionOnRunEnd).toBe(true); }); it("runs externally sourced CLI hook turns", async () => {