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) <noreply@anthropic.com>
This commit is contained in:
Adam
2026-05-23 10:58:47 +10:00
parent 68448c40c0
commit f00f8637a3
@@ -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 {