Repository navigation
[FD-5916] feat(agents): the pi image follows the env's clock - #771
williamloo-scale wants to merge 63 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 pi 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 and hands it the model endpoint's URL and every MCP server's, so on an armed clock a host reached over HTTPS stays behind the proxy even when it's also reached over plain HTTP. The image copies agent_egress.py and clockpage.py beside the bridge; an install (install/v1), which unpacks the build context with them in agent_clock/ and clock/, puts those folders on the server's path. 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:
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 pi before this merges, if you'd like. |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…the env's clock pi compares its own clock with times it didn't make on the env's: before 1970 its compaction throws (it makes a UUIDv7 from Date.now(), which refuses a negative time, and every compaction and overflow recovery takes one), and its proper-lockfile locks compare its clock with their modification times. pi 1.1.0 shows the model no date of its own, so the bridge starts it with the real-time marker wherever the image runs the clock; libfaketime takes the marker out of pi's environment, so the model's commands still read the env's time. On an armed clock pi and its commands go out by the shared egress rule as before. The call site is now under test: a run through the agent's A2A route records how pi was started, armed and not, in a clocked image and as an installed agent; with the clock off its flags and environment are the server's plus the run's own variables and the marker. cli_env's keyword is armed, so it no longer shadows clock_armed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…m, and the image carries what the server imports install.sh, which the image and install/v1 both run, pins Node's archive by nodejs.org's sha256 for each architecture. A contract test checks every file the Dockerfile copies is in the build context, every module the server imports, its own and the shared ones, is copied beside it and importable from an unpacked install, and install.sh installs the pi version the bridge names. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…w pi follows the clock A plain docker build of the folder lacks what shared_sources.toml takes, so the README builds it with build_image, and install/v1 unpacks the build context rather than copying the folder. A new section covers the opt-in clock: the commands follow it, pi stays on real time and why, what the model sees of the date, the egress rule, and why the changelog needs no change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…arker reaches pi pi's bin is a #!/usr/bin/env node script. Run as it is, env is the process started with the marker: libfaketime keeps env on real time, takes the marker out of its environment, and env starts node, and with it pi, on the env's clock. The bridge now runs node /opt/pi/bin/pi, the same program with the same arguments the shebang gives it, where install.sh installs it for the image and install/v1 alike. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e, not on a PYTHONPATH start.sh exported PYTHONPATH for the folders the build context keeps the egress rule and the clock page's format in, and the server passes its environment to pi, so every command the model ran in an installed agent saw it, which main's didn't. install.sh copies the two modules beside the bridge when it runs from an unpacked build context, as the image's build does, and start.sh is main's again. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…arts it, stays on real time while its commands follow - The integration test's pi row starts node with the real-time marker, as the bridge starts pi, and checks that node prints real time, that the date it runs prints the env's time, and that its process.env has no marker. The module docstring no longer says every agent's CLI follows the clock. - A unit test pins the variables root.conf gives the server, which reach pi and the model's commands with the clock off too. - Both READMEs say pi starts as `node /opt/pi/bin/pi`. The agents README says pi's image can follow the clock with pi itself on real time. pi's README says its /proc environ shows the marker rewritten in place as =0, and that the changelog writes its tar in the real-time server. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Root's supervisord restarted a crashed server in place. The restarted server had lost what the run gave it (the env's MCP servers, its config, its peers, its running turns), the pi that was mid-turn ran on in a session of its own, and prompt_agent polled "Task not found" until its timeout. root.conf no longer restarts the server (autorestart=false, startretries=0), and an event listener stops supervisord once the server has exited or failed to start, so the container exits and the run fails as fast as on main. The follower and the egress proxy keep their restarts, and a normal stop is unchanged. supervisord exits 0 after any shutdown, so the container's status is 0, not the server's. 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: on libfaketime, a universe before 1970 breaks pi's compaction for good, because 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 pi image can follow a task env's clock, as the Claude Code and OpenCode images can (#726, #766, #818, #832). It
follows #832's contract: it's opt-in. The agent follows only when
sync_env_clocksetsagent_clock: true(
require_agent_clockimplies it). Otherwise pi and everything it runs keep real time.pi follows differently from Claude Code: pi itself stays on real time, and only the commands it runs for the model
follow the clock. pi can't safely follow the clock itself:
uuidv7()onDate.now(), and uuidv7 refuses a negative time. Everyauto-compaction and every overflow recovery takes that path, so the conversation overflows for good (FD-6434).
pi 1.5.2 and 1.6.0 have the same code, so upgrading doesn't help.
pi 1.1.0 shows the model no date of its own (upstream dropped the date from its prompt), so keeping pi on real time
hides nothing from the model.
How it works
Image. The clock library, the egress proxy and the shared egress rule come from
utils/faketime_clock,utils/egress_proxyandutils/agent_clockthroughshared_sources.toml. The container starts as root:start-agentmakes the clock page and the proxy's CA, then root's supervisord (root.conf) runs:agent, with the real-time markerAGENTENV_REAL_TIME=1.exits).
libfaketime and the TLS shim are preloaded into every process and fake only
agent's.pi on real time. Wherever the image runs the clock (the server's environment names
AGENTENV_EGRESS_PROXY), thebridge starts pi with the marker (
cli_env), armed or not, as a clock may arm mid-turn. libfaketime keeps pi on realtime and takes the marker out of
environ, so everybash -cpi starts reads the env's time. libfaketime rewritesthe marker string in place, so pi's
/proc/<pid>/environshowsAGENTENV_REAL_TIME=0; what pi starts has no markerat all.
node /opt/pi/bin/pi. The bridge starts node itself (PI_COMMAND), with the same program and arguments thescript's
#!/usr/bin/env nodegives node. Run through the shebang,envwould be the process that gets the marker:it would scrub it and start node faked.
Egress. On an armed clock, pi and its commands go out by the shared rule (
agent_egress.egress_env): every TLShost goes through the egress proxy, except:
host.docker.internal;NO_PROXYnames;pi honours
HTTP_PROXY,HTTPS_PROXYandNO_PROXYitself (undici'sEnvHttpProxyAgent), for its model and MCPcalls alike. On real time, pi doesn't need the proxy. But its commands inherit its environment, so it carries the
proxy variables and goes through the proxy too. Where the proxy re-signs a certificate, pi trusts the image's CA
through
NODE_EXTRA_CA_CERTS. Node programs the model runs honour the variables throughNODE_USE_ENV_PROXY, whichNode honours from 22.21, so Node goes to 22.23.3.
install/v1. The build context it unpacks keeps the shared modules in their folders, and
install.shcopies thembeside the bridge, as the image's build does. An installed agent doesn't follow the clock: the target runs neither
the follower nor libfaketime, and the bridge then adds neither the marker nor proxy variables.
No change to shared code.
utils/faketime_clock,utils/egress_proxy,utils/agent_clockand the protocolpackage are taken as they are. The diff touches pi's folder, the agents README and tests.
What the model sees, opted in
The env's time:
date,datetime.now(), and the timestamps its programs write into files;get_time, in the env's time and zone.pi adds no date or time line to the prompt, and its own file tools (
read,ls,find,grep) print no dates.What isn't the env's time:
statorutime, sols -lshows real times),psstart times and/proc/uptime.model. The model would see them only by reading
~/.pi-a2a/sessionsitself.Dateheader, are real time, as for every clocked agent.Clock off: what is the same and what differs
For the model and the harness:
=1, and the commands never see it.pi's and the commands' environment still differs from main's, because the image changed the server's environment (see
Environment below).
At the image level, these differ from main even with the clock off:
CMD start-agent, noUSER) under root's supervisord, which runs thefollower (
agentenv-clock), the egress proxy (agentenv-egress) and the server asagent. Started as another user,the image runs the server alone, as before.
USER(checkedon the VM: main's pi ran as uid 0 with
HOME=/root, this image's asagent). There, pi and the model's commands now run asagent, withHOME=/home/agent, so pi'sstate moves out of root's home, and commands that need root, such as
apt-get, now fail.agentis uid 1001: pi'sDockerfile picks no uid and the base's
ubuntuuser holds 1000. Unlike the other clocked images, which pin 10001,this is unchanged from main. On local Docker and other providers that apply
USER, main already ran pi asagent.trust files and every certifi bundle. A provider's own CA bundle (Sail's, say) is merged into agent-env's bundles and
the proxy's roots. A failed boot stops the container (exit 2).
reason, so the run fails fast (see When the server exits below). What differs is the status: the container exits
0, where main's exited with the server's own (137 when killed). supervisord 4.2.5 exits 0 after every shutdown, and
it has no setting to change that.
time.
USER=agentandLOGNAME=agent(root.conf);SUPERVISOR_ENABLED=1,SUPERVISOR_SERVER_URL(root's 0700 socket, whichagentcan't use),SUPERVISOR_PROCESS_NAME=agentandSUPERVISOR_GROUP_NAME=agent;NODE_EXTRA_CA_CERTS,SSL_CERT_FILEandREQUESTS_CA_BUNDLE, pointing at agent-env's bundles. On localDocker, main's container already had these three, with the same values, from the local provider; on Modal, main's
had none;
AGENTENV_EGRESS_PROXY.python3is first on the commands'PATH, also hassupervisor4.2.5 andsetuptools<81.own log there too, so
docker logsshows a server's exit and the shutdown that follows. That log, and the clock andproxy logs, are also in
/var/log/agentenv-root, which only root can read.node /opt/pi/bin/pirather than through its shebang.When the server exits
On main, the A2A server was the container's process, so when it died the container exited and the run failed fast.
Here, root's supervisord is the container's process. If it restarted the server in place, the restarted server would
have lost what it holds in memory: the env's MCP servers, its config, its peers and the turns it's running. Later turns
would then run without the env's tools, and
prompt_agentwould pollTask not founduntil its timeout. Also, the pithat was mid-turn would keep running and writing, because the bridge starts it in a session of its own.
So supervisord brings the whole container down with the server, and does it alone (
root.conf):autorestart=falseandstartretries=0on[program:agent].[eventlistener:agent-exit], runs as root. It is an inline Python loop that speakssupervisord's
READY/RESULTprotocol. It hearsPROCESS_STATE_EXITEDandPROCESS_STATE_FATAL, and when theprocess is
agent, it sends SIGTERM to its parent, supervisord. supervisord then stops the follower and the proxy,and exits.
STOPPEDand not asEXITED, so the listener stays quiet.Claude Code's and OpenCode's images, already on main, still restart their server in place. They need the same change.
This PR leaves shared and other agents' files alone.
Question for reviewers: should a failed egress boot stop an agent whose clock is off? All three clocked images do
today. I recommend failing fast for now: a half-done boot can leave the trust files that the server's CA variables
point at inconsistent, which breaks TLS even with the clock off. If we want resilience when the clock is off, we should
change all three images together in a follow-up: a failed boot would run the server without the clock, and
sync_timewould report why.History and working state (FD-6434)
Audit of pi 1.1.0, against FD-6434 and the #831 class:
uuidv7())Date.now()with lock mtimes; a jump forward marks a held lock compromised--session-idfinds the session by its header's idcreateSessionIdPI_OFFLINE=1,--session-idalways passed)tarfile(notarprocess)Known edges
the proxy variables until the next turn. The other clocked agents behave the same way.
NO_PROXYmatches by host: a host reached over both plain HTTP and TLS stays behind the proxy, as the sharedrule does for every clocked agent.
upstream address it found unreachable for a minute (
ProbeFailedTTL) and refuses new connections to it meanwhile,without dialing. On the VM, with the endpoint blocked for 40 s mid-turn, pi's retries (2, 4 and 8 s) ran out on both
sides. On this branch, pi's next turn, sent 15 s after the endpoint came back, failed too. Main's pi, going direct,
recovered at once. main's Claude Code image's proxy does the same, and Claude Code's longer retries ride it out. The
fix belongs in the shared proxy, outside this PR.
2262-04-11. Set later, the follower crash-loops (
struct.error) andsync_env_clockreports that the agent can'tfollow. Every clocked image shares this (main's Claude Code image does the same). pi follows at 2262-01-01.
Review findings addressed
pi_agent.py'scli_env(...)call is tested through the A2A route with the fake CLI, which recordsthe agent-env, pi and proxy variables. Mutation-checked: each of these fails tests:
**os.environinstead ofcli_env;armed=False;clocks would have failed the 1950 case instead of surviving it.
build_image, ora2a-agent put);node /opt/pi/bin/pi.node,with the marker) prints real time, while the
dateit runs prints the env's time and itsprocess.envhas nomarker. The module docstring no longer says every CLI follows the clock.
PYTHONPATHconstant is gone;armed;install.shchecks Node's checksum;root.confandstart-agent;start.shno longer exports aPYTHONPATHthat reached the model's commands in installed agents.Testing
Unit tests (run on macOS; the skipped tests are other agents' Linux-only tests; on the Linux VM,
tst/unit/agents,the shipped-bundle and docker-context checks: 1395 passed, none skipped):
tst/unit/agents/pi,test_agent_clock_images.py,test_agent_egress.py: 125 passed.tst/unit/agents, the shipped-bundle, release-pin, infra-image, runtime-dependency and docker-context checks: 1446passed, 46 skipped.
tst/unit/agents/pi:test_root_conf.pypins the crash behaviour: the server is never restarted (autorestart=false,startretries=0), while the follower and the proxy are. A single root listener hearsEXITEDandFATAL. The testalso runs the listener's own code against a stand-in supervisord, which shows that it stops its parent on the
server's exit or failure to start, and on nothing else. Mutation-checked: the test fails if the listener matches
another program, signals itself, or answers
FAIL, or ifstartretriesis raised;test_image_contract.pychecks that the image and an install carry every module the server imports, and thatNode is pinned by checksum;
test_env_clock.pycovers the call site, clock-off parity, and the variables root.conf gives the server. Thatlast one fails when a variable is added or dropped.
ruff check: clean.Local checks against pi 1.1.0 with a stand-in OpenAI endpoint (no key):
NO_PROXYfor model and MCP calls;node /opt/pi/bin/piruns pi as the shebang does.On a VM (Ubuntu 24.04, Docker, local sandboxes unless noted; real model
anthropic/claude-haiku-4-5; A/B againstmain 0.9.1609 from PyPI, whose pi is
ghcr.io/scaleapi/agentenv-pi@sha256:b5af60d8…; this branch's image built fromits context, sources
sha256:4e422beb…):test_agent_env_clock_local.py -k pi)dateit runs prints the env's, and the marker is scrubbed from itsprocess.envagent_clock, A/BCONTEXT_DATE: NOT_GIVEN, MCP works,get_timeunavailable unarmed and the env's when armed, no proxy variables, uid 1001. The model's commands see onlyAGENTENV_EGRESS_PROXY,USER,LOGNAMEand the fourSUPERVISOR_*addedget_timeshow 2027-02-01.lsshows the real mtime, and pi's session header is real. pi's/proc/<pid>/environshowsAGENTENV_REAL_TIME=0and the proxy variables, and its commands have no marker. The model endpoint goes through the proxy. Main's pi, opted in, stays on real time*.w.modal.host(cert from 2026-11-18/20), armed at 2026-10-27, at 2025-06-01 and at 2262-01-01curlandnodefetchof example.com get 200require_agent_clockrequire_agent_clockfails the step clearly (can't follow ... not_advertised)get_time, asagent(uid 1001,HOME=/home/agent). Main's pi there runs as root (uid 0,HOME=/root)Auto-compaction failed: UUIDv7 timestamp must be ..., then turn 4 is refused as over the window. +1000 y can't be set (see Clock range)kill -9of the follower, a backward re-arm,reset_env,clear(each turn's shell date was the clock's then; main's pi kept real time through all of it); an advance, freeze and thaw during asleep 30(the seconddateshows the jump, history kept); SIGTERM to the run mid-turn on both sides (cancelled, everything torn down); 4 opted-in runs at once with two contexts each on one agent. Endpoint blocked for 40 s mid-turn: see Known edges. Server killed mid-turn: see the next tableOn the VM, after the crash-behaviour change (this branch merged with main at 64afced. The image was built from
its context and run on local Docker, against a stand-in OpenAI endpoint with no key, so this round cost nothing):
kill -9mid-turn, 12 s into asleep 40tool call, twice.psjust before the kill shows pi and itsbash -c ... sleep 40exited: agent (terminated by SIGKILL), and then, one second later,received SIGTERM.prompt_agentreportedAgentUnreachableError60.1 s after the kill, both times. Main took about 58 s: the time isprompt_agent's own policy (5 polls in a row over 60 s). Nothing ran on after the kill: no request reached the model, and no pi was left anywhere. The next turn failed atagent-config, as on main. Before this change, the killed turn ran to its 600 s timeout.kill -9'd, an advance to 2027-02-11, and another turndocker run, no agent-env)kill -9of the server: the container exited 2.1 s later, with status 0.kill -9of the follower, then of the egress proxy: each restarted, and the container stayed up.docker stop: 1.2 s, status 0; the server shut down on SIGTERM and supervisord logged it asstopped. A server that can't start (its script renamed):FATALat once, no restart, and the container exited, with status 0.Claude, working with Edgar, finished this PR.
🤖 Generated with Claude Code


Confidence Score: 5/5
The PR appears safe to merge; no new actionable issues were found.Summary
The pi image can now follow the env’s clock when opted in. Pi stays on real time; commands it starts follow the env’s time.
Diagram
%%{init: {'theme': 'neutral'}}%% flowchart TD Start["start-agent as root"] --> Setup["Create clock page and prepare trust"] Setup --> Supervisor["supervisord"] Supervisor --> Follower["Clock follower on real time"] Supervisor --> Proxy["Egress proxy on real time"] Supervisor --> Server["A2A server on real time"] Server --> Pi["Node runs pi with real-time marker"] Pi --> Commands["Commands follow the armed clock"] Server --> Exit["Server exits or fails to start"] Exit --> Listener["Listener stops supervisord"] Listener --> Stop["Container stops"]Reviews (12) · Last reviewed commit: "fix(agents): the pi container exits when..." · Reviewed by Greptile