Repository navigation
feat(agents): Codex follows the env's clock, its CLI on real time and the model told the env's date - #926
Merged
Conversation
… the model told the env's date The Codex image takes the clock follower, libfaketime and the egress proxy, so its card serves clock/v1 sync_time and sync_env_clock's agent_clock has it follow. The Codex CLI is a static binary that no preloaded library reaches, so it stays on real time while the commands it runs read the env's time; each CLI run calls the endpoint through a model relay of its own, which puts the env's date in the environment context and time reminder the CLI writes, and refuses a call it can't date. mcp-remote gets the egress proxy on an armed clock. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ommand to Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
earakely-scale
marked this pull request as ready for review
November 25, 2026 19:09
…the CLI writes, and two timing tests get room A task prompt that quotes an environment context or a time reminder is now sent as written, not rewritten or refused: the relay takes a text as the CLI's only when it is one fragment between its markers. The two tests that gave a stand-in 1 s to start a child under xdist load (Codex's and OpenCode's hung date, Codex's hung catalog read) now give it 3 s. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… tests, and the clock e2e reads pinned CLI versions The start-agent CA-bundle test, copied into Codex's, OpenCode's and Letta Code's suites, is one parametrized test in test_agent_clock_images.py. The stand-in date the Codex and OpenCode date tests share is tst/util/fake_date.py. The agent clock e2e reads the Codex and OpenCode versions its --version checks from each agent's package.json, so a CLI bump doesn't leave them stale. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Collaborator
Author
|
🤖 Automated Claude routine — Env Pod PR Context Review. This is a bot, not Edgar Arakelyan; not a human review. Context from another open PR: #924 (Codex/Gemini atif/1) starts from the same base (
Just a merge-order heads-up. Neither PR is wrong on its own. Generated by Claude Code |
…n static host, whose Date reads real time Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…5-codex-clock-sync
…ent too, which merged from main Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…LI starts Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Codex didn't follow a task env's clock. Its card served no clock/v1
sync_time, sosync_env_clockwithagent_clockrecorded it asnot_advertisedand moved on. The commands the model ran read real time.Worse, Codex tells the model the date itself. Every request's
<environment_context>carries<current_date>, from the CLI's own clock (local_time_context()in codex-rscore/src/session/turn_context.rs). So a Codex run on a 2031 story told the model it was the machine's date.The CLI can't simply be put on the clock the way Claude Code is.
@openai/codex's Linux builds (x64 and arm64) are static musl binaries, which/etc/ld.so.preloadand libfaketime never reach.What
The image follows the clock like the other clocked agents.
utils/faketime_clockandutils/egress_proxy(shared_sources.toml), withstart-agentandroot.confas Claude Code's image has them.agentwith the real-time marker.sync_timethrough the protocol's framework, sosync_env_clockwithagent_clock(orrequire_agent_clock) has it follow.The CLI stays on real time; the commands it runs don't. Codex, a static binary, keeps real time whatever the clock, so its threads, rollouts and resumes are unaffected by a clock set behind them. The commands the model runs (bash,
date, python, node) and the MCP clients the CLI starts read the env's time.Each CLI run calls the endpoint through a model relay of its own (
model_relay.py, shared with OpenCode and Letta Code), given to the CLI as a-coverride of the provider'sbase_url. While the clock is armed, the relay's rewrite (codex_date.py) puts the env's date, read fromdate, into every message of each call:<environment_context>'s<current_date>, a resumed thread's earlier ones included;<current_time_reminder>Codex gives a turn atpersistenteffort.The relay takes a text as the CLI's only when the whole text is one such fragment between its markers, as Codex writes them, so a task prompt that quotes one is sent as written. A call whose date can't be read, or whose fragment writes a date or time in a form the relay doesn't know, is refused. The turn then fails rather than tell the model the machine's date. Off the clock, calls go through untouched.
MCP through the egress proxy. On an armed clock, the CLI's commands and MCP clients get the egress proxy (
agent_egress.egress_env, with the env's MCP URLs). Codex hands a stdio MCP server only the variables its entry names, somcp-remote's entry now names the proxy variables too. It also gets--enable-proxy, since mcp-remote's bundled HTTP client ignores proxy variables without it; with none set, it connects directly as before.install/v1 copies the relay and the clock modules beside the bridge. An installed agent has no follower, so it calls through the relay with nothing to rewrite.
The protocol floor moves to 0.1.643 (
ModelUsage.of, which the relay uses), andaiohttpjoins the requirements.Not changed
ls -lin a solver's sandbox still shows the machine's date.<timezone>stays the container's.execincodex-code-mode-host, another static binary. The tools it calls follow the clock, but JavaScript's ownDatein that code reads real time. This follows from the binary being static; no run here was seen using it, since the trajectory doesn't record the JavaScript.Tests
Unit:
codex_date: the env's date and time in every environment context and reminder, the first and a resumed thread's; before 1970, in 2200, in the CLI's zone; text outside an environment context and tool output left alone; off the clock or with nothing to rewrite, the call goes byte for byte; a non-JSON call, an unknown date or time form, adatethat fails, hangs or leaves a child are refused.--enable-proxy.test_agent_clock_images.pycovers Codex like the other clocked agents.Integration:
codex_env_date_test.pyruns the CLI package-lock.json pins against a fake Responses endpoint, a new thread and a resumed one, with the clock armed: every<current_date>the CLI sent carries the env's date, and no part of any request carries the machine's. With the rewrite off, the same test fails on2026-11-25. Bumping the CLI runs it against the new version.test_agent_env_clock_local.pygains Codex: deployed with an env on local Docker, it follows the env's clock until it is torn down, its turn told the env's date and its shell'sdatethe env's. Passes on x86_64 and arm64.E2E on dedicated VMs, a stand-in model, A/B against main. Each run: the mail env and Codex on local Docker, the clock armed with
agent_clock, turns that call the gateway'sget_time, the env'ssearch_emailsand a shell probe (date, python, node, HTTPS from python and node), a late agent, in-container probes.CERT_HAS_EXPIRED/CERT_NOT_YET_VALID, as expected). The machine's date appeared only in tool output, from file times.clear(real dates again) and a re-arm withoutagent_clock;dateremoved: the turn failed naming why, and the next turn, withdateback, passed;require_agent_clock;persistenteffort: each time reminder carried the env's time.not_advertised, and every call told the model the machine's date;require_agent_clockfailed the run.install/v1: Codex installed into a Debian task container and onto the sandbox's host answered through its relay on real time (Alpine is refused for glibc, as before).
Real models, A/B against main:
get_time, an invoice from the env's mail, anddate, python and node, the model answered with the env's date for every one.CONTEXT_DATE: 2026-11-25whileget_timesaid 2031-03-04.persistenteffort, Codex sendsreasoning.effort: "disabled", which gpt-6.2-astra answers with a 500 on main and on this branch alike. The reminders those calls carried had the env's time, as a stand-in run at that effort shows end to end.On the prod hub, real Cooperation Bench tasks, A/B against today's
codex-cli(v37): this branch's image registered as a test agent, two tasks run once on each image the benchmark's way (gpt-6-astra atxhigh, sandboxes closed at the end).The image built on Modal from its build context and deployed; its solver synced in both tasks (
synced: true), where v37 wasnot_advertised.All four runs completed with no failed step and no permission error; neither solver ran a shell command (the tasks give it MCP tools only).
Scores: on kl01 both images scored 1.0 (Codex's earlier runs: 4 of 5). On kl12, over three batches:
The latest three runs of this image all passed, no agent wrote about the date in any run, and two misses in fourteen runs split this way happen by chance about one time in four. So there's no measured effect of the story date on this task.
Test upkeep: the start-agent CA-bundle test, which Codex's, OpenCode's and Letta Code's suites each had a copy of, is one parametrized test in
test_agent_clock_images.py; the stand-indatethe Codex and OpenCode date tests share istst/util/fake_date.py; andtest_agent_env_clock_local.pyreads the Codex and OpenCode versions its--versioncheck expects from each agent's package.json.Timing tests: the hung-
datetest (Codex's and OpenCode's) and Codex's hung catalog read gave a stand-in 1 s to start its child, which xdist load sometimes exceeds (OpenCode's failed 6 of 8 runs under 12 workers). They now give it 3 s, and 8 of 8 runs passed.🤖 Generated with Claude Code


Confidence Score: 5/5
The PR appears safe to merge with the documented mid-turn proxy limitation accepted.Summary
Codex gains the shared clock follower and egress proxy. Each CLI run uses a model relay to replace Codex’s date and time with the environment’s while the clock is armed.
Diagram
%%{init: {'theme': 'neutral'}}%% flowchart LR Clock[Environment clock] --> Follower[Clock follower] Follower --> Commands[Commands and MCP clients] CLI[Codex CLI on real time] --> Relay[Per-run model relay] Follower --> Date[Environment date] Date --> Relay Relay --> Endpoint[Model endpoint]Reviews (9) · Last reviewed commit: "docs(agents): a clocked agent's proxy se..." · Reviewed by Greptile