mirror of
https://github.com/openai/codex.git
synced 2026-11-27 15:30:27 +00:00
Add opt-in nonfatal handling for clock read failures (#45825)
## Why Clock provider failures can abort a turn while preparing time context or running clock tools. Allow turns to continue with an explicit indication that the current time is unavailable. ## What changed - Add `features.nonfatal_clock_read_errors`, disabled by default, to report clock failures to the model without failing the turn. - Emit a generic `failed to read current time` notice for context reads and tool errors, without exposing provider error details. Deduplicate context notices per turn and compaction window, and remove inherited notices from forked subagent context. - Omit unavailable environment dates and explicitly clear previously visible dates with `<current_date status="unavailable" />`. - Return external sleep clock failures to the model when the feature is enabled, preserving sleep item completion notifications. ## Testing Add coverage for continued inference after clock failures, notice deduplication across compaction, subagent notice filtering, environment date removal and recovery, and sleep failures during initial and polling reads. GitOrigin-RevId: a39c3723c06a6f786d8ad59d667e8b9f626c973e
This commit is contained in:
1 parent
fac58c1153
commit
5bf132cd52
14 files changed
+367
-48
No files matched your search
@@ -1623,8 +1623,14 @@ async fn spawned_full_history_v2_child_uses_model_precedence_without_dropping_co
|
||||
.features
|
||||
.enable(Feature::CurrentTimeReminder)
|
||||
.expect("test config should allow feature update");
|
||||
config
|
||||
.features
|
||||
.enable(Feature::NonfatalClockReadErrors)
|
||||
.expect("test config should allow feature update");
|
||||
config.include_environment_context = false;
|
||||
config.current_time_reminder = Some(CurrentTimeReminderConfig {
|
||||
reminder_interval_seconds: 0,
|
||||
clock_source: codex_features::CurrentTimeSource::External,
|
||||
..CurrentTimeReminderConfig::default()
|
||||
});
|
||||
}
|
||||
@@ -1652,6 +1658,31 @@ async fn spawned_full_history_v2_child_uses_model_precedence_without_dropping_co
|
||||
if matches!(selection, FullHistoryV2ModelSelection::WorldStateIdentity) {
|
||||
builder = builder.with_history_mode(ThreadHistoryMode::Paginated);
|
||||
}
|
||||
if matches!(selection, FullHistoryV2ModelSelection::CurrentTimeReminders) {
|
||||
#[derive(Default)]
|
||||
struct FailFirstClockRead(std::sync::atomic::AtomicBool);
|
||||
|
||||
impl codex_core::TimeProvider for FailFirstClockRead {
|
||||
fn current_time(&self, _thread_id: ThreadId) -> codex_core::TimeFuture<'_> {
|
||||
let already_read = self.0.swap(true, std::sync::atomic::Ordering::Relaxed);
|
||||
Box::pin(async move {
|
||||
anyhow::ensure!(already_read, "parent clock unavailable");
|
||||
Ok(chrono::Utc::now())
|
||||
})
|
||||
}
|
||||
|
||||
fn sleep(
|
||||
&self,
|
||||
_thread_id: ThreadId,
|
||||
_duration: Duration,
|
||||
) -> codex_core::SleepFuture<'_> {
|
||||
Box::pin(async { Ok(()) })
|
||||
}
|
||||
}
|
||||
|
||||
builder =
|
||||
builder.with_external_time_provider(std::sync::Arc::new(FailFirstClockRead::default()));
|
||||
}
|
||||
let test = builder.build(&server).await?;
|
||||
if matches!(selection, FullHistoryV2ModelSelection::WorldStateIdentity) {
|
||||
test.codex.submit(Op::Compact).await?;
|
||||
@@ -1806,15 +1837,23 @@ async fn spawned_full_history_v2_child_uses_model_precedence_without_dropping_co
|
||||
);
|
||||
}
|
||||
if matches!(selection, FullHistoryV2ModelSelection::CurrentTimeReminders) {
|
||||
let reminder_count = |request: &ResponsesRequest| {
|
||||
let notice_count = |request: &ResponsesRequest, marker: &str| {
|
||||
request
|
||||
.message_input_texts("developer")
|
||||
.into_iter()
|
||||
.filter(|text| text.starts_with("<current_time_reminder>"))
|
||||
.filter(|text| text.starts_with(marker))
|
||||
.count()
|
||||
};
|
||||
assert_eq!(reminder_count(&parent_request), 2);
|
||||
assert_eq!(reminder_count(&child_request), 1);
|
||||
assert_eq!(
|
||||
notice_count(&parent_request, "<current_time_unavailable>"),
|
||||
1
|
||||
);
|
||||
assert_eq!(notice_count(&parent_request, "<current_time_reminder>"), 1);
|
||||
assert_eq!(
|
||||
notice_count(&child_request, "<current_time_unavailable>"),
|
||||
0
|
||||
);
|
||||
assert_eq!(notice_count(&child_request, "<current_time_reminder>"), 1);
|
||||
}
|
||||
let child_body = child_request.body_json();
|
||||
if matches!(selection, FullHistoryV2ModelSelection::WorldStateIdentity) {
|
||||
|
||||
Reference in new issue
Block a user