Keep interrupts responsive during host service-tier updates (#60644)

## Why

Waiting for host acceptance of a service-tier update in the submission loop can block interrupts while the host receipt is pending.

## What changed

Move the host acceptance wait out of the submission loop while keeping explicit thread settings replies pending until acceptance completes. Report handoff failures to the caller while preserving the locally committed settings, and allow a subsequent explicit request for the same tier to retry a failed handoff.

## Testing

Add a WebSocket regression test covering interrupts with pending host receipts, failure reporting, same-tier retries, and continued thread operation after startup caller cancellation.

GitOrigin-RevId: 1b27d156eba3ebb47e717a987f41f4f595635be8
This commit is contained in:
rhan-oai
2026-11-10 19:13:55 +00:00
committed by copyberry
parent 3f797555cd
commit 30b42cb802
8 changed files with 302 additions and 33 deletions
+8 -2
View File
@@ -826,7 +826,9 @@ impl CodexThread {
}
/// Queues settings for future turns and waits for Core to accept or reject them.
/// Rejections are returned to the caller instead of emitted as thread errors.
/// Rejections are returned to the caller instead of emitted as thread errors. A host-root
/// service-tier update also waits for local host acceptance outside Core's submission loop.
/// A handoff error leaves the settings committed locally. Callers can retry the same tier.
pub async fn update_thread_settings(
&self,
thread_settings: impl Into<WithTurnExtensionData<ThreadSettingsOverrides>>,
@@ -857,7 +859,11 @@ impl CodexThread {
settings: CodexThreadSettingsOverrides,
) -> ConstraintResult<()> {
let updates = self.thread_settings_update(settings);
self.session.update_settings(updates).await.map(|_| ())
let commit = self.session.update_settings(updates).await?;
if let Some(accepted) = commit.host_acceptance {
let _ = accepted.await;
}
Ok(())
}
/// Replaces tools for subsequent model steps and future turns, preserving in-flight calls.