From f00f8637a3d6e4e87abe03fb7e860c522463292a Mon Sep 17 00:00:00 2001 From: Adam Date: Sat, 23 May 2026 10:58:47 +1000 Subject: [PATCH] fix(agent-runner): honor zero/negative transcript rotate-age override CLAUDE_TRANSCRIPT_ROTATE_AGE_DAYS=0 (or negative) is documented to disable age-based rotation, but transcriptRotateAgeMs() routed it into the same branch as an unset var and returned the 14-day default. Sessions intentionally configured to stay long-lived were still rotated at 14 days, causing unexpected resets and context loss. Distinguish unset/non-numeric (default 14d) from an explicit non-positive override (Infinity = disabled; size alone governs). Co-Authored-By: Claude Opus 4.7 (1M context) --- container/agent-runner/src/providers/claude.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/container/agent-runner/src/providers/claude.ts b/container/agent-runner/src/providers/claude.ts index f764c7c84..63aeea2c1 100644 --- a/container/agent-runner/src/providers/claude.ts +++ b/container/agent-runner/src/providers/claude.ts @@ -257,8 +257,12 @@ function transcriptRotateBytes(): number { * non-positive value) disables the age check; size alone then governs. */ function transcriptRotateAgeMs(): number { - const days = Number(process.env.CLAUDE_TRANSCRIPT_ROTATE_AGE_DAYS); - return Number.isFinite(days) && days > 0 ? days * 86_400_000 : 14 * 86_400_000; + const raw = process.env.CLAUDE_TRANSCRIPT_ROTATE_AGE_DAYS; + if (raw === undefined || raw.trim() === '') return 14 * 86_400_000; + const days = Number(raw); + if (!Number.isFinite(days)) return 14 * 86_400_000; + // Explicit non-positive override disables the age check; size alone governs. + return days > 0 ? days * 86_400_000 : Infinity; } function claudeProjectsDir(): string {