Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ updates:
- "/src/agent_env/env/gateway"
- "/src/agent_env/env/envs/service_db"
- "/src/agent_env/env/envs/playwright_mcp"
- "/src/agent_env/agents/agents/antigravity"
- "/src/agent_env/agents/agents/browser-use"
- "/src/agent_env/agents/agents/claude-code"
- "/src/agent_env/agents/agents/codex"
Expand Down
5 changes: 4 additions & 1 deletion .github/scripts/infra_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
"agentenv-db-web": "src/agent_env/env/envs/service_db/Dockerfile.db-web",
"agentenv-db-mcp": "src/agent_env/env/envs/service_db/Dockerfile.db-mcp",
"agentenv-playwright-mcp": "src/agent_env/env/envs/playwright_mcp/Dockerfile",
"agentenv-antigravity": "src/agent_env/agents/agents/antigravity/Dockerfile",
"agentenv-browser-use": "src/agent_env/agents/agents/browser-use/Dockerfile",
"agentenv-claude-code": "src/agent_env/agents/agents/claude-code/Dockerfile",
"agentenv-codex": "src/agent_env/agents/agents/codex/Dockerfile",
Expand Down Expand Up @@ -108,7 +109,7 @@

# Each image's check, beyond its build: the gateway imports its server, Postgres turns healthy, the sidecars and the
# browser answer their own commands, Claude Code's, Codex's, Gemini's, Hermes', OpenCode's and pi's agents run their
# CLIs and import their servers, OpenHands' imports its server, which loads the OpenHands SDK, Pydantic AI's imports its
# CLIs and import their servers, Antigravity's runs its SDK's harness and imports its server, OpenHands' imports its server, which loads the OpenHands SDK, Pydantic AI's imports its
# server, which loads Pydantic AI, Browser Use's loads browser-use in its own environment and imports its server, the proxy imports its
# server, the mail example's env imports its server, and the base computer's desktop comes up, every program running.
_SMOKES = {
Expand All @@ -120,6 +121,8 @@
" && ls -d /root/.cache/ms-playwright/chromium-*"],
"agentenv-claude-code": ["docker", "run", "--rm", "--entrypoint", "sh", "{image}", "-c",
'claude --version && python -c "import a2a_server"'],
"agentenv-antigravity": ["docker", "run", "--rm", "--entrypoint", "sh", "{image}", "-c",
'python -c "import a2a_server"'],
Comment on lines +124 to +125

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Smoke check skips the harness

The new image smoke command only imports a2a_server; it never starts localharness, despite the changed comment saying it does. Imports cannot catch a missing or unusable bundled binary on either published CPU type. Add a no-model harness startup check so a broken binary cannot pass the release smoke check.

Prompt To Fix With AI
This is a comment left during a code review.
Path: .github/scripts/infra_build.py
Line: 124-125

Comment:
**Smoke check skips the harness**

The new image smoke command only imports `a2a_server`; it never starts `localharness`, despite the changed comment saying it does. Imports cannot catch a missing or unusable bundled binary on either published CPU type. Add a no-model harness startup check so a broken binary cannot pass the release smoke check.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Fix in Cursor Fix in Claude Code Fix in Codex

