codex: address PR review feedback (#22509)

This commit is contained in:
Eric Traut
2026-05-13 10:00:48 -07:00
parent c8e542aa77
commit 2fd121519c
2 changed files with 106 additions and 8 deletions
@@ -52,6 +52,9 @@ struct ResolvedTurnContextOverrides {
overrides: CodexThreadTurnContextOverrides,
}
const TURN_CONTEXT_APPLY_TIMEOUT: Duration = Duration::from_secs(5);
const TURN_CONTEXT_APPLY_POLL_INTERVAL: Duration = Duration::from_millis(10);
impl TurnRequestProcessor {
#[allow(clippy::too_many_arguments)]
pub(crate) fn new(
@@ -569,6 +572,30 @@ impl TurnRequestProcessor {
error
})?;
if let Some(after_turn_context) = after_turn_context {
if before_turn_context != after_turn_context {
let started = Instant::now();
loop {
let config_snapshot = thread.config_snapshot().await;
if thread_turn_context_from_snapshot(&config_snapshot) == after_turn_context {
break;
}
if started.elapsed() >= TURN_CONTEXT_APPLY_TIMEOUT {
return Err(internal_error(
"timed out waiting for turn context overrides to apply".to_string(),
));
}
tokio::time::sleep(TURN_CONTEXT_APPLY_POLL_INTERVAL).await;
}
}
self.maybe_emit_turn_context_updated(
&params.thread_id,
&before_turn_context,
after_turn_context,
)
.await;
}
if turn_has_input {
let config_snapshot = thread.config_snapshot().await;
codex_memories_write::start_memories_startup_task(
@@ -580,14 +607,6 @@ impl TurnRequestProcessor {
&config_snapshot.session_source,
);
}
if let Some(after_turn_context) = after_turn_context {
self.maybe_emit_turn_context_updated(
&params.thread_id,
&before_turn_context,
after_turn_context,
)
.await;
}
self.outgoing
.record_request_turn_id(&request_id, &turn_id)