mirror of
https://github.com/openai/codex.git
synced 2026-11-20 22:40:37 +00:00
Defer queue-only mail after a retained final answer (#62639)
## Why A WebSocket response can still complete with a final answer while Codex drains it after a mailbox interrupt. Treating the interrupt alone as a reason to resample reopens the turn even when the pending mail can wait. ## What changed Recheck whether pending mail requires preemption after the drain. When the drain retains a final answer, queue-only mail waits for the next turn's sampling boundary. User steering can still reopen the current turn. ## Testing Add WebSocket regression cases for queue-only mail after both empty and nonempty final answers, and for user steering received during the drain. GitOrigin-RevId: 914b51f2de1afc91311667cc05718507717aaaa0
This commit is contained in:
@@ -3256,9 +3256,16 @@ async fn try_run_sampling_request(
|
||||
if resampling.update_usage_boundary {
|
||||
sess.state.lock().await.history.reset_last_usage_boundary();
|
||||
}
|
||||
// A completed final retained during the drain can defer queue-only mail.
|
||||
// Recheck that boundary instead of reopening it solely because we interrupted.
|
||||
let mailbox_preempted = *draining_for_mailbox
|
||||
&& sess
|
||||
.input_queue
|
||||
.should_preempt_sampling_for_mail(&sess.active_turn, &turn_context.sub_id)
|
||||
.await;
|
||||
break Ok(SamplingRequestResult {
|
||||
needs_follow_up,
|
||||
mailbox_preempted: *draining_for_mailbox,
|
||||
needs_follow_up: needs_follow_up || mailbox_preempted,
|
||||
mailbox_preempted,
|
||||
last_agent_message,
|
||||
});
|
||||
}
|
||||
@@ -3581,7 +3588,6 @@ async fn try_run_sampling_request(
|
||||
}
|
||||
// Keep the response ID and terminal decision. Later tools receive a denial.
|
||||
*draining_for_mailbox = true;
|
||||
needs_follow_up = true;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user