Refactor rollout budget checks and turn completion state (#61583)

## What changed

- Centralize generation admission checks before request contributors run for HTTP and non-warmup WebSocket requests.
- Route pending input and inline compaction through dedicated budget checks, and centralize post-compaction budget handling.
- Preserve whether any checkpoint was installed when remote compaction combines a background candidate with foreground compaction.
- Track accepted final answers separately from trailing commentary and encapsulate the response state shared by stop and after-agent hooks.

## Testing

Update the plan-mode contributor test to verify that contributed commentary is tracked separately from final answers, and adapt stream-event assertions to the phase-aware assistant text representation.

GitOrigin-RevId: 43b663e92bfd24ec7e5a0778b711938f16a7fea4
This commit is contained in:
tongzhou wang
2026-11-15 00:03:59 +00:00
committed by copyberry
parent ce82e38b16
commit eaa25e1f43
11 changed files with 246 additions and 110 deletions
+2 -2
View File
@@ -218,7 +218,7 @@ async fn run_remote_compact_task_inner(
return Err(error);
}
}
let started_item = if candidate.is_none() {
let started_item = if candidate.is_none() && !sess.defer_compaction_start(turn_context, phase) {
let item = TurnItem::ContextCompaction(ContextCompactionItem::new());
sess.emit_turn_item_started(turn_context, &item).await;
Some(item)
@@ -264,7 +264,7 @@ async fn run_remote_compact_task_inner(
attempt
.track(sess.as_ref(), status, codex_error, analytics_details)
.await;
let result = result.and_then(|installed| sess.check_rollout_budget().map(|()| installed));
let result = sess.finish_compaction(turn_context, phase, result);
match result {
Ok(installed) => Ok(installed),
Err(err)