Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
ae1d4be
feat(agents): agents follow the env's clock the way computers do (FD-…
williamloo-scale Nov 16, 2026
eea933c
refactor(agents): leave the Claude Code image to its own PR; agents s…
williamloo-scale Nov 17, 2026
608a93d
Merge origin/main
williamloo-scale Nov 17, 2026
182cef0
feat(agents): the Claude Code image follows the env's clock (FD-5916)
williamloo-scale Nov 17, 2026
bce00d4
fix(agents): agent clock review: new config's status, one clock per a…
williamloo-scale Nov 17, 2026
84381b8
fix(agents): keep each agent's clock record on a key of its own; a re…
williamloo-scale Nov 17, 2026
56dac45
fix(agents): agent clock keys can't collide; one clock env per agent;…
williamloo-scale Nov 17, 2026
c726743
chore: drop test run output committed by mistake
williamloo-scale Nov 17, 2026
5e8c756
Merge #714
williamloo-scale Nov 17, 2026
3b6f499
test(agents): the Claude Code image follows the env's clock end to en…
williamloo-scale Nov 17, 2026
cecc686
fix(agents): a failed agent sync retires its follower; the task's zon…
williamloo-scale Nov 17, 2026
afe55b4
Merge origin/main
williamloo-scale Nov 17, 2026
d523a6e
Merge #714
williamloo-scale Nov 17, 2026
ac0a39e
fix(agents): libfaketime's init can't deadlock the CLI; the CLI goes …
williamloo-scale Nov 17, 2026
c8ed6e1
fix(agents): a later clock sync leaves agents teardown_sandboxes took…
williamloo-scale Nov 17, 2026
b5d3b4b
fix(ci): the agent clock e2e skips as a declared capability gap; the …
williamloo-scale Nov 17, 2026
25af21a
chore: drop test-run output committed again, and ignore where the pro…
williamloo-scale Nov 17, 2026
7216c7c
fix(agents): route the CLI through egress by the clock page's armed f…
williamloo-scale Nov 17, 2026
fc3134b
Merge #714
williamloo-scale Nov 17, 2026
f8bd9ff
feat(a2a-agent): validate clock/v1 by the time the agent's own comman…
earakely-scale Nov 17, 2026
f9af1b6
refactor(a2a-agent): name the clock validation's timeouts and error l…
williamloo-scale Nov 17, 2026
43fdb97
fix(gateway): get_time says the machine's clock may not be synchroniz…
earakely-scale Nov 18, 2026
8bf8e4c
refactor(a2a-agent): move agent_clock to a2a_agent/clock.py, beside t…
earakely-scale Nov 18, 2026
810f42e
Merge #714
williamloo-scale Nov 18, 2026
686fdf1
test(agents): the agent clock e2e imports FOLLOWING_KEY from a2a_agen…
williamloo-scale Nov 18, 2026
9d7d6c0
Merge origin/main (#714 merged)
williamloo-scale Nov 18, 2026
1ff90bd
fix(agents): the Claude Code image installs protocol 0.1.575, the fir…
earakely-scale Nov 18, 2026
ca97b37
fix(computers): the clock follower follows a changed config while its…
earakely-scale Nov 18, 2026
0875e06
fix(agents): an armed clock keeps the agent's own NO_PROXY hosts dire…
williamloo-scale Nov 18, 2026
bb4f07f
test(agents): the agent clock checks run over every clocked agent ima…
williamloo-scale Nov 18, 2026
a3f9e34
Merge main into #726: the clock and egress proxy now live in utils (#…
earakely-scale Nov 18, 2026
3c60fda
refactor(agents): the Claude Code image takes the clock and egress pr…
earakely-scale Nov 18, 2026
150c563
test(agents): Claude Code's contract test takes the folders shared_so…
williamloo-scale Nov 18, 2026
aed27ee
fix(agents): a private HTTPS model endpoint is reached directly on an…
williamloo-scale Nov 18, 2026
a6f3720
fix(agents): the model host's lookup is bounded and kept, so a slow r…
williamloo-scale Nov 18, 2026
660d816
fix(agents): a private HTTPS model endpoint goes through the egress p…
earakely-scale Nov 18, 2026
8848ea0
fix(agents): the egress proxy's private-network setting joins its pro…
earakely-scale Nov 18, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ updates:
groups:
infra-base-images:
patterns: ["*"]
# The base computers' egress proxy, a Go program their Dockerfiles build: its modules' fixes, uTLS's and
# golang.org/x/crypto's among them. A bump changes the bases' sources, so the next release rebuilds and publishes them.
# The egress proxy, a Go program the base computers' and the Claude Code image's Dockerfiles build: its modules' fixes,
# uTLS's and golang.org/x/crypto's among them. A bump changes their sources, so the next release rebuilds them.
# The browser base's copy is the desktop's, byte for byte (a unit test checks it), so one grouped pull request bumps
# both.
- package-ecosystem: "gomod"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/local-backends.yml
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ jobs:
run: |
.venv/bin/python .github/scripts/check_skip_policy.py junit-integration-slow.xml \
--allow model_endpoint_configured remote_sandbox default_a2a_agent mcp_server_sources windows_media \
omarchy_image
omarchy_image agent_clock_image
# The tests' times, for .github/scripts/slow_test_durations.py to rebalance the shards with.
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
if: always()
Expand Down
16 changes: 16 additions & 0 deletions src/agent_env/agents/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,22 @@ turn off becomes `--disallowedTools`, which keeps the CLI's defaults for the res
`claude_bridge.py`: every tool the pinned CLI has, though which it offers by default depends on the model. A test fails
when the Dockerfile's `CLAUDE_CODE_VERSION` moves, until `ClaudeCodeTool` and `TOOLS_CLI_VERSION` move with it.

The image follows a task env's clock the way a computer does (FD-5916): it runs the computer base's clock follower
and egress proxy, taken from `utils/faketime_clock` and `utils/egress_proxy` through its `shared_sources.toml`, each as
its own user under root's supervisord (`start-agent`, `root.conf`), with agent-env's libfaketime preloaded for the
agent's user.
The A2A server starts with the real-time marker, so it and its records stay on real time, and serves clock/v1's
`sync_time`, which the protocol's framework serves on the card of any agent in an image with the follower
(`agentenv_protocol.a2a_agent.clock`). Once `sync_env_clock` has armed the clock, it declares the agent at the gateway
as a follower with a read token of its own and calls that `sync_time` with the follower's config, which the server
writes; `deploy_agent` does the same for an agent it deploys while the clock is armed. From then on the CLI, its own
"Today's date is" line included, and every command the model runs read the env's time, and a clock write that waits for
followers waits for the agent. While the clock is armed the CLI goes out through the egress proxy, which keeps a live
site's TLS working at any date the clock shows, and to the env's MCP servers and a plain-HTTP model endpoint directly.
The image's proxy reaches private networks too (`AGENTENV_EGRESS_PRIVATE`), so a model endpoint over TLS at a private
address works at any date as well. Unarmed, the page holds real time and the CLI goes out directly, as before. Started
as a user other than root, the image runs the A2A server alone, on real time, as before.

`install_agent` installs it too, into a container a task already runs or onto a `vm` sandbox's Linux host, with
`install.sh` from its folder: Claude Code's native build for the target's CPU and libc, uv, and the agent's requirements
in a Python of its own, so the target's Python is left alone. The CLI runs its commands in bash or zsh, so a target with
Expand Down
44 changes: 40 additions & 4 deletions src/agent_env/agents/agents/claude-code/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
# Node for the scripts the model runs, without npm or npx; Claude Code itself is a native build.
FROM public.ecr.aws/docker/library/node:22-slim@sha256:c3de60bf2f9dd0ac6370e6117950ff62d6e339527e7472301c9c78a017978392 AS node

# The env's clock: the egress proxy, one static Go binary, and agent-env's libfaketime and its TLS shim, taken from
# agent-env's sources as clock/ and egress/ (shared_sources.toml) and built for this image's libc (Debian bookworm) in
# stages of their own, so no toolchain is left in the image.
FROM public.ecr.aws/docker/library/golang:1.26.11-bookworm@sha256:dc40a13b61304647ed7e5d581d246b86413dfc29d63c6d018310feb93cd98fc0 AS egress
COPY egress/ /egress/
RUN cd /egress && go vet ./... && go test -count=1 ./... \
&& CGO_ENABLED=0 GOFLAGS=-mod=readonly go build -trimpath -ldflags=-s -o /out/egress .

FROM public.ecr.aws/docker/library/python:3.11-slim@sha256:c20888b6acdd1e63e1c433a185bf3ad162c0288fe484616ce062e0d28add2900 AS clock
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
build-essential patch curl ca-certificates
COPY clock/ /clock/
RUN sh /clock/build.sh /out

FROM public.ecr.aws/docker/library/python:3.11-slim@sha256:c20888b6acdd1e63e1c433a185bf3ad162c0288fe484616ce062e0d28add2900
# poppler-utils: the CLI's Read tool runs pdftoppm for a PDF's pages.
RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates curl poppler-utils \
Expand All @@ -24,13 +38,35 @@ COPY requirements.txt model-requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt -r model-requirements.txt
# install.sh and run.sh are install/v1's: in the image, so they stay in its build context.
COPY a2a_server.py claude_bridge.py kit.py tar_changelog.py entrypoint.sh install.sh run.sh ./
# The CLI's cwd, /app, and its state, fixed so neither follows the uid: Modal runs the image as root.
# The CLI's cwd, /app, and its state, fixed so neither follows the uid.
RUN useradd --create-home --uid 10001 agent && mkdir -p /app /home/agent/.claude \
&& chown agent:agent /app /home/agent/.claude && chmod 0755 entrypoint.sh
# The env's clock: the follower and the egress proxy, each as its own user, under root's supervisord (root.conf), and
# agent-env's libfaketime and its TLS shim preloaded into every process, faking only the agent's (clock.conf). The
# follower's config is the agent's user's to write (agentenv_protocol.a2a_agent.clock) and the follower's to read.
RUN pip install --no-cache-dir supervisor==4.2.5 \
&& useradd --system --no-create-home --home-dir /nonexistent --shell /usr/sbin/nologin agentenv-clock \
&& useradd --system --no-create-home --home-dir /nonexistent --shell /usr/sbin/nologin agentenv-egress \
&& mkdir -p /usr/local/lib/agentenv-clock /usr/local/lib/agentenv-egress /etc/agentenv \
&& install -d -o agent -g agentenv-clock -m 2750 /etc/agentenv/clock \
&& touch /etc/agentenv/ca.pem \
&& cp /etc/ssl/certs/ca-certificates.crt /etc/agentenv/ca-bundle.pem \
&& cp /etc/ssl/certs/ca-certificates.crt /usr/local/lib/agentenv-egress/roots.pem
COPY --from=clock /out/libfaketimeMT.so.1 /out/libtls_realtime.so /usr/local/lib/agentenv-clock/
COPY --from=egress /out/egress /usr/local/lib/agentenv-egress/egress
COPY clock/clockpage.py clock/clock-follower /usr/local/lib/agentenv-clock/
COPY clock/clock.conf /etc/agentenv/clock.conf
COPY root.conf /etc/agentenv/root.conf
COPY start-agent /usr/local/bin/start-agent
RUN sed -i -e "s/^AGENTENV_SESSION_UID=.*/AGENTENV_SESSION_UID=$(id -u agent)/" \
-e "s/^AGENTENV_CLOCK_PAGE_UID=.*/AGENTENV_CLOCK_PAGE_UID=$(id -u agentenv-clock)/" /etc/agentenv/clock.conf \
&& chmod 0755 /usr/local/lib/agentenv-clock/clock-follower /usr/local/bin/start-agent \
&& printf '%s\n' /usr/local/lib/agentenv-clock/libfaketimeMT.so.1 /usr/local/lib/agentenv-clock/libtls_realtime.so \
> /etc/ld.so.preload

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Blocker: with this preload the Claude Code CLI deadlocks at startup. claude --version never returns, as the agent user or root, armed or not.

  • Without /etc/ld.so.preload it returns at once.
  • Preloading only libtls_realtime.so is fine; preloading only libfaketimeMT.so.1 hangs.
  • gdb on the hung process: clock_gettime → ftpl_init → pthread_once waiting on itself (futex, single thread). Upstream 0.9.12's own comment at that call says "If ftpl_init ends up recursing, pthread_once will deadlock."

I think this, not the proxy, is the claude CLI timed out after 600s on #714's CI: the CLI never gets as far as a request.

A per-thread guard fixed it on my box: a clock call made while libfaketime's init is running reads the kernel clock instead of waiting. With it, the whole flow worked end to end:

  • the CLI's Today's date is line and the model's commands followed the env's clock, including jumps during a turn;
  • the CLI reached api.anthropic.com through egress at a date outside its certificate.

The computer base ships the same patch, so other programs on computers that call the clock this way might freeze too; I haven't checked that.

The guard I tested (on top of libfaketime.patch)
--- a/src/libfaketime.c
+++ b/src/libfaketime.c
@@ -329,6 +329,9 @@
   check_missing_real(#name, (NULL == real_##name))
 
 static pthread_once_t initialized_once_control = PTHREAD_ONCE_INIT;
+/* Set on the thread running ftpl_really_init: a time call it makes, as an allocator that reads the clock does when
+ * dlsym allocates, takes the kernel's clock instead of waiting on the init it is part of. */
+static __thread int ftpl_initializing = 0;
 
 /* prototypes */
 static int    fake_gettimeofday(struct timeval *tv);
@@ -2326,6 +2329,7 @@
   int result;
 
   ftpl_init();
+  if (ftpl_initializing) return syscall(SYS_clock_gettime, clk_id, tp);
   // If ftpl_init ends up recursing, pthread_once will deadlock.
   // (Previously we attempted to detect this situation, and bomb out,
   // but the approach taken wasn't thread-safe and broke in practice.)
@@ -3103,8 +3107,15 @@
   dont_fake = dont_fake_final;
 }
 
+static void ftpl_really_init_guarded(void) {
+  ftpl_initializing = 1;
+  ftpl_really_init();
+  ftpl_initializing = 0;
+}
+
 inline static void ftpl_init(void) {
-  pthread_once(&initialized_once_control, ftpl_really_init);
+  if (ftpl_initializing) return;
+  pthread_once(&initialized_once_control, ftpl_really_init_guarded);
 }
 
 void *ft_dlvsym(void *handle, const char *symbol, const char *version,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, this was the real blocker. I reproduced it: claude --version hung (killed by timeout after 20 s) with /etc/ld.so.preload in place, and returned at once without it. Fixed in ac0a39e with your guard, appended to the agent's clock/libfaketime.patch. It applies cleanly after the existing patch, and claude --version now returns as root and as agent. The computer base doesn't take it yet, so the drift test now checks that the agent's patch is the base's, byte for byte, followed by the guard. Whether computers need it too is worth its own PR. I agree this, not the proxy, explains the 600 s timeouts. I also made the CLI go through egress only while the follower follows an armed clock, and reach a plain-HTTP model endpoint directly, so a private endpoint keeps working when the clock isn't set.

ENV A2A_PORT=8000 PYTHONPATH=/opt/agent CLAUDE_CONFIG_DIR=/home/agent/.claude \
DISABLE_AUTOUPDATER=1 CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1
USER agent
WORKDIR /app
EXPOSE 8000
# CMD rather than ENTRYPOINT: Modal passes a sandbox's env to the image's CMD only.
CMD ["/opt/agent/entrypoint.sh"]
# Starts as root, which start-agent needs for the clock; the A2A server and the CLI run as the agent's user. CMD rather
# than ENTRYPOINT: Modal passes a sandbox's env to the image's CMD only.
CMD ["/usr/local/bin/start-agent"]
78 changes: 75 additions & 3 deletions src/agent_env/agents/agents/claude-code/claude_bridge.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@
import re
import signal
import stat
import struct
import time
from collections.abc import Callable, Mapping
from collections.abc import Callable, Iterable, Mapping
from dataclasses import dataclass, field, replace
from functools import partial
from pathlib import Path
from typing import Literal
from urllib.parse import urlsplit

from pydantic import BaseModel, ConfigDict, model_validator

Expand Down Expand Up @@ -173,8 +175,74 @@ def _model_headers(raw: str | None) -> dict[str, str]:
return {str(name): str(value) for name, value in headers.items()}


#: Set by the image (root.conf) where the egress proxy runs: the CLI and the model's commands go out through it
#: while the agent follows an armed clock.
EGRESS_PROXY_ENV = "AGENTENV_EGRESS_PROXY"
#: The clock page agent-env's libfaketime reads the CLI's time from (clock/clockpage.py, version 2): it keeps the last
#: armed clock while the follower reconnects or restarts, which the follower's status doesn't say.
CLOCK_PAGE = "/dev/shm/agentenv-clock"
_PAGE = struct.Struct("<IIQqqdIIQQqq") # magic version seq universe_ns anchor_ns rate armed reserved generation check ...
_PAGE_MAGIC, _PAGE_VERSION, _MASK = 0x4B434541, 2, 0xFFFFFFFFFFFFFFFF
#: The constant every page's check is salted with (clockpage.check).
_PAGE_CHECK_SALT = 0x9E3779B97F4A7C15
#: How often, and how far apart, a read retries a page a write is under way on: 50 ms in all, far longer than a write.
_PAGE_READ_TRIES, _PAGE_RETRY_S = 50, 0.001
_DIRECT_HOSTS = ("localhost", "127.0.0.1", "::1", "host.docker.internal")


def clock_armed(page_path: str | None = None) -> bool:
"""Whether the clock page holds an armed clock, so the CLI started now reads the env's time: the page itself,
as libfaketime reads it, retried while a write is under way (seq odd) or its check doesn't match."""
try:
with open(page_path or CLOCK_PAGE, "rb") as page:
for _ in range(_PAGE_READ_TRIES):
page.seek(0)
raw = page.read(_PAGE.size)
if len(raw) < _PAGE.size:
return False
magic, version, seq, universe, anchor, rate, armed, _, generation, checked, mono_u, mono_a = \
_PAGE.unpack(raw)
if magic != _PAGE_MAGIC or version != _PAGE_VERSION:
return False
rate_bits = struct.unpack("<Q", struct.pack("<d", rate))[0]
expected = (seq ^ (universe & _MASK) ^ (anchor & _MASK) ^ rate_bits ^ armed ^ generation
^ (mono_u & _MASK) ^ (mono_a & _MASK) ^ _PAGE_CHECK_SALT) & _MASK
if seq % 2 == 0 and checked == expected:
return bool(armed)
time.sleep(_PAGE_RETRY_S)
except OSError:
return False
return bool(armed) # a writer that died mid-write: the next write takes the page up; its armed flag says the most


def model_direct_hosts(base_url: str | None) -> list[str]:
"""The model endpoint's host when the CLI reaches it directly on an armed clock: over plain HTTP, which has no
certificate to check at the env's date. Over TLS it goes through the egress proxy, which checks the certificate on
real time and, in an agent's image, reaches a private network's address too (``AGENTENV_EGRESS_PRIVATE``)."""
endpoint = urlsplit(base_url or "")
return [endpoint.hostname] if endpoint.hostname and endpoint.scheme == "http" else []


def egress_env(environ: Mapping[str, str], direct: Iterable[str] = (), *, armed: bool = False) -> dict[str, str]:
"""The egress proxy for the CLI and what it starts, where the image runs one (FD-5916) and the clock is ``armed``:
they read the env's time, so a client checking a live site's certificate against it would refuse the site once
the clock is months off, and the proxy, on real time, hands it a certificate that holds then. The env's MCP servers
(``direct``) are reached directly: the proxy refuses an address that isn't global, as a local or private gateway's
is. Unarmed, the CLI reads real time and goes out directly, as an image without the proxy does, so a model endpoint
or mirror at a private address keeps working. Hosts the agent was deployed to reach directly (``NO_PROXY``,
``no_proxy``) stay direct."""
proxy = environ.get(EGRESS_PROXY_ENV)
if not proxy or not armed:
return {}
configured = [host.strip() for name in ("NO_PROXY", "no_proxy") for host in (environ.get(name) or "").split(",")]
hosts = ",".join(dict.fromkeys([*_DIRECT_HOSTS, *filter(None, configured), *filter(None, direct)]))
return {**{name: proxy for base in ("HTTP_PROXY", "HTTPS_PROXY", "ALL_PROXY") for name in (base, base.lower())},
"NO_PROXY": hosts, "no_proxy": hosts, "NODE_USE_ENV_PROXY": "1"}


def cli_env(environ: Mapping[str, str], *, model: str | None = None, project_id: str | None = None,
task_id: str | None = None, max_thinking_tokens: int | None = None) -> dict[str, str]:
task_id: str | None = None, max_thinking_tokens: int | None = None,
direct_hosts: Iterable[str] = (), clock_armed: bool = False) -> dict[str, str]:
"""The CLI's environment: this process's, pointed at the endpoint agent-env configured (its key as a bearer
token, so an API key too would conflict), with the endpoint's headers and the run's attribution, and the model's
aliases pinned to ``model`` on that endpoint. A variable already set is kept, LITELLM_* too, so a script the model
Expand Down Expand Up @@ -203,6 +271,8 @@ def cli_env(environ: Mapping[str, str], *, model: str | None = None, project_id:
# Older CLIs prepend a changing attribution block to the system prompt on custom base URLs, which defeats the
# provider's prefix cache.
env["CLAUDE_CODE_ATTRIBUTION_HEADER"] = "0"
model_hosts = model_direct_hosts(env.get("ANTHROPIC_BASE_URL")) if clock_armed else []
env.update(egress_env(environ, [*direct_hosts, *model_hosts], armed=clock_armed))
return env


Expand Down Expand Up @@ -682,7 +752,9 @@ async def _spawn_claude(
stdout=asyncio.subprocess.PIPE,
stderr=asyncio.subprocess.PIPE,
env=cli_env(os.environ, model=model, project_id=project_id, task_id=task_id,
max_thinking_tokens=max_thinking_tokens),
max_thinking_tokens=max_thinking_tokens, clock_armed=clock_armed(),
direct_hosts=[urlsplit(str(entry.get("url") or "")).hostname or ""
for entry in (mcp_servers or {}).values()]),
cwd=WORKSPACE_DIR,
start_new_session=True,
))
Expand Down
7 changes: 4 additions & 3 deletions src/agent_env/agents/agents/claude-code/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# The image installs the newest agentenv-framework-protocol at or above this floor; a release doesn't pin it, so the
# image is built again only when this folder changes. The floor is the first that serves peer-agents/v1's tools, which
# the agent advertises without handlers of its own; raise it when the agent needs a newer protocol.
agentenv-framework-protocol[agent]>=0.1.351
# image is built again only when this folder changes. The floor is the first that serves clock/v1's sync_time on an
# agent whose image runs the clock follower (agentenv_protocol.a2a_agent.clock), which this image does; raise it when
# the agent needs a newer protocol.
agentenv-framework-protocol[agent]>=0.1.575
62 changes: 62 additions & 0 deletions src/agent_env/agents/agents/claude-code/root.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
; Root's supervisord (start-agent, FD-5916): the clock follower and the egress proxy, each as its own user, on real
; time, and the A2A server as the agent's user. The server starts with the real-time marker, which agent-env's
; libfaketime takes out of its environment, so the server's own records keep real timestamps and everything it starts,
; the CLI and the model's commands, reads the env's time. Its socket and logs are root's alone, so the agent's user can
; neither stop nor restart any of them. The follower follows nothing until the server writes its config, which
; sync_env_clock has it do, then picks it up within a quarter second.
[supervisord]
nodaemon=true
user=root
logfile=/var/log/agentenv-root/supervisord.log
pidfile=/run/agentenv-root/supervisord.pid
childlogdir=/var/log/agentenv-root

[unix_http_server]
file=/run/agentenv-root/supervisor.sock
chmod=0700

[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface

[supervisorctl]
serverurl=unix:///run/agentenv-root/supervisor.sock

[program:clock]
command=/usr/local/bin/python3 -I /usr/local/lib/agentenv-clock/clock-follower
user=agentenv-clock
directory=/
priority=3
autorestart=true
startsecs=1
startretries=1000
redirect_stderr=true
stdout_logfile=/var/log/agentenv-root/clock.log
environment=HOME="/nonexistent",USER="agentenv-clock",LOGNAME="agentenv-clock"

[program:egress]
command=/usr/local/lib/agentenv-egress/egress serve
user=agentenv-egress
directory=/
priority=3
autorestart=true
startsecs=1
startretries=1000
redirect_stderr=true
stdout_logfile=/var/log/agentenv-root/egress.log
environment=HOME="/nonexistent",USER="agentenv-egress",LOGNAME="agentenv-egress",AGENTENV_EGRESS_PRIVATE="allow"

; uvicorn itself, not entrypoint.sh: the marker holds for the process it's given to alone, and a shell that execs
; uvicorn would hand uvicorn an environment without it.
[program:agent]
command=/usr/local/bin/python3 -m uvicorn a2a_server:app --host 0.0.0.0 --port %(ENV_A2A_PORT)s
user=agent
directory=/app
priority=10
autorestart=true
stopasgroup=true
killasgroup=true
stopwaitsecs=30
redirect_stderr=true
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
environment=HOME="/home/agent",USER="agent",LOGNAME="agent",AGENTENV_REAL_TIME="1",AGENTENV_EGRESS_PROXY="http://127.0.0.1:3128",NODE_EXTRA_CA_CERTS="/etc/agentenv/ca.pem",SSL_CERT_FILE="/etc/agentenv/ca-bundle.pem",REQUESTS_CA_BUNDLE="/etc/agentenv/ca-bundle.pem"
4 changes: 4 additions & 0 deletions src/agent_env/agents/agents/claude-code/shared_sources.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# What this image's build context takes from agent-env's own sources, at the name its Dockerfile copies it from: one
# copy of each, shared with the other images that take it (utils/docker/context.py). Paths are under src/agent_env.
clock = "utils/faketime_clock"
egress = "utils/egress_proxy"
19 changes: 19 additions & 0 deletions src/agent_env/agents/agents/claude-code/start-agent
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/sh
# The image's start (FD-5916). As root, it makes what the agent's user must not touch, the clock page and file (the
# clock user's from their first byte) and the egress proxy's CA (its key the egress user's alone, trusted in the
# system store, agent-env's trust files and every certifi bundle), then starts root's supervisord (root.conf), which
# runs the clock follower and the egress proxy, each as its own user on real time, and the A2A server as the agent's
# user on real time, everything it starts reading the env's time from the page. Until sync_env_clock has the agent
# follow a clock, the page holds real time and the proxy relays TLS untouched. Started as another user, the image runs
# the A2A server alone, as before, on real time.
set -eu
if [ "$(id -u)" != 0 ]; then
exec /opt/agent/entrypoint.sh
fi
install -d -o root -g root -m 0700 /var/log/agentenv-root /run/agentenv-root
install -d -o agentenv-clock -g agentenv-clock -m 0755 /run/agentenv-clock
python3 -I /usr/local/lib/agentenv-clock/clockpage.py create agentenv-clock
AGENTENV_SESSION_USER=agent AGENTENV_EGRESS_NSS=off \
/usr/local/lib/agentenv-egress/egress boot > /var/log/agentenv-root/egress-boot.log 2>&1 \
|| { cat /var/log/agentenv-root/egress-boot.log >&2; echo "the egress proxy's boot failed" >&2; exit 2; }
exec supervisord -c /etc/agentenv/root.conf
Loading
Loading