Support asynchronous host service-tier reads and acceptance (#60075)

## What changed

Make `AgentServiceTier` reads asynchronous and have updates return a receipt for local acceptance. Await acceptance during root startup and settings updates outside state and registry locks, sharing the receipt with explicit same-tier retries.

Await shared-tier reads during child preparation, startup prewarm, and step capture. Allow cancellation while capturing a step, and keep host propagation independent of the acceptance wait.

## Testing

Extend the host-child WebSocket test to cover delayed acceptance, same-tier retries without duplicate updates, accessible settings while acceptance is pending, and tier inheritance during prewarm and subsequent steps.

GitOrigin-RevId: 0e2e1899834c37684e904c4a36e66344a0c6c7f3
This commit is contained in:
rhan-oai
2026-11-07 06:51:10 +00:00
committed by copyberry
parent f4275a2a2e
commit f5ac7a757e
8 changed files with 176 additions and 49 deletions
+13 -3
View File
@@ -2160,6 +2160,7 @@ impl Session {
) -> ConstraintResult<Option<SessionSettingsCommit>> {
let notify_config_contributors = !self.services.extensions.config_contributors().is_empty();
let windows_sandbox_changed;
let mut tier_acceptance = None;
let (
commit,
previous_config,
@@ -2224,7 +2225,7 @@ impl Session {
}
state.session_configuration = updated;
if root_service_tier_changed && !state.shared_service_tier_pending {
crate::agent::host::propagate_config_update(
state.service_tier_acceptance = crate::agent::host::propagate_config_update(
self,
AgentConfigUpdate::ServiceTier(
state
@@ -2235,6 +2236,9 @@ impl Session {
),
);
}
if root_service_tier_changed || updates.step_settings.service_tier.is_some() {
tier_acceptance = state.service_tier_acceptance.clone();
}
let new_config = notify_config_contributors
.then(|| self.build_effective_session_config(&state.session_configuration));
let commit = SessionSettingsCommit {
@@ -2277,6 +2281,9 @@ impl Session {
if mcp_inputs_changed {
self.schedule_mcp_prewarm();
}
if let Some(accepted) = tier_acceptance {
accepted.await;
}
Ok(Some(commit))
}
@@ -4313,8 +4320,11 @@ impl Session {
)
};
if self.inherits_root_service_tier(&turn_context.session_source) {
let root_service_tier =
crate::agent::host::service_tier(self, settings.selected().service_tier.clone());
let root_service_tier = tokio::select! {
biased;
tier = crate::agent::host::service_tier(self, settings.selected().service_tier.clone()) => tier,
_ = cancellation_token.cancelled() => return Err(CodexErr::TurnAborted),
};
if settings.selected().service_tier != root_service_tier {
let mut selected = settings.selected().clone();
selected.service_tier = root_service_tier;
+2 -1
View File
@@ -347,7 +347,8 @@ async fn schedule_startup_prewarm_inner(
crate::agent::host::service_tier(
&session,
startup_turn_context.initial_settings.service_tier.clone(),
),
)
.await,
&session.features(),
&preconnect_model_info,
)