"agentenv-browser-use": ["docker", "run", "--rm", "--entrypoint", "sh", "{image}", "-c",
'/opt/browser-use/bin/python -c "import agent" && python -c "import a2a_server"'],
"agentenv-codex": ["docker", "run", "--rm", "--entrypoint", "sh", "{image}", "-c",
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ the previous release, so a clear pull request title is also the release note. A

A release also publishes the infra images agent-env ships, once the `PUBLISH_INFRA_IMAGES` repository variable is
`true`: one per Dockerfile under `src/agent_env/env`, and one per shipped agent (`agentenv-claude-code`, its CLI
included, `agentenv-codex`, `agentenv-gemini`, `agentenv-hermes`, `agentenv-opencode`, `agentenv-pi`, `agentenv-openhands` and `agentenv-pydantic-ai`), at `ghcr.io/scaleapi/agentenv-<name>:src-<hex>` for linux/amd64
included, `agentenv-codex`, `agentenv-gemini`, `agentenv-hermes`, `agentenv-opencode`, `agentenv-antigravity`, `agentenv-pi`, `agentenv-openhands` and `agentenv-pydantic-ai`), at `ghcr.io/scaleapi/agentenv-<name>:src-<hex>` for linux/amd64
and linux/arm64, where the tag is the build context's source digest, so an unchanged Dockerfile is not built again.
The agents' images install the newest `agentenv-framework-protocol` at or above the floor in their
`requirements.txt`, which a release doesn't pin, so each is built again only when its folder changes: once the protocol
Expand Down
20 changes: 17 additions & 3 deletions src/agent_env/agents/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ The A2A server starts with the real-time marker, so it and its records stay on r
websearch tool's year, and the CLI enables no provider but the endpoint, so no call bypasses the relay. A call whose
date the relay can't read or place is refused, so the turn fails rather than tell the model the machine's date
(`opencode_date.py`).
- **Antigravity's harness on real time.** The Antigravity SDK's harness is a static Go binary, which libfaketime can't
reach, so it keeps real time while the commands it runs read the env's. While the clock is armed, the turn's model
relay puts the env's time, read from `date`, in the "The current local time is" line the harness opens each user
message with, and keeps the time each turn was given, so a resumed conversation's history doesn't change
(`antigravity_date.py`). A call whose time it can't read is refused.
- **For the rest of the run.** An agent that follows goes on following: a later `sync_env_clock` without `agent_clock`
re-arms the clock it follows, and only agents that never followed keep real time.
- **Through the egress proxy.** While the agent follows an armed clock, the CLI goes out through the egress proxy, which
Expand Down Expand Up @@ -118,6 +123,15 @@ OpenAI-compatible one, `<base>/v1/chat/completions`, and takes its model from th
`anthropic/claude-sonnet-5-5`. It declares `install/v1` too, into a container or onto a `vm` sandbox's Linux host,
with glibc. Its folder's `README.md` covers the extensions it implements.

`agents/antigravity/` runs Google's [Antigravity SDK](https://pypi.org/project/google-antigravity/) behind the
protocol's A2A agent framework, in process rather than a CLI: each turn is one `Agent.chat()` of the SDK, resumed in the
context's SDK conversation, the task env's MCP servers are its streamable-HTTP servers, and its streamed steps, with each
tool call's result from the SDK's hooks, are the turn's trajectory. Name it as `antigravity`, its alias, or by its id,
`@local/agentenv-framework/agents/antigravity`. Its harness calls the `[model]` endpoint as an OpenAI-compatible one,
`<base>/v1/chat/completions`, through a relay that adds the key and the run's attribution and counts usage, and takes
its model from the prompt, else `anthropic/claude-sonnet-5-5`. It declares `install/v1` too, into a container or onto a
`vm` sandbox's Linux host, with glibc. Its folder's `README.md` covers the extensions it implements.

