Repository navigation
[FD-5916] feat(agents): the Hermes image follows the env's clock - #768
williamloo-scale wants to merge 62 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>
# 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 Hermes specifically: plain-HTTP MCP hosts go direct, but a host also reached over HTTPS would then bypass the proxy too. The shared rule handles that case. 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_egress, which the image copies beside it with clockpage, and hands it the model endpoint's URL and every MCP server's: a host also reached over HTTPS now stays behind the proxy. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
|
Thanks, done. I merged |
|
Claude again, working with Edgar. I checked the update, and the migration onto the shared rule looks right:
Hermes reaches MCP from Python, whose HTTP clients honour the proxy variables, so the shared rule should carry through. One thing hasn't been done yet: a run with an armed clock against an env on Modal, whose certificate starts after the virtual date. That's the case #818 was about. I'm happy to run it for Hermes before this merges, if you'd like. |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ommands it runs follow it Hermes compares its own clock with times it didn't make on that clock in many places: its scratch folder (TMPDIR) is pruned at each start of entries idle for 24 h, and the processes running in them; terminal spills and large tool results are deleted past 7 days and sessions.retention_days; checkpoints past their retention; the turn lease stops a turn the clock jumps past or runs fast through; the stream stall check drops a stream the clock jumps past. On an env clock ahead of real time these delete a conversation's files or end its turns. On an armed clock the bridge now starts Hermes as the command its launcher runs, Hermes' own Python, with AGENTENV_REAL_TIME=1, rather than through the launcher's shell, which would take the marker. Hermes and everything it does in-process stay on real time; every command it starts (the model's shell, execute_code scripts, git) follows the env's clock. With --env-clock the plugin has Hermes read the date it shows the model (hermes_time.now) and the session id's stamp, which the "Conversation started" line reads, from a `date` it runs. The turn's config names the egress proxy's and its CA's variables in terminal.env_passthrough, as execute_code hands its scripts only a fixed few. Unarmed, the command, environment and config are main's. The Dockerfile reads the pinned release's launcher at build, so a Hermes bump that changes it fails the build rather than an armed turn; the plugin names the release whose names it replaces, which a test holds to the Dockerfile's HERMES_COMMIT. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…and reads its launcher at build Hermes had no image contract test: every file the Dockerfile copies is in the build context, every module the A2A server imports (the folder's own and the shared egress rule and clock page format) is copied into /opt/agent beside it, with the plugin, and the build reads the pinned launcher. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nAI-compatible stand-in The Hermes row had no turn: Hermes calls chat completions, which the Anthropic stand-in doesn't serve. Each agent now names the stand-in its CLI speaks. Hermes' turn checks the date line it sends the model and a terminal `date` are the env's, its session id carries the env's date, and its session store records a real-time start, so Hermes itself ran on real time. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The Hermes README gets a section on the clock: off by default, what opting in changes, why Hermes stays on real time, the date the model sees and its limits; the image paragraph says it starts as root under supervisord. The agents README names Hermes among the clocked agents. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s every session id and passes the zone to execute_code - launcher_command takes only `exec <python> -I -c <bootstrap> "$@"`: Hermes' forwarder to another launcher, or an `exec env ...`, would hand the real-time marker to sh or env, Hermes would follow the env's clock again, and the build's launcher check would still pass. - --env-clock replaces every binding of new_session_id a loaded module made by import, not only agent_init's: conversation_compression binds it as mint_session_id for a compaction's child session. - On an armed clock, terminal.env_passthrough names TZ too: execute_code scrubs TZ and sets it only from Hermes' own timezone setting, so its scripts saw UTC while the terminal showed the task's zone. - The README says what a clock armed mid-turn does: that turn's Hermes was started unarmed, through the launcher, so it jumps with the clock and its lease or stall check may stop it; the next turn is armed. It also names the variables supervisord adds to the server's environment. - The unarmed test pins the whole profile config, and a test pins that the clock adds only the passthrough. The fake launcher is written in the installer's shape. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Supervisord restarts a Hermes A2A server that dies, and the turns it was running, in sessions of their own, went on after the restart: on the VM a turn kept running its tool, wrote the workspace and the session store, and only then exited, ~45 s after the new server was up. As it starts, the server now kills each such turn and what it started, known by the event pipe's variable and a home under the profiles (kill_orphaned_clis). The README also says what a turn running when the clock is armed meets: its model calls check certificates on the env's clock, since Hermes' Python carries its own OpenSSL, which the TLS shim doesn't reach. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Main's Hermes usage counting (#855) turns the profile's background review off, which the unarmed config pin now names; the README keeps main's usage paragraph with the image's supervisord paragraph. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e the clock On main the A2A server was the container's process, so a server that died took the container down and the run failed at once. Under root's supervisord it was restarted in place without its turns, registrations or the A2A task it was running: the caller polled "Task not found" until its timeout, and the context's next turn started a fresh Hermes session. Now supervisord doesn't restart the server (autorestart=false, startretries=0), and an event listener in root.conf stops supervisord when the server is EXITED or FATAL; supervisord then stops the follower and the proxy and exits, and the container with it. The follower and the proxy still restart in place, and a normal stop exits 0 as before. supervisord 4.2.5 exits 0 after any shutdown, so a crashed server's container exits 0; supervisord's log line says why. The startup sweep for turns a dead server left (kill_orphaned_clis) goes 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: Hermes on libfaketime compares its own clock with real file times and timers in about nine places: the scratch prune, output spill cleanup, the turn lease, the stream stall detector, and others. With the clock a day or more ahead, or jumping mid-turn, it deleted its own working files and killed turns. The version on this branch kept Hermes on real time and only put the model's commands on the clock, so advertising 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 Hermes image can follow a task env's clock, opt-in, as Claude Code and OpenCode do since #818 and #832. A task that
sets
agent_clock: trueonsync_env_clock(require_agent_clockimplies it) gets Hermes with every command it runs onthe env's time and the env's date in its prompt. Without it, a turn runs as on
main(the image-level differences arelisted below).
Unlike Claude Code, Hermes itself stays on real time and only the commands it runs follow the env's clock. Hermes
compares its own clock with real file times or real elapsed time in many places inside its own process, and several of
them have no setting to turn them off. On a clock ahead of real time, those places delete a conversation's files or end
its turns (list under R4). On real time they behave as they always do. Hermes still shows the model the env's date.
Clock off (default)
What's the same for the model and for Hermes. A turn is
hermes agentenv turnwith the same flags, started throughHermes' launcher. It gets the server's environment with only
HERMES_HOMEand the event pipe added, and a profileconfig.yamlwith nothing of the clock in it. It runs on real time with no proxy variables.test_unarmed_the_bridge_starts_hermes_with_the_command_and_environment_it_always_haspins the command, the environmentand the whole config dict.
test_the_clock_adds_only_execute_codes_passthrough_to_the_profile_configpins that an armedturn's config differs only by
terminal.env_passthrough.What differs at the image level, even with the clock off:
start-agent, then supervisord (root.conf). Supervisord runs theclock follower and the egress proxy, each as its own system user, and the A2A server, and so Hermes, as
agent(uid 10001). Started as any other user, the image runs
entrypoint.shalone as that user, as before.mainthe server and Hermes ran as root there. Now they run asuid 10001 there too.
/dataand/appbelong toagent, as before.main'sdoesn't:
SUPERVISOR_ENABLED,SUPERVISOR_PROCESS_NAME,SUPERVISOR_GROUP_NAMEandSUPERVISOR_SERVER_URL.The socket it names is root's, mode 0700, so
agentcan't use it.USER=agent,LOGNAME=agentandAGENTENV_EGRESS_PROXY=http://127.0.0.1:3128.SSL_CERT_FILE,REQUESTS_CA_BUNDLEandNODE_EXTRA_CA_CERTS, pointing at agent-env's bundles: the system roots,the egress proxy's CA and any bundle the provider set (
start-agentmerges it in, for Sail for one).HOME=/data, as the image already set it.AGENTENV_REAL_TIME=1is set on the server, but libfaketime takes it outof the server's environment, so nothing the server starts sees it.
stderr). The boot mints a CA, its key the egress user's alone. It adds the CA to the system trust store
(
update-ca-certificates), to agent-env's bundles and to every certifi bundle under/usr/lib/python3,/usr/local/liband/opt. A failed certifi bundle is reported as a warning, not a failure. Start-up takes longerby the boot's time: on the VM,
docker runto the agent card served took 2.6 s againstmain's 0.7 s (threeruns each). The image is 735.5 MB against
main's 730.9 MB./etc/ld.so.preload) into every process. They fake onlyagent'sprocesses, and while the clock is unarmed the clock page holds real time.
main. Onmainthe server was the container's process, so aserver that died took the container down and the run failed. Under supervisord it would be restarted in place,
without its turns, its registrations (the env's MCP servers, the config, peers) or the A2A task it was running, so
later turns would run without the env's tools while the dead server's turn went on in a session of its own. So
supervisord doesn't restart it (
autorestart=false,startretries=0, so one that dies as it starts is FATAL atonce), and an event listener in
root.conf([eventlistener:agent-exit], a few lines of Python speakingsupervisord's listener protocol) stops supervisord when the server is EXITED or FATAL, whatever the reason.
Supervisord then stops the follower and the proxy and exits, and so does the container. Everything in it goes too,
so the turn the server was running writes nothing more.
autorestart=true. Killed with -9, each restarts in place and the container staysup.
it pass, and the container exits 0.
after any shutdown and has no setting to change that. On
main,kill -9gave 137. The cause is in thecontainer's output, in supervisord's log:
exited: agent (terminated by SIGKILL; not expected), thenreceived SIGTERM indicating exit request.(
kill_orphaned_clis). That's gone: with no restart, nothing produces that case.Opted in
Hermes runs on real time. The bridge starts each turn with the command Hermes' launcher runs: Hermes' own Python
with
-I -c <bootstrap>, plusAGENTENV_REAL_TIME=1(hermes_bridge.cli_command). It skips the launcher because thelauncher is a
#!/bin/shscript, andshwould take the marker in Hermes' place. libfaketime takes the marker outof Hermes' environment, so everything Hermes starts follows the env's clock: the model's shell commands,
execute_codescripts, git.launcher_commandreads only the installer's shape,exec <python> -I -c <bootstrap> "$@". It refuses any otherexec, such as Hermes' forwarder to another launcher,exec env ..., or a missing-I, becauseshorenvwould take the marker there.
build rather than a turn.
prepare_launchreturns early because the image removes/opt/hermes/.git,and subagents run as threads.
What the model sees about "now" (R2): its commands'
date, the dates its commands write into files, git commitdates,
execute_code's time and zone, andget_time(from the gateway) are all the env's. With--env-clock, theplugin has Hermes read the dates it shows from a
datechild process:Conversation started:line, andToday's dateafter a rebuild;the stamp, the lineage root's first.
It replaces two Hermes names for this. One is
hermes_time.datetime, whichhermes_time.now()reads. The other ishermes_state_ids.new_session_id, along with every copy a module that has already loaded bound by import(
agent.agent_init'snew_session_idandagent.conversation_compression'smint_session_idat the pinnedrelease). A module that loads later binds the replacement.
date +%sis used because%Nnext to a negative%sisa second off before 1970. A test holds the release these names were checked against to the Dockerfile's
HERMES_COMMIT.What stays real:
started_atand the trajectory events'timestamps;stat);session_searchlistings.Network (R3): the shared rule,
agent_egress.egress_env(environ, [model_url, *mcp_urls], armed=...), is appliedto Hermes' environment. Every TLS host goes through the egress proxy, Hermes' own model and MCP calls included. The
proxy checks certificates on real time, so it covers an HTTPS MCP server on
*.modal.hostwhose certificate startsafter the env's date, and a clock behind real time. Loopback, the hosts the deploy's
NO_PROXYnames and hostsreached only over plain HTTP go direct.
Hermes trusts the proxy's CA through
SSL_CERT_FILE, and its terminal's commands inherit the same variables.execute_codegives its scripts an allowlisted environment, and setsTZonly from Hermes' owntimezonesetting. So on an armed clock only, the turn's config names the proxy's variables, the CA's and
TZinterminal.env_passthrough. Scripts then reach TLS hosts through the proxy and read the time in the task's zone,as the terminal does.
Why Hermes stays on real time (R4)
Each of these runs inside Hermes' process against real file times or real elapsed time (Hermes at
bf0203a):hermes_constants.py:1011andhermes_constants_scratch.py:373: at every start, prune scratch (TMPDIR) entriesidle for 24 h and kill the processes rooted in them. Ahead of real time, this deletes earlier turns' temp files and
execute_codestaging folders.tools/environments/base_output.py:187: terminal spill files, 7 days.tools/environments/local.py:70: the terminal's temp cache.tools/tool_result_storage.py:139/223: large tool-result spillover, bysessions.retention_days. With the clockmore than 90 days ahead, a result is pruned right after it's written.
tools/checkpoint_maintenance.py:209: checkpoint retention.tools/process_registry_results.py:32: background-process results, 7 days.agent/turn_facade_lease.py:219: the turn lease stops a turn when the clock jumps more than about 240 s or runsabout 5x fast.
agent/chat_completion_stream_monitor.py:135: the stall check drops a stream that a forward jump lands in.Running Hermes on real time fixes all of them at once. The call-site tests pin it: a mutation that drops the marker,
the direct launch or
--env-clockfails them.Shared code (R5)
utils/egress_proxy,utils/faketime_clock,utils/agent_clock,tst/util/fake_openai.py, and the Claude Code andOpenCode folders are untouched. The image takes the first three through
shared_sources.toml.Workspace snapshot (R7)
Hermes has no workspace changelog. The context snapshot archives the profile with Python's
tarfilein the server,on real time. The workspace's
taris the server's child, so it follows the env's clock when armed. It writes a fullarchive, so its contents don't depend on the clock. A clock behind the files' real modification times only adds GNU
tar's "time stamp in the future" warnings on extract. C6 checks the exit status.
Known limits
through the launcher with no marker. So its Hermes follows the env's clock from then on, without the proxy. Its own
model and MCP calls then check certificates on the env's clock, because Hermes' Python (python-build-standalone)
carries its own OpenSSL, which agent-env's TLS shim doesn't reach. At a date outside the endpoint's certificate they
fail with
APIConnectionError: Connection error.On the VM (C5), a clock armed at 2029-08-01 12 s into a turn endedthat turn with this error after Hermes' 3 retries. Its turn lease or stall check may stop it too, with
Session turn lease ...or a dropped stream. The conversation keeps its history, and the next turn is armed. Startingunarmed turns on real time too would keep Hermes itself on real time, but it would change the unarmed command and
still leave that turn's commands without the proxy.
as it does on any clock. Such a session keeps its real start date until Hermes rebuilds its prompt.
hermes_timeandhermes_state_idsat module top, on unarmed turns too, so a release that renames either would failevery turn loudly, not only armed ones, until the plugin follows.
Tests
tst/unit/agents/hermes/test_env_clock.pyandtest_image_contract.py(35 cases in 21 tests):-m, Hermes' forwarder,exec env, no-I,an extra argument);
execute_code's passthrough with and without a task zone;agent.agent_initandagent.conversation_compressionloaded under their own names fornew_session_id;start-agent's provider-bundle merge;-Iunchecked,bootstrap dropped,
TZnot passed,TZalways named, passthrough unarmed, session-id switch narrowed toagent_init, switch by name only, date switch dropped, switch without the flag, unarmed via the launcher's command,armed without
--env-clock, armed without the marker).test_image_contract.py:root.confread as supervisord reads it: the server hasautorestart=falseandstartretries=0, the followerand the proxy
autorestart=true, and the listener takesPROCESS_STATE_EXITEDandPROCESS_STATE_FATALand runsas root.
RESULT 2 OKand lets the follower's and the proxy's exits pass. It sends its parent SIGTERM when the server isEXITED, or FATAL after it dies while starting.
their default, no FATAL, and the follower not restarted.
tst/unit/agents. On Linux (the VM), 101 passed intst/unit/agents/hermesandtest_agent_clock_images.py.ruff check .is clean.test_agent_env_clock_local.pypasses all three rows on the VM: Hermes over this image, andClaude Code and OpenCode over
main's published images. The Hermes row gave the date lineTuesday, March 04, 2031, terminaldate2031-03-04T05:06:07Zand session id20310304_050607_…, and the sessionstore's
started_atwas real now.unarmed, real, +75 d, +200 y, 1950, jumps between turns (real, +75 d, +200 y, 1950), and +1000 days, rate 10 and
1950 during turns. Each one kept turns 1-3 in turn 4's call and read turn 1's scratch file back in turn 4. The
terminal dates and the date line were the env's, and armed turns' Hermes had
AGENTENV_REAL_TIME=0and the proxy.main's image passes the unarmed scenario. +1000 y is past the clock page's range (int64 ns: 2262-04-11) for everyagent, so +200 y stands in. Control, the PR's earlier head
6961dff10(Hermes itself on the env's clock): at+75 d, turn 1's scratch file was pruned by turn 4, and the 1950 move during a turn failed it with
system time before Unix epoch.claude-haiku-4-5; local Docker unless noted). All pass:mainand this branch gave the same answers (shell date real,get_time2027, date line real). Therewas no marker or proxy in Hermes' environment and no follower.
mainran its published image by digest; thisbranch ran its own build.
America/Chicago:dateMon Feb 1 06:00:13 CST 2027, the git commit2027-02-01T06:00:15-06:00, the file's contents, andexecute_code2027-02-01 06:00:17 CSTand HTTPS 200.get_timegave 2027-02-01 and the date lineMonday, February 01, 2027 (CST, UTC-06:00).*.modal.hostat 2026-10-27 (before the certificate), 2025-06-01 and 1950. TheMCP calls, terminal
curlandexecute_codeHTTPS all worked. The proxy re-signed*.modal.hostand theendpoint (
decision: outside).openai/gpt-5.4-minion E2's prompt gave the same results.agent deployed later followed.
require_agent_clockpasses here and fails clearly againstmain's Hermes(
not_advertised).reset_envandclear, acrossfive turns of one conversation;
mainand this branch;APIConnectionError(see Known limits), the next turn was armed and thehistory kept;
main, with this branch's image rebuilt, a stand-in model and localDocker:
kill -910 s into a turn that sleeps 45 s.after the kill, the file the turn writes once its sleep ends didn't exist, so nothing kept writing.
main's image (docker kill, since its server is PID 1): exit 137 at once, and no file either.agent-env run, with the clock armed and opted in:prompt_agentfailed the step 59.7 s after the kill withAgentUnreachableError: ... 5 polls in a row over 60s got no reply. The same task onmainfailed 59.5 s after the kill, with the same error.main's 203 s. Before this change, the step polledTask not founduntilits 300 s timeout, and the next turn ran in a fresh Hermes session without the env's tools.
agent-env run, all verifiers passing:datewas real (2026-11-21);completed.
agent-env run, between two opted-in turns: both restarted and the container stayed up. A clock advanceto 2027-02-11, with
wait_followers_s, then reached the restarted follower. The next turn'sdatewas2027-02-11, and the verifiers passed.
docker stop:main: 0.4 s);main: 5.5 s). That's uvicorn's 5 s graceful shutdown, then the server killsthe turn as it stops.
stopped: agent, and the listener didn't fire.conversation_compressionisunit-tested only); C6, a snapshot round trip. On the env's clock, the workspace
tarcreated at +200 y and extractedat 1950 with exit 0 and only
time stamp … in the futurewarnings.claude-haiku-4-5but onegpt-5.4-miniturn.Also in this push:
mainmerged in. #855's usage counting turns off the profile's background review, which theunarmed config pin now includes.
Claude, working with Edgar, finished this PR: the merge with
main, the crash behaviour and its VM re-test.🤖 Generated with Claude Code


Confidence Score: 5/5
The PR appears safe to merge, with no new actionable issues found.Summary
Adds opt-in clock support to Hermes while keeping Hermes itself on real time.
williamloo-scaledocuments these accepted limits: arming the clock during a turn can fail that turn, existing sessions retain their original date until a prompt rebuild, and a server crash stops the container with exit status 0.Diagram
%%{init: {'theme': 'neutral'}}%% flowchart LR S["A2A server: real time"] --> H["Hermes: real time"] H --> D["Prompt dates: task clock"] H --> C["Commands: task clock"] H --> P["TLS proxy: real time"] C --> P F["Clock follower"] --> CReviews (11) · Last reviewed commit: "fix(agents): a Hermes server that exits ..." · Reviewed by Greptile