Repository navigation
feat(agents): Antigravity agent on the env's clock #925
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
earakely-scale
wants to merge
1
commit into
main
Choose a base branch
from
edgararakelyan/fd-6998-antigravity-agent
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+3,741
−11
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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. |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new image smoke command only imports
a2a_server; it never startslocalharness, 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