Notify lifecycle extensions of compaction usage limits (#49097)

## Why

Usage-limit failures during manual or post-turn compaction did not notify turn lifecycle extensions, leaving them unable to react to these errors.

## What changed

Emit the turn error lifecycle notification for `UsageLimitExceeded` in both compaction paths. Preserve the completed answer after post-turn compaction fails, and avoid duplicating the error already emitted by manual compaction.

GitOrigin-RevId: f31155e5991d762a0779030921aedbd1f818cfbb
This commit is contained in:
xli-oai
2026-09-28 23:00:28 +00:00
committed by copyberry
parent 2ce64843be
commit 9563713df2
2 changed files with 19 additions and 6 deletions
+6
View File
@@ -736,6 +736,12 @@ pub(crate) async fn run_turn(
) {
return Err(err);
}
let error = err.to_codex_protocol_error();
if matches!(error, CodexErrorInfo::UsageLimitExceeded) {
// Preserve the completed answer while stopping automatic work.
sess.emit_turn_error_lifecycle(turn_context.as_ref(), error)
.await;
}
warn!(error = %err, "Post-turn compaction failed; preserving the completed turn");
}
break;