Skip to content

Add app-server current-time impl (varlatency 3/n)#28835

Open
rka-oai wants to merge 11 commits into
codex/varlatency-remindersfrom
codex/current-time-app-server-provider
Open

Add app-server current-time impl (varlatency 3/n)#28835
rka-oai wants to merge 11 commits into
codex/varlatency-remindersfrom
codex/current-time-app-server-provider

Conversation

@rka-oai

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

Copy link
Copy Markdown
Contributor

What

Server should request:

{
  "id": 42,
  "method": "currentTime/read",
  "params": {
    "threadId": "11111111-1111-1111-1111-aaaaafdc2c11"
  }
}

Client should respond with something like:

{
  "id": 42,
  "result": {
    "currentTimeAt": 1781717655
  }
}

Why

Sessions configured with clock_source = "app_server_client" need a thread-specific external time source before inference. The system clock remains the default production provider.

Validation

  • cargo test -p codex-app-server-protocol
  • cargo test -p codex-app-server --test all current_time_read_round_trip_adds_reminder_to_model_input
  • cargo test -p codex-app-server first_attestation_capable_connection_for_thread_only_uses_thread_subscribers
  • cargo test -p codex-analytics
  • just fix -p codex-app-server-protocol
  • just fix -p codex-app-server

Stacked on #28824.

@rka-oai rka-oai marked this pull request as ready for review June 18, 2026 03:22
@rka-oai rka-oai changed the title Add app-server current-time provider Add app-server current-time impl (varlatency 3/n) Jun 18, 2026

@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: d473fdc80a

ℹ️ 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/app-server/src/current_time.rs Outdated
Comment thread codex-rs/app-server-protocol/src/protocol/v1.rs
Comment thread codex-rs/app-server-protocol/src/protocol/v2/current_time.rs
thread_id: ThreadId,
) -> Result<DateTime<Utc>> {
let connection_ids = thread_state_manager
.current_time_capable_connections_for_thread(thread_id)

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.

P2 Badge Wait for subscriber attachment before reading app-server time

For threads created outside the synchronous thread/start path, such as subagents, client subscription is attached later by the thread_created_rx background branch, but the first model request can call this provider immediately. With clock_source = "app_server_client" and a reminder due on the first request, this lookup can see zero current-time-capable subscribers and fail the turn even though an initialized client would be attached moments later; make creation/attachment ordered for these threads or have the provider wait/retry for the initial subscriber.

Useful? React with 👍 / 👎.

@rka-oai rka-oai Jun 18, 2026

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.

Fixed cleanly for the supported single-client case in 5617874.

Comment on lines +53 to +55
/// Opt into `currentTime/read` requests for an external clock.
#[serde(default)]
pub request_current_time: bool,

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.

P2 Badge Keep current-time capability out of v1 initialize

Adding request_current_time to v1::InitializeCapabilities expands the v1 initialize contract and regenerates schema/json/v1/InitializeParams.json with a new current-time field. This current-time negotiation is new app-server API surface, so it should be modeled in v2/common protocol instead of extending v1.

AGENTS.md reference: AGENTS.md:L257-L260

Useful? React with 👍 / 👎.

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.

iiuc, this shouldn't be an issue

let capabilities = InitializeCapabilities {
experimental_api: self.experimental_api,
request_attestation: false,
request_current_time: false,

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.

P2 Badge Expose current-time opt-in through the client facade

For callers that use app-server-client and handle AppServerEvent::ServerRequest, this hard-coded false means they cannot advertise the new current-time capability even if they implement currentTime/read. With clock_source = "app_server_client", app-server will therefore find zero capable subscribers and fail the turn before inference; add a start/connect argument and forward it here (and in the remote connect args) so facade clients can opt in.

Useful? React with 👍 / 👎.

@rka-oai rka-oai Jun 18, 2026

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.

shouldn't be an issue. this should only support clients that connect directly to the app-server using JSON-RPC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant