diff --git a/src/agents/pi-embedded-runner/run.ts b/src/agents/pi-embedded-runner/run.ts index af4fa2886f3..81f26a47902 100644 --- a/src/agents/pi-embedded-runner/run.ts +++ b/src/agents/pi-embedded-runner/run.ts @@ -714,8 +714,8 @@ export async function runEmbeddedPiAgent( log.info( `[context-overflow-recovery] Truncated ${truncResult.truncatedCount} tool result(s); retrying prompt`, ); - // Session is now smaller; allow compaction retries again. - overflowCompactionAttempts = 0; + // Do NOT reset overflowCompactionAttempts here — the global cap must remain + // enforced across all iterations to prevent unbounded compaction cycles (OC-65). continue; } log.warn(