Skip to content

current time reminders impl for system clock (2/n)#28824

Merged
rka-oai merged 9 commits into
mainfrom
codex/varlatency-reminders
Jun 18, 2026
Merged

current time reminders impl for system clock (2/n)#28824
rka-oai merged 9 commits into
mainfrom
codex/varlatency-reminders

Conversation

@rka-oai

@rka-oai rka-oai commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Stacked on #28822.

Summary

  • add a host-injectable current-time provider with a built-in system implementation
  • record UTC developer reminders in history immediately before due model requests
  • keep cadence state per session and force a refresh after compaction

This does NOT include the app server client <-> server clock logic. This PR is only for the reminder message & system clock that will be used in prod.

Testing

  • just clippy -p codex-core -p codex-app-server -p codex-mcp-server -p codex-thread-manager-sample
  • just fmt

@rka-oai rka-oai force-pushed the codex/varlatency-reminders branch 2 times, most recently from eccf43d to 05da7e6 Compare June 18, 2026 01:19
@rka-oai rka-oai changed the title Inject current-time reminders before sampling current time reminders impl (varlatency 2/n) Jun 18, 2026
@rka-oai rka-oai changed the title current time reminders impl (varlatency 2/n) current time reminders impl for system clock (varlatency 2/n) Jun 18, 2026
@rka-oai rka-oai marked this pull request as ready for review June 18, 2026 01:57
@rka-oai rka-oai requested a review from a team as a code owner June 18, 2026 01:57

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e8c21f1b20

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread codex-rs/core/src/session/time_reminder.rs
.expect("test config should allow current-time reminders");
config.current_time_reminder = Some(CurrentTimeReminderConfig {
reminder_interval_model_requests: interval,
clock_source: CurrentTimeSource::AppServerClient,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[found by codex] These tests only exercise AppServerClient; please add coverage for the production System source.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

.build(&server)
.await?;

test.submit_turn("first turn").await?;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[found by codex] This proves cadence across turns, not model requests; please cover a tool-call follow-up within one turn.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment thread codex-rs/core/src/current_time.rs Outdated

match config.clock_source {
CurrentTimeSource::System => Ok(Some(Arc::new(SystemCurrentTimeProvider))),
CurrentTimeSource::AppServerClient => external_provider.map(Some).ok_or_else(|| {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Probably should be named external

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

renamed to external everywhere in the stack

Comment thread codex-rs/core/src/thread_manager.rs Outdated
state_db: Option<StateDbHandle>,
installation_id: String,
attestation_provider: Option<Arc<dyn AttestationProvider>>,
external_current_time_provider: Option<Arc<dyn CurrentTimeProvider>>,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: external_time_provider

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and TimeProvider

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

.services
.current_time_provider
.as_ref()
.ok_or_else(|| CodexErr::Fatal("current-time provider is not configured".to_string()))?;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's a lil strange that we have 2 sources of truth for how this feature is enabled. Pick one.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

.await;

let mut state = sess.state.lock().await;
state.current_time_reminder.record_delivery(window_id);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we have 1 method?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment thread codex-rs/core/src/session/turn.rs Outdated
Comment on lines +229 to +236
info!("Turn error: {err:#}");
sess.emit_turn_error_lifecycle(turn_context.as_ref(), err.to_codex_protocol_error())
.await;
sess.track_turn_codex_error(turn_context.as_ref(), &err);
let event = EventMsg::Error(err.to_error_event(/*message_prefix*/ None));
sess.send_event(&turn_context, event).await;
return None;
}

@pakrym-oai pakrym-oai Jun 18, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not in love with this special pile of error handling. Can we have all error handling localized? maybe by reordering things

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cleaned up

@rka-oai rka-oai force-pushed the codex/varlatency-config branch from 7a0e21d to 88be248 Compare June 18, 2026 11:39
@rka-oai rka-oai force-pushed the codex/varlatency-reminders branch 3 times, most recently from 38a6d16 to d45f58b Compare June 18, 2026 11:55
@rka-oai rka-oai force-pushed the codex/varlatency-config branch from 5df1f8f to 221ef10 Compare June 18, 2026 12:40
@rka-oai rka-oai force-pushed the codex/varlatency-reminders branch 2 times, most recently from 4d678ec to f09e32e Compare June 18, 2026 12:47
@rka-oai rka-oai force-pushed the codex/varlatency-config branch from 3f08ca5 to 98dbb60 Compare June 18, 2026 16:14
@rka-oai rka-oai force-pushed the codex/varlatency-reminders branch from 14e4299 to 0539ddc Compare June 18, 2026 16:14
@rka-oai rka-oai force-pushed the codex/varlatency-config branch from 98dbb60 to c8424ce Compare June 18, 2026 17:19
@rka-oai rka-oai force-pushed the codex/varlatency-reminders branch from 0539ddc to 671d4f5 Compare June 18, 2026 17:19
@rka-oai rka-oai force-pushed the codex/varlatency-config branch from c8424ce to 88a9dc6 Compare June 18, 2026 18:07
@rka-oai rka-oai force-pushed the codex/varlatency-reminders branch from 671d4f5 to 933b6ab Compare June 18, 2026 18:07
Base automatically changed from codex/varlatency-config to main June 18, 2026 18:39
@rka-oai rka-oai enabled auto-merge (squash) June 18, 2026 18:48
@rka-oai rka-oai force-pushed the codex/varlatency-reminders branch from 933b6ab to 5396ac2 Compare June 18, 2026 18:55
@rka-oai rka-oai force-pushed the codex/varlatency-reminders branch from 5396ac2 to ba927fa Compare June 18, 2026 18:57
@rka-oai rka-oai merged commit 752ed90 into main Jun 18, 2026
45 of 47 checks passed
@rka-oai rka-oai deleted the codex/varlatency-reminders branch June 18, 2026 19:18
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 18, 2026
@rka-oai rka-oai changed the title current time reminders impl for system clock (varlatency 2/n) current time reminders impl for system clock (2/n) Jun 18, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants