Repository navigation
[FD-5916] feat(agents): the Codex image follows the env's clock - #765
williamloo-scale wants to merge 65 commits into
Conversation
…5916) Prototype of the Agents on the Env Clock design, to size the change. The gateway takes followers declared after it starts; every AgentEnvAgent in an image that runs the clock follower serves clock/v1 sync_time; sync_env_clock and deploy_agent declare each agent as a follower and hand it its config; the Claude Code image runs the computer base's follower, egress proxy and libfaketime, copied in until FD-5700; get_time no longer calls the machine's clock unsynced. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…kip unless require_agent_clock The image's changes move to wloo/claude-code-clock-image, along with the computer base's egress options only it uses: on CI the image's Claude Code timed out reaching the test's model endpoint. What stays serves sync_time for an agent whose image runs the follower and is otherwise inert. An agent that can't follow is now skipped even when tolerate_missing_sync_time is false, which stays about the env's servers; require_agent_clock fails the step instead. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The image half of the agent clock: the computer base's clock follower and egress proxy, copied in until FD-5700, libfaketime preloaded for the agent's user, root's supervisord starting them and the A2A server, and the CLI sent through the proxy. Needs #714 and an agentenv-protocol release with CLOCK_V1. Not ready: on CI this image's CLI timed out reaching the integration tests' model endpoint, likely the proxy refusing a private address; it should go through the proxy only once the clock is armed. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…gent, retire on teardown - An agent's sync_time takes only a status of the config it just wrote (its URL and name, written after it), so what the follower showed of an earlier gateway or token never passes for success. - An agent follows one env's clock; another env's is skipped as follows_another_env, as its one follower can't watch two gateways. deploy_agent's late follows are recorded with the sync's, so both see it. - teardown_sandboxes retires a torn-down agent's follower (DELETE /clock/followers, retire_follower), so later writes don't wait for it or answer 504 naming it. A declaration no longer replaces a follower the gateway started with. - Logs say an outcome's synced, reason and follower, never the agent's answer; the timeouts, token size and error length are named constants. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…tirement wakes waiting writes - Which env an agent follows moves from clock_configurations' items to metadata.agent_clock_following, one key per agent, so late deploy_agent steps that save at once never overwrite each other's record and teardown still finds it. - Retiring a follower notifies writes waiting for it, and a watch by a follower retired meanwhile acknowledges nothing. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
… retire however its sandbox goes - Agent names are percent-encoded into their metadata keys, so team.solver and team_solver never share a record. - An agent follows the clock of the first env it's registered with, fixed by the agent alone, so two steps arming two of its envs at once never both take its one follower. - teardown_sandboxes retires the follower of every agent whose sandbox it takes down, by agent, sandbox or env name. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…d on local Docker (FD-5916) Deploys the image with an env, runs sync_env_clock with require_agent_clock, and checks that the agent's user reads the env's time (date and datetime.now()) while the real-time marker opts out; that a write waiting for followers waits for the agent, answering 504 naming it while its container is paused; and that after teardown_sandboxes writes no longer wait for it. Skipped unless AGENTENV_E2E_CLAUDE_CODE_IMAGE names an image built from this branch. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…e survives a server restart; get_time keeps its sentence - follow retires the follower it declared when the agent's sync_time fails, by an HTTP error or a transport one, so the gateway isn't left waiting on every later write for a follower that never watches. - sync_time saves the task's zone in the follower's config, and the A2A server takes it back when it starts, so a server supervisord restarts mid-run keeps the zone as the follower keeps the clock. - get_time's description keeps "the clock on the machine you are running on is not synchronized": most agents won't follow the clock for a while yet. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…through the proxy only on an armed clock - The agent's libfaketime takes Edgar's init guard: a clock call made while ftpl_really_init runs on that thread, as the CLI's allocator makes one when dlsym allocates, reads the kernel's clock instead of waiting on pthread_once, which deadlocked: claude --version never returned. The computer base's patch doesn't take it yet; the agent's copy is the base's, then the guard, which the drift test checks. - The CLI goes out through the egress proxy only while the follower follows an armed clock (clock_armed), and reaches a plain-HTTP model endpoint directly then: unarmed, it goes out as before, so a private endpoint keeps working. - egress/ is the base's again after main moved it. - The e2e test checks claude --version under the preload, and one turn of the real CLI against a stub Messages endpoint: its "Today's date is" line and a Bash date are the env's. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
… down alone Their records stay in deployed_agents after teardown, and calling their gone servers failed the step. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…browser base's egress copy takes boot.go - test_agent_env_clock_local skips as agentenv-capability-missing: agent_clock_image, which the slow integration job allows, as no CI job builds agent images. - ubuntu-24.04-browser's egress/ is ubuntu-24.04's again, with this PR's AGENTENV_SESSION_USER and AGENTENV_EGRESS_NSS. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…tocol's tests write it Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…lag, not the follower's status The page is what libfaketime reads, and it keeps the last armed clock while the follower reconnects to a restarted gateway or restarts itself, when its status says connected false or armed false. A CLI started then reads the env's time, so it must go through the proxy. Unit tests pin both windows. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…ds show An agent whose card serves clock/v1 sync_time is now checked end to end after the validation DAG: the validation env's clock is armed frozen in America/Chicago with require_agent_clock, the agent runs `date` through its harness and must show that instant and zone, a write that waits for followers must be acknowledged, and `date` must show the time it moved to. A synced follower alone doesn't pass: an image whose preload is missing, or whose harness can't run under it, follows and still fails. An agent whose card serves no sync_time is skipped. The result is recorded under validated_a2a_extensions[urn:agentenv:clock/v1] and verifications["a2a_clock"]. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ength Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…ed with the env An agent in an image that follows the env's clock reads the env's time, so "is not synchronized, so do not use it" is false for it. "May not be" holds for every agent, following or not, and get_time answers what a following agent's clock already shows. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…he other agent extension clients It drives an agent's clock/v1 sync_time and the gateway's follower declarations for the steps that call it (sync_env_clock, deploy_agent, teardown_sandboxes), as object_transfer does for snapshot transfers; it defines no step. The name mirrors agentenv_protocol.a2a_agent.clock, the agent's side of the same extension. The persisted metadata key agent_clock_following is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…t.clock, where #714 moved it Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…st with an agent's clock/v1 sync_time 0.1.575 is the release that carries #714 (agentenv_protocol.a2a_agent.clock): before it, the image's protocol serves no clock/v1, so the agent advertises none and sync_env_clock skips it as not_advertised. The image is built again only when this folder changes, so the floor is what makes it take the release. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… gateway refuses at once A watch that fails fast (connection refused) answers before the follower's quarter-second poll sees a changed config, and the retry backoff ends early on that change, so the follower kept retrying the old URL in a tight loop and never followed the new one: an agent re-synced to another gateway after its first one went away stayed on the old clock, burning a core, and every write that waited for it answered 504. It now checks the config after each failed watch. The base's, the browser base's and the Claude Code image's copies stay identical. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ct; name the egress probe's error limit - egress_env merges the hosts NO_PROXY and no_proxy already name with the direct ones, so a private registry the agent was deployed to reach directly isn't sent to the proxy, which refuses it, once the clock is armed. - egress/upstream.go names its 200-character problem limit (problemChars), in the computer bases' copies too, which stay byte for byte the same. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…ge, not Claude Code's alone - tst/unit/agents/test_agent_clock_images.py: every agent folder with clock/ copies the base's clock pieces with the init guard, runs the follower, the proxy and the server as their users, preloads libfaketime for the agent's user, starts as another user as before, and decides the CLI's proxy with the same clock_armed and egress_env as Claude Code. - The local e2e runs over each image AGENTENV_E2E_AGENT_IMAGES names (claude-code=<tag>,...), with a CLI turn for an agent whose CLI the stub endpoint speaks to. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
|
🤖 Automated Claude routine — Env Pod PR Context Review. This is a bot, not Edgar Arakelyan; not a human review. Context from a sibling PR rather than from this diff. #818 (open, ready) moves the clock-egress rule out of the per-agent bridges into one
One behavioural note on the same seam: #818 was opened for an env whose Generated by Claude Code |
# Conflicts: # tst/integration/task_step/test_agent_env_clock_local.py
|
Hi @williamloo-scale, this is Claude, working with Edgar. Please don't merge this yet. It needs #818 merged a single egress rule for every clocked agent:
This branch still has its own Why it matters beyond the test: on an armed clock, the CLI checks TLS certificates against the virtual date. An env on Modal whose Codex specifically: only the model endpoint goes direct here, so MCP is already proxied. This one is just the migration. If it helps, I can push the merge and migration commits to this branch and run the same armed-clock end-to-end check against a Modal env. Just say so here or on Slack. |
The bridge imports clock_armed and egress_env from agent_clock's agent_egress, which the image and an install copy beside it with clockpage, and hands it the model endpoint's URL; its own copy of the rule goes. mcp-remote, which codex hands only the trust variables, is still not given the proxy. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…ss proxy on an armed clock Codex hands mcp-remote only the variables its env_vars names, so on an armed clock it went to an HTTPS MCP server directly and checked the server's certificate against the env's date. It now gets the proxy's variables too, and the bridge hands the egress rule every MCP server's URL, so only plain-HTTP ones go direct, as #818 has for Claude Code and OpenCode. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
|
Thanks, done, with one correction: codex's MCP wasn't already proxied. Codex hands a stdio server only what @greptileai review |
|
Claude again, working with Edgar. Thanks for the update. The migration onto
I agree with Greptile's open P1 on
It would help to say in the PR why Codex needs 1970. My guess is that its TLS stack rejects a Two codex-scoped options:
I can run the armed-clock check against a Modal env for Codex once this settles, if that helps. |
The shared proxy's leaves had been floored at the Unix epoch because rustls refuses an earlier certificate, but only the Codex CLI checks with rustls, and it now runs on real time and reaches the model endpoint directly. The floor broke HTTPS for every computer and agent following a clock before 1970, and rebuilt both computer bases. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…low the clock and its proxy The Codex CLI is a static musl binary, so the preloaded libfaketime never reaches it: it, its state and its own certificate checks run on real time, and it reaches the model endpoint directly. On an armed clock each CLI run now: - keeps proxy variables out of the CLI's own environment and gives them to the model's commands alone, through `-c shell_environment_policy.set.*`, built from the shared `egress_env`; - starts each MCP server's mcp-remote with AGENTENV_REAL_TIME=1 (`-c mcp_servers.<name>.env.*`), so its certificate checks, cookie and token expiry and leases stay on real time and it reaches the servers directly; config.toml's entries go back to main's; - puts the env's date and zone before the prompt, as `date` shows it, since Codex renders the host's real date into its <environment_context>, and says that a clock tool and Date in code mode's JavaScript read real time too. Unarmed, a run's command, environment and prompt are main's, which a test pins. Tests at the spawn and through the A2A server fail when the wiring is removed. The image's comments say what follows the clock and lose a ticket id. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… a fake Responses API The codex row now runs one turn of the real CLI in the image: the date line the agent puts before the prompt and a shell `date` the model runs show the env's time, and the CLI's own <environment_context> date is the host's. tst/util/fake_responses.py answers the CLI with the shell tool its request offers, then quotes the output. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…the image's server applies the clock The real-time marker given to an MCP server's environment never reached mcp-remote: its bin is a `#!/usr/bin/env node` script, so env, the first program libfaketime loads into, stayed on real time and took the marker out of what it handed Node, which then checked certificates and compared expiries on the env's clock. On an armed run each server is now started as Node with mcp-remote's script and config.toml's arguments (`codex_config.server_args`), the marker in its environment. Unarmed runs and config.toml are unchanged. The clock applies only where root.conf starts the server, as the user libfaketime fakes, with the egress proxy in its environment (`clock_followed`): an install/v1 agent runs as root, whose commands stay on real time, so a computer's armed page no longer gets its real date labelled as the task's. The local agent clock e2e checks in the image that the env MCP server's Node process got the marker. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e, the peer agents' server's too The CLI is given two MCP servers on Linux, the env's and the agent's own peer_agents server, so a turn starts two mcp-remote processes; the e2e expected one and failed on the VM with both marked. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nning In the image supervisord restarts a crashed A2A server in place, and the CLIs it was running, each leading a session of its own, outlived it: on the VM a server killed -9 mid-turn left its CLI running for another 20 s, writing to the workspace and its thread's rollout beside the restarted server. The server now kills every codex exec of its user that leads its own session, process group and all, as it starts; only where root.conf starts it (AGENTENV_EGRESS_PROXY), since elsewhere a crash ends the agent. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
On main the server was the container's only process, so its death ended the container and the run failed within prompt_agent's unreachable window. Under root's supervisord a crashed server was started again in place: the dead server's CLI went on writing in its own session, the new server had lost the task's MCP servers, config, peers and running tasks, and prompt_agent polled "Task not found" until its timeout. root.conf now never starts the server again (autorestart=false, startretries=0) and an agent-exit event listener has supervisord shut down when the server exits or can't start; the clock follower and the egress proxy keep restarting in place. supervisord 4.2.5 exits 0 after a signalled shutdown, so the container's exit status is 0. The startup sweep of the CLIs a crashed server left running is gone with the case it handled. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Hi @williamloo-scale, Claude here, working with Edgar. I finished this PR on your branch. Edgar asked me to bring all five clock PRs to the same bar as Claude Code's (#818, #831, #832). What changed
Tested on a dedicated VM, with a stand-in model and real models, side by side with
Greptile is 5/5 on the head and CI is green. Also new here: if the A2A server dies, the container now exits, as on Merging: the five clock PRs (#765 #768 #769 #770 #771) each add a row to The full details are in the PR description. Claude, working with Edgar |
|
Closing this, per Edgar's decision. Claude here, working with Edgar. Why: Codex can't follow libfaketime faithfully. Every Linux build OpenAI publishes is a static musl binary (0.162.1 ships only Edgar's rule: an agent advertises the clock ( What this agent does instead: it stays as it is on
What's kept: the branch stays for reference. The investigation is in this PR's description and comments, and in Linear FD-6434. Thanks for all the work on this, William. It's what showed where libfaketime does and doesn't hold up. Claude, working with Edgar |
What and why
The Codex image can follow a task env's clock when the task opts in with
sync_env_clock'sagent_clock(orrequire_agent_clock). Claude Code has had the same opt-in since #832. Without it, Codex runs on real time as before.Codex can't follow the clock the way Claude Code does. On Linux the Codex CLI is a static musl binary, and so are
codex-code-mode-hostandbwrap, so the preloaded libfaketime never reaches them. So this PR leaves the CLI, and thestate it keeps, on real time: rollouts,
state.db, thread ids and its own certificate checks. Only the model's commandsfollow the clock, and the model is told the env's date.
How it works
The image is the same kind as Claude Code's and OpenCode's:
shared_sources.tomltakesutils/faketime_clock,utils/egress_proxyandutils/agent_clockfrom agent-env'sone copy of each.
start-agentandroot.confrun root's supervisord. The clock follower and the egress proxy each run as their ownuser, on real time. The A2A server runs as
agentwith the real-time marker, which libfaketime takes out of itsenvironment, so what it starts is faked.
agentuser alone.start-agentmerges a provider's CA bundle (Sail's, say) into agent-env's trust files and into the proxy's roots.main, where the server was the container's only process. root.confnever starts it again (
autorestart=false,startretries=0). Anagent-exitevent listener, a few lines of Pythoninline in root.conf that speak supervisord's eventlistener protocol, hears
PROCESS_STATE_EXITEDandPROCESS_STATE_FATAL. When the process isagent, it sends its parent, supervisord, a SIGTERM. supervisord thenstops the follower and the proxy and exits, and the container with it. The follower and the proxy keep restarting
in place. A server started again would have lost the task's MCP servers, config, peers and running tasks, and the
dead server's CLI would have gone on in the workspace beside it.
A CLI run applies the clock only when
clock_followed()holds: the clock page is armed (the sharedclock_armed(),read once per CLI run) and the server has
AGENTENV_EGRESS_PROXYin its environment. Only root.conf sets thatvariable, and root.conf starts the server as the user libfaketime fakes. An agent installed with
install/v1runs asroot, and libfaketime doesn't fake root's commands. So such an agent never applies the clock, even inside a computer
whose clock page is armed. Without this check it would tell the model that the real date was the task's.
On such a run, each
codex execalso gets:Each MCP server's mcp-remote, started by Node itself on real time. These overrides change how the server starts:
-c mcp_servers.<name>.command="<node>";-c mcp_servers.<name>.args=["<.../mcp-remote/dist/proxy.js>", <config.toml's args>];-c mcp_servers.<name>.env.AGENTENV_REAL_TIME="1".mcp-remote compares its clock with server times and real file times: cookie
Expires, lease ages, a stale-filesweep by mtime, OAuth token expiry. On real time it also checks certificates against the real date, so it reaches
the servers directly. That includes an HTTPS server on Modal whose certificate starts after the virtual date, and a
clock behind real time (proven in the image by E3 below). The marker has to reach Node itself. mcp-remote's bin is
dist/proxy.js, which starts with#!/usr/bin/env node. Started that way, the first process isenv, which isdynamically linked. libfaketime keeps
envon real time, takes the marker out of its environment, andenvthenexecs Node without it. config.toml still names
mcp-remote, so an unarmed run starts it as before.The egress proxy for the model's commands.
-c shell_environment_policy.set.<VAR>=...sets the proxy variablesfrom the shared
egress_env. The model's commands check certificates against the env's date, so they go out throughthe proxy. The exceptions are loopback,
NO_PROXY's hosts, and the model endpoint's and MCP servers' hosts whenthey are served over plain HTTP only.
The env's date before the prompt, as an
<environment_clock>note: "Today is 2027-02-03 (Wednesday) inAmerica/Chicago on this task's clock…". The date is what
dateprints when the real-time server starts it.The CLI's own environment has no proxy variables. It checks the model endpoint's certificate on real time and reaches
the endpoint directly.
What the model sees on an armed clock
The env's time:
date, Python, Node and everything else it runs (bash, git,rgon arm64, the bundledzsh);what its commands write into files; the gateway's
get_time; and the note at the top of every turn. File mtimesstay real, because stat isn't faked.
The host's real time:
current_datein Codex's own<environment_context>, which the CLI renders. Codex has no setting for it.include_environment_context = falsewould also drop cwd, shell and permissions.developer_instructionssit ina thread's first context only, so they can't follow a clock that moves between turns.
clock_source = "external"fails
codex execat session start.Datein the JavaScript the model runs in Codex'sV8 host (
codex-code-mode-host, static);clocktool.The note tells the model all of this and says to go by the env's clock. Whether models follow it is what E1 and E2
below measure.
Clock off
With no
agent_clock, the bridge builds the same command, CLI environment and prompt as onmain, and a unit testpins this. config.toml is unchanged. What still differs at the image level:
agent(uid 10001). On localDocker the old image already ran as
agent. Providers that ignoreUSERand ran the old image as root (Modal) nowrun the server, the CLI and the model's commands as uid 10001. Those commands can't
apt-get installor writeroot-owned paths, including files a root step stages into
/app./appitself and/home/agent/.codexareagent's.SUPERVISOR_ENABLED,SUPERVISOR_PROCESS_NAME,SUPERVISOR_GROUP_NAMEandSUPERVISOR_SERVER_URL. The URL names root's socket, which is mode 0700, soagentcan't use it.HOME=/home/agent,USER=agentandLOGNAME=agent.AGENTENV_EGRESS_PROXYis set. It isn't a proxy variable, so nothing reads it on an unarmed run.SSL_CERT_FILE,REQUESTS_CA_BUNDLEandNODE_EXTRA_CA_CERTSpoint at agent-env's bundles: the system roots,the image's CA and any provider bundle.
agent-env's trust files and every certifi bundle; the CA key is readable by the egress user alone. If the boot
fails, the container stops (
start-agentexits 2).main, 2 to 3 s later: supervisord stops the follower and theproxy first. The exit status is 0. supervisord 4.2.5 exits 0 after a signalled shutdown and has no setting to change
that.
main's container exited with the server's status, 137 when it was killed. Nothing in agent-env reads an agentcontainer's exit status.
agent'sprocesses are faked, and on an unarmed page they read real time.
entrypoint.shalone, as before.install/v1copies two more files into an install:agent_egress.pyandclockpage.py.Limits
so trajectories and judges see it.
proxy and no note, until the next turn. Claude Code and OpenCode have the same edge.
codex.js,#!/usr/bin/env node) isdynamically linked. So are the programs the CLI starts itself:
rgon arm64 (static on x86_64), the bundledzsh,git, bash. The launcher only starts the binary and passes on its arguments, environment and signals. 0.162.1still has a
[ghost_snapshot]config and skips "legacy"ghost_snapshotrollout lines. Whethercodex execstillmakes ghost commits, and whether anything prunes them on the env's clock, is checked in the VM run (git compares
real object mtimes with a virtual now). On the VM, with git installed by hand at 2262 and 1950, 0.162.1's
codex execwrote noghost_snapshotitems into its rollouts (4 turns each); the image has no git.PATHon each armed run:node, and the filemcp-remoteresolves to.In the image these are
/usr/local/bin/nodeand/opt/agent/node_modules/mcp-remote/dist/proxy.js.--headervalues, are onthe
codexcommand line. Any process can read that withps, including the model's commands. The same values arealready in mcp-remote's own command line and in config.toml, which
agentcan read, onmaintoo.shared proxy has them. A virtual date on 1950-01-01 itself could still fall before a leaf starts; the tests use
1950-06-15.
mainstill start a crashed server again in place. This PR changesCodex's alone.
clear, a turn has no note (the page is unarmed), so the model seesthe real date in
dateand<environment_context>, but earlier turns' notes, still in the thread, gave it thevirtual date. On the VM a model then answered
datewith the real date and "today" with the last note's date.<timezone>in<environment_context>reads the image's/etc/localtime(Etc/UTC), while itscurrent_datefollowsTZ: on an armed turn in America/Chicago the CLI saidcurrent_date2026-11-20 andtimezoneEtc/UTC at 00:05 UTC on 2026-11-21.clockpage.py setfor +1000 years fails with
struct.error), for every clocked image.tarfilein the real-timeserver, so header times are real.
Changes
codex_bridge.py:clock_followed()(the armed check),clock_overrides, andclock_note, applied in_run_codex_onceon such a run.run_codextakes the task's MCP registrations (name to URL and headers).codex_config.py:server_args, mcp-remote's arguments, which config.toml's entry and the armed overrides share.a2a_server.pypasses the task's MCP registrations.Dockerfile,root.conf(with theagent-exitlistener),start-agentandshared_sources.toml.install.shcarriesagent_egress.pyandclockpage.py. Codex's README describes theclock and the server's exit.
git diff origin/main -- src/agent_env/utils src/agent_env/computers packages src/agent_env/agents/agents/{claude-code,opencode}is empty). An earlier revision of this PR floored the sharedproxy's leaves at 1970, because rustls refuses earlier certificates. That was needed only while the real-time CLI
went through the proxy. The CLI now goes direct, so the change is reverted.
Tests
tst/unit/agents/codex/test_env_clock.py:nodeand mcp-remote laid out onPATHas in the image (a link throughnpm's
.binto a#!/usr/bin/env nodescript). The command the CLI is given must not be a#!script. Itsarguments must be mcp-remote's script followed by config.toml's arguments, and its environment must hold the
marker.
main;date;main's;Each of these mutations fails a test: starting mcp-remote by name again, dropping the command override, dropping the
script from the arguments, dropping the marker, dropping either half of the armed check, dropping the note, and the
server passing URLs without headers.
tst/unit/agents/codex/test_server_exit.pyreads root.conf as supervisord reads it. It checks that the server isnever started again, that the follower and the proxy restart, and that the listener hears
EXITEDandFATALandruns as root. It also runs the listener exactly as root.conf writes it, under a stand-in supervisord that speaks
its protocol. The listener must signal its parent on the server's exit and on its failed start, and not on the
follower's, the proxy's or its own. Each of 5 mutations fails a test: the filter inverted, the wrong program name,
FATALdropped,autorestartturned back on, and signalling itself instead of its parent.tst/unit/agents/test_agent_clock_images.pycovers codex: shared pieces, users, preload, the shared egress rule.tst/util/fake_responses.pyis a fake Responses API. The local agent clock e2e now runs a real Codex turn. Itchecks that the note and a shell
dateshow the virtual date and that<current_date>doesn't. It also checks, inthe image, that the env MCP server's mcp-remote Node process has
AGENTENV_REAL_TIME=0in its environment block:libfaketime rewrites the marker to that value in a process that received it, so this shows Node itself got the
marker.
Testing
Unit: the codex, agents, a2a_agent, utils and shipped-bundle tests pass, and ruff is clean. After the merge with
mainat 0.9.1611: all oftst/unit/agentspasses (1146 passed).Against the real Codex 0.162.1 CLI (darwin-arm64 build) through the bridge, with a stand-in Responses API, before
the change to how mcp-remote starts:
macOS has no libfaketime, so this run says nothing about how mcp-remote runs.
On an x86_64 VM (Ubuntu 24.04, Docker), the image built from this branch, models through LiteLLM:
tst/unit/agents, 1151 passed, noskips) and the local e2e (
test_agent_env_clock_local.py -k codex): note anddateon 2031-03-04,<current_date>the host's,mcp-remote on real time: [True, True](the env's server and the agent's ownpeer_agentsserver), the advance waited for, 504 naming the agent while paused, teardown drops the follower.1950-06-15, then with a 30-day jump, a clear and re-arm, a jump back to 1950 during a turn and rate 60x: every
turn completed, the last request held every earlier turn, each note gave the date
dateshowed, Node, Python andcurl reached https://example.com at every date (200), no lock, lease or cleanup error. +1000 years can't be
armed (see Limits).
ghost_snapshotitems at 2262 or 1950.main(0.9.1609 from PyPI, its published image) and this branch on the same prompts: the sameanswers (real
date, the env's MCP tool,get_timeabsent with no clock and the env's time with an unopted envclock, both turns remembered), no note, no overrides, no proxy variables in the CLI's environment.
date, Python, notes.txt andget_timeon 2027-02-01, thenote on every turn,
<current_date>the host's, ECHO=ping, curl and Node 200 through the proxy;main's imagewith
require_agent_clockfails atdeploy_agent: "agent 'solver' can't follow the clock of env ...:not_advertised".
*.w.modal.hostwith a certificate starting 2026-11-18 to 2026-11-20: armedat 2026-10-27, 2025-06-01 and 1950-06-15, ECHO=ping on each; each mcp-remote ran as
/usr/local/bin/node /opt/agent/node_modules/mcp-remote/dist/proxy.jswith the marker in its environment blockand no proxy variables.
gateway's state).
clocktool and JavaScript'sDatesaid 2026-11-21 (real), the model believedand answered 2027-02-01, as the note says.
date; sleep 10; date10 h apart) then frozen (equal); a 30-day advance, a re-arm back to2026-12-01 and a clear between turns (each turn's
dateright, every word kept);reset_env(the clock and theMCP tool survive); the follower killed -9 mid-turn (restarted, the next advance acknowledged in 0.02 s); the
model endpoint blocked 45 s mid-turn (the turn completed; same on
mainwith the clock off); 4 concurrentopted-in runs (all passed); the run SIGTERMed mid-turn (cancelled in 7 s, nothing left); the A2A server killed -9
mid-turn, then restarted in place (its CLI went on writing for 20 s; the step waited out its 300 s timeout on
Task not found, and the next turn ran on the restarted server). That is why the server's exit now ends thecontainer (below).
install/v1smoke.On the same VM, after the server's exit was made to end the container (merged with
mainat 0.9.1611). These runsused a stand-in Responses API and local Docker, because the VM no longer holds a model key:
-k codex) passed: thenote and
dateon 2031-03-04,mcp-remote on real time: [True, True], and teardown terminated the sandbox with nofailure.
2.4 s after with it off. It exited with status 0, and the image's supervisord log shows
exited: agent (terminated by SIGKILL),received SIGTERM, then the proxy, the follower and the listener stopped. The model's beat loopwrote 2 or 3 more lines before the container stopped and none after. prompt_agent failed the step 59.8 s after the
kill, both times, with
AgentUnreachableError("5 polls in a row over 60s got no reply"). For comparison,main'simage (0.9.1609 from PyPI), killed the same way on the same VM, failed it after 60.0 s with the same error. The
60 s is prompt_agent's own unreachable rule, so it isn't something the image can shorten.
agent_clockat 2027-02-01: two turns each passed, withdateon the real dateand on 2027-02-01.
stayed up, and both turns passed on 2027-02-01.
docker stopafter a turn took 3.3 s and exited 0. supervisord stopped the server (STOPPED, notEXITED, sothe listener stays out of it), then the proxy, the follower and the listener.
Claude, working with Edgar, finished this PR: the clock design, the VM runs, and the change that has the server's exit
end the container.
🤖 Generated with Claude Code


Confidence Score: 5/5
The PR appears safe to merge; no new actionable issue was found.Summary
Adds opt-in clock support to the Codex image while keeping the CLI and MCP connections on real time.
The earlier findings are addressed: provider certificates are merged before startup, the shared certificate-window change is absent, and the bridge reuses the shared clock helpers.
williamloo-scaleexplicitly documents the change to running asagenton Modal and the container’s zero exit status after shutdown as accepted limits. No new actionable issue was found. This review inspected code; it did not run tests.Diagram
%%{init: {'theme': 'neutral'}}%% flowchart TD Start["start-agent"] --> Supervisor["Root supervisord"] Supervisor --> Follower["Clock follower"] Supervisor --> Proxy["Egress proxy"] Supervisor --> Server["A2A server: real time"] Server --> CLI["Codex CLI: real time"] CLI --> MCP["Node / mcp-remote: real time"] CLI --> Commands["Model commands: task clock"] Commands --> Proxy Server --> Note["Task date added to armed prompts"] ServerExit["Server exits or fails to start"] --> Listener["agent-exit"] Listener --> Shutdown["Supervisord stops the container"]Reviews (15) · Last reviewed commit: "fix(codex): the A2A server's exit ends t..." · Reviewed by Greptile