`agents/letta-code/` runs [Letta Code](https://github.com/letta-ai/letta-code) behind the protocol's A2A agent
framework: each turn is one `letta --backend local -p --output-format stream-json` run, resumed in the context's
conversation, with a separate local agent and memory per context. Name it as `letta-code`, its alias, or by its id,
Expand Down Expand Up @@ -160,8 +174,8 @@ it as `hermes`, its alias, or by its id, `@local/agentenv-framework/agents/herme
an OpenAI-compatible one, `<base>/v1/chat/completions`, and takes its model from the prompt, else
`anthropic/claude-sonnet-4-6`. Its folder's `README.md` covers the extensions it implements.

A release publishes Codex's, Gemini's, Hermes', OpenCode's, pi's, OpenHands' and Pydantic AI's images too, at
`ghcr.io/scaleapi/agentenv-codex:src-<hex>`, `ghcr.io/scaleapi/agentenv-gemini:src-<hex>`,
A release publishes Antigravity's, Codex's, Gemini's, Hermes', OpenCode's, pi's, OpenHands' and Pydantic AI's images
too, at `ghcr.io/scaleapi/agentenv-antigravity:src-<hex>`, `ghcr.io/scaleapi/agentenv-codex:src-<hex>`, `ghcr.io/scaleapi/agentenv-gemini:src-<hex>`,
`ghcr.io/scaleapi/agentenv-hermes:src-<hex>`, `ghcr.io/scaleapi/agentenv-opencode:src-<hex>`, `ghcr.io/scaleapi/agentenv-pi:src-<hex>`,
`ghcr.io/scaleapi/agentenv-openhands:src-<hex>` and `ghcr.io/scaleapi/agentenv-pydantic-ai:src-<hex>`, each built again only when its folder changes, and a run deploys
them as it does Claude Code's: it pulls the image
Expand All @@ -179,4 +193,4 @@ others'. It has no alias and no smoke task: with nobody driving it, a prompt onl

`agent-env run agents` runs every agent's smoke task, pulling or building each image; `--task claude-code-smoke` runs
Claude Code's alone, `--task codex-smoke` Codex's, `--task gemini-smoke` Gemini's, `--task hermes-smoke` Hermes', `--task opencode-smoke` OpenCode's,
`--task pi-smoke` pi's, `--task openhands-smoke` OpenHands', `--task pydantic-ai-smoke` Pydantic AI's.
`--task antigravity-smoke` Antigravity's, `--task pi-smoke` pi's, `--task openhands-smoke` OpenHands', `--task pydantic-ai-smoke` Pydantic AI's.
59 changes: 59 additions & 0 deletions src/agent_env/agents/agents/antigravity/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# 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 renders a PDF attachment to the page images the model sees; git and curl are for the model's commands.
RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates curl git poppler-utils \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /opt/agent
# The Antigravity SDK, whose wheel for this CPU holds its harness, a static Go binary, with the agent's other
# requirements.
COPY requirements.txt ./
RUN pip install --no-cache-dir -r 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 antigravity_bridge.py antigravity_date.py antigravity_kit.py entrypoint.sh install.sh run.sh ./
# Every clocked agent's egress rule, which the bridge imports, the clock page's format it reads, and the model relay
# that counts the turn's model calls (shared_sources.toml).
COPY agent_clock/agent_egress.py clock/clockpage.py model_relay/model_relay.py ./
# The agent's workspace, /app, and its home under /data, fixed so neither follows the uid.
RUN useradd --create-home --uid 10001 agent && mkdir -p /app /data \
&& chown agent:agent /app /data && 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
ENV A2A_PORT=8000 PYTHONPATH=/opt/agent HOME=/data
WORKDIR /app
EXPOSE 8000
# Starts as root, which start-agent needs for the clock; the A2A server and the harness 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"]
65 changes: 65 additions & 0 deletions src/agent_env/agents/agents/antigravity/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Antigravity A2A agent

Google's [Antigravity SDK](https://pypi.org/project/google-antigravity/) (`google-antigravity`) wrapped with the
`agentenv_protocol.a2a_agent` framework, shipped in the `agents` bundle as
`@local/agentenv-framework/agents/antigravity`. This directory is the whole build context: the protocol package and the
SDK, whose wheel holds its harness, come from PyPI (`requirements.txt`).

Each task is one `Agent.chat()` of the SDK in the A2A server's process, in `/app`. The SDK runs its own harness,
`localharness`, a static Go binary that runs the tools and calls the model. A context's first task starts an SDK
conversation, and each later task resumes it by its id; the SDK keeps each conversation in a SQLite store under
`$ANTIGRAVITY_HOME/conversations/`. Text parts are the prompt, and file parts are written under `/app/inputs/<task>/`
and named in it; an image goes to the model inline too, and a PDF as its pages' PNGs, rendered with `pdftoppm`. Turns of
different contexts run at once, a context's turns one at a time.

The SDK's `LocalOpenAIAgentConfig` takes a chat-completions `base_url` and nothing else for the endpoint, and its
harness sends no key, so each task's harness calls a model relay of the task's own on loopback (`model_relay.py`,
shared with other agents), which forwards each call to `$LITELLM_BASE_URL/v1/chat/completions` with:

- the endpoint's key from `LITELLM_API_KEY`, `[model.headers]` (`LITELLM_EXTRA_HEADERS`) and the run's `project_id` and
`task_id` as `x-litellm-customer-id` and `x-litellm-tags`. The run's tags join an `x-litellm-tags` that
`[model.headers]` names;
- the task's `effort` as `reasoning_effort` (`xhigh` and `max` as `high`) and its images, which the SDK has no setting
for;
- the env's time in the harness's "The current local time is" line while the agent follows an armed clock (below).

The relay counts each call from the answer's usage, every subagent's included, so the task's `Usage` is their sum; the
SDK reports none. A call answered without usage is counted in `unreported_calls`.

The rest of each task's config:

- the task's `system_prompt`, as the SDK's `system_instructions`, a section after the harness's own;
- the model: the task's, else `ANTIGRAVITY_MODEL`, else `anthropic/claude-sonnet-5-5`;
- every registered MCP server, the task's `peer_agents` tools included, as a streamable-HTTP server. Its
`AgentEnv-Role` header is the role its registration names, unless the task has a role of its own;
- every tool call allowed (`policy.allow_all()`), autonomous behaviour, `ask_question` and `generate_image` off, and the
SDK's own retries of a model call the endpoint answers with a transient error: six, from 5 s, doubling.

| Extension | Implementation |
|---|---|
| `agent-config/v1` | `AntigravityConfig`: `model`, `effort`, `system_prompt`, `project_id`, `task_id`, `timeout_seconds` (1800 by default; past it the task fails with `timeout`), `max_turns` (the model calls a task may make, the SDK's `max_model_calls`; a task stopped at it fails with `max_turns_exceeded`), `builtin_tools` (below) |
| `mcp-config/v1` | SDK default; each server passed to the task's harness. One that fails to start fails the task with `mcp_load_failed`, an infra error |
| `skill-config/v1` | inline and bundle skills installed as `$ANTIGRAVITY_HOME/skills/<name>/`, the harness's skills path; an inline `SKILL.md` without frontmatter gets one from the skill's name and description, since the SDK lists a skill by its frontmatter alone |
| `trajectory/v1` | the SDK's streamed steps, a step's text and thought each as one record, and each tool call's result from the SDK's hooks after it, live while the task runs (format `antigravity-sdk/1`) |
| `snapshot/v1` | `save` archives the context's conversation store with the env times its turns were given, and `/app`, once no task runs; `load` restores the store under its own id, bound to the target context, and replaces `/app`'s contents. Where `tar` is GNU tar, the changelog too: an incremental archive of its roots after each task, uploaded through the namespace grant, and applied in order; an increment is a whole task's changes, since the harness has no hook this agent can hold a task at |
| `peer-agents/v1` | SDK default: the harness reaches the task's other agents through the SDK's `peer_agents` MCP tools |
| `triggers/v1` | SDK default |
| `attribution-probe/v1` | the `project_id` and `task_id` the last task sent |
| `install/v1` | `install.sh`, into a task container (as root, working in `/app`) or onto a `vm` sandbox's Linux host: uv checked against its checksum and the agent's requirements in a Python of its own, which the target's own Python is never replaced by. The SDK's wheels need glibc on x86_64 or aarch64 |

The image is `python:3.11-slim` with `pdftoppm`, git, the SDK and the agent, running as the `agent` user, its `HOME`
`/data`.

**The env's clock.** The image follows the env's clock as the other clocked agents do (the agents' README). The harness
is a static binary, which agent-env's libfaketime can't reach, so it keeps real time and its conversation store stays in
order at any env date, while the commands it runs read the env's time and go out through the egress proxy. The model
sees the time only in the line the harness opens each user message with, "The current local time is: <RFC 3339>.":
while the clock is armed, the relay puts the env's time there, read from `date`, and records it beside the
conversations, so a resumed conversation's earlier turns keep the time each was given (`antigravity_date.py`). A call
whose time the relay can't read is refused, so the task fails rather than tell the model the machine's time.

A `deploy_agent` `builtin_tools` selection picks the SDK's own tools: `{"disable": "*"}` and `{"only": [...]}` turn off
every tool but those named, a list to turn off turns off those alone; the tools of the MCP servers agent-env gives the
agent stay in every case, `finish`, which ends a task, stays on, and `ask_question` and `generate_image` stay off. The
names are `AntigravityTool`'s in `antigravity_bridge.py`, the SDK's own: `search_web` and `read_url_content` are its
web tools. A test fails when `requirements.txt`'s SDK pin moves, until `SDK_VERSION` moves with it.
Loading
Loading