Repository navigation
[FD-5916] feat(agents): the Letta Code image follows the env's clock - #769
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>
…-image # 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 Letta Code specifically: 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/agent_egress and hands it every MCP server's URL, so an HTTPS MCP host goes through the egress proxy on an armed clock (its certificate is checked on real time); loopback, the model relay's among it, and plain-HTTP hosts stay direct. The image and install.sh copy agent_egress.py and clockpage.py beside it. 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:
Letta Code's MCP client is Node or Bun. It's worth confirming end to end that it honours 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 Letta Code before this merges, if you'd like. |
…-image Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…on real time The changelog's tar is a child of the A2A server, which runs on real time, but libfaketime takes the real-time marker out of the server's environment, so tar read the env's clock. Its dump time went into the snapshot file, and on a clock ahead of real time the next increment missed every file changed after it, since file times stay real. Both incremental tars now run with AGENTENV_REAL_TIME=1. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…, its default-off equality and its image contract - every letta command of a turn carries the egress variables on an armed clock, with the env's HTTPS MCP host behind the proxy and loopback and plain-HTTP hosts direct; - unarmed, a turn runs main's commands with main's environment; - the changelog's incremental tars run on real time; - the image and an install carry every module the server imports, the egress rule and the clock page's format among them, and the MCP mod the bridge installs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s clock and what still reads it against other times The image starts as root and runs the server as the agent's user; the whole CLI follows the clock once a task opts in, its environment context's "Local time" line included, while the server, its model relay and its records stay on real time; MCP over TLS goes through the egress proxy and the changelog's tar runs on real time. The edge cases that remain are listed. root.conf and start-agent lose a ticket id. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…-image Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…'s file names are pinned, and the README names the lock and listing edges - The local clock e2e gives letta-code a turn against the OpenAI chat-completions stub: the CLI's Local time line and the model's Bash date show the env's date, and its model calls reach the loopback relay with the proxy variables set. - The image contract test runs install.sh's copy loop and checks every file lands in app/ by its own name, where run.sh imports from; putting agent_clock/agent_egress.py at app/agent_clock/ passed every other test. - Letta Code's README: what a jump back or a frozen clock does to file locks (a killed CLI's reflection transcript lock, waits for a held lock), the time-based message id on a frozen clock, the memory listing's mixed commit and file times, and git log and status among the commands that work at 1950 and 3026. - The agents README names Letta Code among the agents on the shared egress rule. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s before the clock Under root's supervisord a crashed server was restarted in place: the dead server's CLI went on in the workspace, the new one had lost the env's MCP servers, config, peers and tasks, so later turns ran silently without the env's tools, and prompt_agent polled "Task not found" until its timeout. Now root.conf never restarts the server, and an event listener on its EXITED or FATAL stops supervisord, so the container ends and the run fails as on main. The clock follower and the egress proxy keep restarting in place; a stop of the container stops the server without an exit event. supervisord 4.2.5 always exits 0, so the container's status is 0 rather than 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 |
What and why
The Letta Code image can now follow a task env's virtual clock, as the Claude Code and OpenCode images do (#726, #818, #831, #832). It follows only when a
sync_env_clockstep setsagent_clock: true(require_agent_clockimplies it). Otherwise the agent runs on real time and reads the env's time from the gateway'sget_timetool, exactly as onmain.How it works once a task opts in
Time
lettaprocess, so the whole CLI follows the clock. That includes the- **Local time**:line of the environment context the CLI gives the model, and every command the model runs (date, the timestamps it writes into files).lettacommand,letta mcp call(started by the CLI for each MCP tool call), the model's commands, and the bridge's owngitcommit to the memory.AGENTENV_REAL_TIME=1). Left on the env's clock, it would write a virtual dump time into its.snar, and on a clock ahead of real time the next increments would miss every modified file. The snapshot's plain tars stay on the env's clock; they record only the files' own times.Network
127.0.0.1over plain HTTP, directly. The relay, on real time, makes the TLS call to the endpoint.agent_egress.egress_env. On an armed clock, everylettacommand of a turn getsHTTP(S)_PROXY,ALL_PROXY,NO_PROXYandNODE_USE_ENV_PROXY=1, and so doletta mcp calland the model's commands, which inherit them.host.docker.internal, the deploy'sNO_PROXYhosts and plain-HTTP-only hosts go direct. Every TLS host goes through the egress proxy.NODE_EXTRA_CA_CERTS. That is the*.modal.hostcase fix(claude-code): reach env MCP servers through the egress proxy on an armed clock #818 fixed, and it also covers a clock behind real time.State
messages.jsonlin file order (read in the pinned 0.34.26 bundle).What changes
shared_sources.tomltakesutils/faketime_clock,utils/egress_proxyandutils/agent_clock.USER,CMD ["/usr/local/bin/start-agent"]. It copiesagent_egress.pyandclockpage.pybeside the bridge, andinstall.shdoes the same.start-agentandroot.conf: root's supervisord runs the follower, the egress proxy (AGENTENV_EGRESS_PRIVATE="allow") and the A2A server, the server asagentwith the real-time marker. Started as another user, the image runsentrypoint.shalone, as before. A provider's CA bundle stays trusted.main: supervisord never restarts it (autorestart=false), and an[eventlistener:agent-exit]inroot.confstops supervisord when the server exits or fails to start (PROCESS_STATE_EXITED/PROCESS_STATE_FATALfor theagentprogram), so the container ends. The listener is a few lines of inlinepython3speaking supervisord's eventlistener protocol, sending SIGTERM to its parent. The follower and the proxy keep their own restart policy (autorestart=true). See "Server exit" below.letta_code_bridge._turn:_context_env(context_id, [every MCP URL], armed=clock_armed()).a2a_server: the changelog's baseline and capture tars run withAGENTENV_REAL_TIME=1.tst/unit/agents/letta_code/test_env_clock.py: the call site; the default-off equality; the changelog's real time; CA bundles.tst/unit/agents/letta_code/test_image_contract.py: every copied file exists; the image and an install carry every module the server imports; an install puts each file underapp/by its own name, whererun.shimports from.tst/unit/agents/letta_code/test_server_exit.py:root.confparsed as supervisord parses it. The server hasautorestart=falseand the follower and the proxyautorestart=true. There is one listener, running as root, on exactly EXITED and FATAL. Its inline command is also run against a stand-in supervisord that plays the protocol: it sends SIGTERM for theagentprogram's EXITED and FATAL and for nothing else (clock,egress), and keeps serving after each.test_agent_clock_images.pycovers this image.test_agent_env_clock_local.py) has a row for it, with a real CLI turn against a stub OpenAI chat-completions endpoint (tst/util/fake_openai.py). The turn checks that the Local time line and the model's Bashdateshow the env's date, and that model calls reach the loopback relay with the proxy variables set.No change to the shared
utils/egress_proxy,utils/faketime_clockorutils/agent_clock.requirements.txtis unchanged:main's floor of 0.1.588 already servessync_time.With the clock off: same as
main, except at the image levelA turn runs exactly
main'slettacommands, with exactly the environmentmain's bridge built: no proxy variables, the same flags.test_unarmed_a_turn_runs_mains_commands_with_mains_environmentpins this. What still differs, even with the clock off:Start. The container starts as root, and root's supervisord is PID 1. It runs the clock follower (as
agentenv-clock, idle until a task opts in), the egress proxy (asagentenv-egress, on127.0.0.1:3128, unused) and the A2A server (asagent). On local Docker the server was alreadyagent. Adocker execwithout-unow runs as root, because the image no longer setsUSER.Modal. Modal runs the image as root. On
main, the A2A server, the CLI and the model's commands ran as root there; now they run asagent, uid 10001. A task whose model needs root (apt-get install, writing outside/app,/dataand/tmp) can fail on Modal. A side effect: the CLI's own auto-updater, which starts on everylettarun and, as root onmain, could replace the pinned CLI with a globalnpm install, now fails harmlessly.Egress boot. The egress proxy's boot (minting the per-boot image CA) runs on every start, and a failed boot stops the container with exit 2.
Server exit. Same as
main: when the A2A server exits, for any reason, the container ends and the run fails. Earlier on this branch supervisord restarted a crashed server in place. That left the dead server's CLI running in the workspace, and the new server had lost the env's MCP registrations, theagent-configvalues, the peers and the running tasks. Later turns then ran silently without the env's tools, andprompt_agentpolled "Task not found" until its full timeout. Nowroot.confnever restarts the server, and theagent-exitlistener stops supervisord. Two small differences frommainremain:main's was the server's own (137 after akill -9). supervisord 4.2.5 always exits 0 after a shutdown and has no setting to change that.startretrieswith backoff) before supervisord gives up and the container ends. Onmainthe container ended at once.The follower and the proxy still restart in place, and a normal stop of the container (
docker stop, a sandbox teardown) stops the server without an exit event and exits cleanly. Claude Code's and OpenCode's clocked images onmainstill restart a crashed server in place.Environment. The server's environment, which the CLI and the model's commands inherit, gains:
AGENTENV_EGRESS_PROXY;NODE_EXTRA_CA_CERTS,SSL_CERT_FILEandREQUESTS_CA_BUNDLE, pointing at agent-env's bundles: the system roots plus the per-boot image CA, plus a provider's own bundle when it sets one;USERandLOGNAME(agent);SUPERVISOR_ENABLED,SUPERVISOR_PROCESS_NAME,SUPERVISOR_GROUP_NAMEandSUPERVISOR_SERVER_URL.Trust. The per-boot image CA is trusted in the system store and in the certifi bundles.
Preload. libfaketime and the TLS shim are preloaded in every process (
/etc/ld.so.preload). With an unarmed page, both read real time.Changelog tar. The changelog tar gets
AGENTENV_REAL_TIME=1in its environment. With the clock off this changes nothing.Installs. An install into a task container or onto a VM host (
install.sh) also copiesagent_egress.pyandclockpage.pyintoapp/. It gets no clock, as before.What still reads the env's clock against other times (in the README)
git fsckflags both.commit,ls-tree,show,logandstatuswork. Checked with git 2.52 on macOS, and with Debian's 2.39 in the image at 1950 and 2262: every turn's commit landed, andfsckreportsbadDateOverflowandbadTimezone.Retry-Aftergiven as a date is read against the env's date. The CLI waits at most 60 s, and LiteLLM and the providers send seconds anyway.Failed to append transcript deltain the context's debug log).Other limits
registry.npmjs.org) and its telemetry (api.letta.com) go through the proxy. In the VM runs the proxy re-signed them (mode: intercept) and they worked.messages.jsonlonly grew. The pre-turn size estimate after the jump comes from reading the code.sync_env_clockwithagent_clockorrequire_agent_clockthen fails the step with "this agent's clock follower isn't following the gateway: it hasn't heard from the gateway … yet", which doesn't name the date as the cause. This is shared code, the same for every clocked agent.ls -l,stat,find -newer) and whatever a live service reports, such as HTTPDateheaders. Both stay real.Testing
Unit (macOS, this head)
tst/unit/agentsandtst/unit/utils: 1346 passed, 46 skipped (Linux-only).ruff check: clean.armed=False,armed=True, dropping the MCP URLs, droppingegress_env;agent_egress.py, the install not carryingmcp_tools.ts, and the install putting a file atapp/<path>instead ofapp/<name>. That last mutation passed all 54 other tests, so a test was added for it;root.conf: the server'sautorestart=true, the listener matching another program name, the listener droppingPROCESS_STATE_FATAL, the listener signalling itself instead of supervisord, and a;in its command, which supervisord would read as the start of a comment.The pinned CLI (0.34.26), locally, against a stand-in model API, no key
NODE_OPTIONS, a macOS stand-in for libfaketime, so the model's shell showed real time. Each run had four turns of about 40 s in one conversation, through the bridge and through the real A2A server.2031-03-04T05:06:07Z, a frozen-clock turn through the bridge againsttst/util/fake_openai.py, with the e2e's responder, completed in 3.4 s. It read- **Local time**: Tuesday, March 4, 2031 at 05:06 AM UTC, which the e2e's assertions accept.CONNECT …:443and reached aNO_PROXYplain-HTTP host directly. The image runs Node 22.23.4.commit,log --format=%ct,status,showandls-treework. At 1950,%ctprints the overflowed18446744073081078017.Earlier on this branch (at e7bc8c0): an image build, the local armed-clock e2e, and the A2A validator against a real model through LiteLLM. clock/v1 was supported, synced and followed writes.
VM phase (dedicated x86_64 Ubuntu 24.04 VM, branch at 602e31e against
main= agentenv-framework 0.9.1609 from PyPI, whose letta-code is the publishedghcr.io/scaleapi/agentenv-letta-code@sha256:cce226db…; models through LiteLLM withanthropic/claude-haiku-4-5)Linux unit tests.
tst/unit/agentsandtst/unit/utils: 1355 passed and 0 skipped. The 46 that skip on macOS ran and passed.Image smoke. The image built from 602e31e in 81 s.
test_agent_env_clock_local.py -k letta-codepassed (158 s):dateanddatetime.now()showed2031-03-04T05:06:07Zat rate 0;dateread2031-03-04T05:06:07Z;agent-solverwhile the agent was paused;Clock off. Each
lettaprocess's/proc/<pid>/environ(sampled during stand-in turns and real turns) has no*_PROXYand noNODE_USE_ENV_PROXY. Againstmain's it has exactly 10 more variables, the ones listed above (19 → 29).docker run --user 10001runsuvicornalone (viaentrypoint.sh), with no supervisord and real time. On Modal, with the clock off, the model'sid -uprinted 0 onmainand 10001 here.FD-6434 repro in the image (stand-in model, 4 turns of about 43 s). Real, +75 d, 1950 and 2262 (the clock page's limit; +1000 y can't be set, see "Dates past 2262"), plus jumps (real → +75 d → 1950 → 2262 between turns, and 3600x then a jump back inside each turn), all pass:
dateread the clock's date;messages.jsonlonly grew;The jumps run with a compaction after turn 2 compacted once and completed turns 3 and 4 (see "Compaction evidence").
Real-model end to end (agents on local Docker;
mailon local Docker or on Modal):mainon the same prompts, unarmed and armed withoutagent_clock, local and Modal. Both sides showed the same behaviour: realdateand Local time,get_timeUNAVAILABLE when unarmed and the env's date when armed, MCP direct, no follower config.long-lc-on(+75 d): following;date, Local time andget_timeread 2027-02-03; MCP worked; the write while the agent was paused answered 504 naming it; the late agent followed; all 4 turns kept every earlier label (5/5 checks).HTTP(S)_PROXY,ALL_PROXY,NODE_USE_ENV_PROXY=1andNO_PROXY=localhost,127.0.0.1,::1,host.docker.internal. The egress logs show no loopback host anywhere: model calls went to the relay directly.mailon Modal, armed at 2026-10-27, before the*.w.modal.hostcertificate's notBefore (Nov 19 2026, ZeroSSL). MCP went through the proxy, re-signed (intercept), and the invoice came back; every date read 2026-10-27.behind-lc-on(2025-06-01, certificate notBefore Nov 20 2026): passed the same way.require_agent_clock, with the agent deployed after or before the clock: passed here. Onmainit fails clearly: "agent 'default-agent' can't follow the clock of env …: not_advertised".notes/notes.txt(versions 1, 2, 3) (R7).The Modal service-db start-up race hit 5 times (retried). One
mainclock-off run on Modal lost all three of its attempts to it; the same case passed in its other Modal pair.Chaos (two runs, both opted in,
mailon Modal). In the first run, Modal terminated the env from outside (a shared app) during the 600 s wait below, so its second half was run again.kill -9of the follower (restarted in 3 s, the next write acknowledged);kill -9of the egress proxy (restarted, MCP fine on the next turn); the model endpoint blocked for 45 s mid-turn (that turn still completed).reset_env(the clock and follower were kept), clear (back to real time) and a backward re-arm at 2026-01-15 withoutagent_clock(the agent kept following) all showed the right date.File lock timeoutand noFailed to append transcript deltain any container log or session.prompt_agentpolled "Task not found" until its own timeout (600 s by default). The image now ends the container instead; see "Server exit" above and the crash checks below.Server crash, this head (eb890df:
mainat 64afced merged in; the stand-in model API, themailenv and the agent on local Docker;main= agentenv-framework 0.9.1609's published image). In each run, the A2A server gotkill -912 s into a turn, while its CLI ran the model'ssleep 30. On the branch that was akill -9inside the container; onmain, where the server is PID 1, it wasdocker kill -s KILL. Each run had a second turn after the crash.mainprompt_agentfailed after the killagent-configunreachable, 10 tries in 104 s)Both fail at
prompt_agent's own rule ("stopped answering: 5 polls in a row over 60s got no reply"), so the branch now fails as fast asmain. Before this change it polled "Task not found" for 600 s. supervisord's log readsexited: agent (terminated by SIGKILL; not expected), thenreceived SIGTERM indicating exit request1 s later, then each program stopped. The killed turn's CLI and itssleep 30went with the container: the CLI never made its next model call. The previous phase's attempt to killmain's server by its host pid had been refused, unnoticed, by AppArmor (docker-default doesn't take signals from the SSM agent's snap profile). Themaincolumn above is the first real measurement.Turns still work, this head (stand-in model,
mailon local Docker; all passed):dateread real time (2026-11-21).agent_clock): the agent'sdateand the model'sdateread 2027-02-03.kill -9, then the egress proxy: each restarted within 4 s with a new pid, while the server kept its pid and uptime and the container stayed running with 0 restarts. Next, anadvancewithwait_followers_swas acknowledged in 0.02 s, and a turn read the new date, 2027-02-04.Stops and start failures, this head (
docker runof the image):docker stopexited 0 in 2.3 s.docker stopmid-turn exited 0 in 6.5 s: the server waited out its 5 s graceful shutdown and killed the turn's CLI. The listener stayed silent, since each program ended asstopped, notexited.A2A_PORT=notaport) was retried three times, wentFATAL, and the container ended 12.6 s afterdocker run, exit 0.uvicornalone, as before.SIGTERM to
agent-env runmid-turn, both sides: the run was recorded cancelled, 2 sandboxes were torn down, and no containers or sandbox folders were left.Image size: 1,369,446,346 B against
main's 1,352,085,856 B (+17.4 MB, +1.3%).Follow-up (separate PR, from
main)Set
DISABLE_AUTOUPDATER=1in the image. Everylettarun starts the CLI's auto-update check in the background: it fetches from the npm registry, and when a newer version is out it runs a globalnpm install. That ismain's behaviour with the clock off, so changing it here would break "same asmain".Claude, working with Edgar, finished this PR.
🤖 Generated with Claude Code


Confidence Score: 5/5
The PR appears safe to merge; no new actionable issue was established.Summary
Letta Code can now follow the task environment’s clock after explicit opt-in.
The earlier unnumbered finding about missing shared clock helpers is fixed: both helpers are declared, copied, and imported.
williamloo-scale documents the accepted Modal user change, container exit status and startup retries, and CLI limits around dates, locks, and memory ordering.
Diagram
%%{init: {'theme': 'neutral'}}%% flowchart LR S[Root supervisord] --> F[Clock follower] S --> E[Egress proxy on real time] S --> A[A2A server on real time] F --> P[Shared clock page] A --> C[Letta CLI] P --> C C --> R[Loopback model relay] R --> M[Model endpoint] C --> E E --> T[HTTPS task tools] A --> X[Server exit listener] X --> Q[Stop supervisord and container]Reviews (12) · Last reviewed commit: "fix(agents): Letta Code's container ends..." · Reviewed by Greptile