Skip to content

feat(agents): Antigravity agent on the env's clock - #925

Open
earakely-scale wants to merge 1 commit into
mainfrom
edgararakelyan/fd-6998-antigravity-agent
Open

earakely-scale wants to merge 1 commit into
mainfrom
edgararakelyan/fd-6998-antigravity-agent

Conversation

@earakely-scale

@earakely-scale earakely-scale commented Nov 25, 2026 •

Copy link
Copy Markdown
Collaborator

What

A bundled Antigravity agent: Google's Antigravity SDK (google-antigravity==0.1.24) behind the protocol's A2A agent framework, at @local/agentenv-framework/agents/antigravity (alias antigravity), with a smoke task and a published image (agentenv-antigravity). It follows the env's clock like the other clocked agents. The hub's antigravity-carbon is out of tree; this is the in-tree one FD-6998 asks for.

  • Each turn is one Agent.chat() in the A2A server's process. A context's later turns resume its SDK conversation.
  • The env's MCP servers are the SDK's streamable-HTTP servers, with the run's AgentEnv-Role and timeouts of 60 s and 300 s.
  • The trajectory is antigravity-sdk/1, served live. It holds the streamed steps, each step's text and thought as one record, and each tool call. Each call's result, which only the SDK's hooks see, follows its call with call_ref.
  • Extensions: agent-config, mcp-config, skill-config (an inline SKILL.md without frontmatter gets one, since the SDK lists skills by frontmatter), trajectory, snapshot (conversation store, env times and /app, plus the changelog where tar is GNU tar), peer-agents, triggers, attribution-probe, install/v1 (container or host), clock/v1.

FD-6998's asks, for this agent

  • Usage is reported. The SDK's harness sends no key, so each turn's harness calls a model relay of its own (model_relay.py, shared). The relay adds the key, [model.headers] and the run's attribution, and counts usage from every call the harness makes, subagents included.
  • Web tools can be turned off. builtin_tools selects the SDK's own tools, so {"disable": ["search_web", "read_url_content"]} turns the web tools off; ask_question and generate_image are always off and finish always on.
  • Transient 502s and EOFs. The SDK retries a model call the endpoint answers with a transient error six times, from 5 s, doubling. An MCP server that fails to start fails the turn with mcp_load_failed as an infra error.
  • Not here: the hub's proxy route for gemini/gemini-4-carbon and the <end_of_image> text, which come from that model and the out-of-tree agent.

The env's clock

The harness (localharness) is a static Go binary, which libfaketime can't reach. So it, and its conversation store, stay on real time at any env date, while the commands it starts follow the clock and go out through the egress proxy.

The model sees the harness's clock in two places. While the clock is armed, the relay rewrites both:

  • the The current local time is: … line in each turn's message, which gets the env's time from date;
  • the Created At: / Completed At: stamps on each command result, which shift by the env's offset when the relay first sees them, so a command keeps its duration.

Each rewrite is recorded beside the conversations, keyed by the time and the message it's in, so a resumed conversation sends its history unchanged. A call whose env time can't be read is refused rather than sent with the machine's time.

Found by the e2e tests and fixed here

  • The real-SDK integration test (antigravity_env_date_test.py) found two leaks:
    • Turns that start in the same second shared a key, so the later one was told the earlier one's env time.
    • Command results carried the harness's real Created At / Completed At.
  • Trajectory linking: the harness's own skill lookup streams its call and reports its result to the hooks, but the hooks never decide it. Ordinal linking therefore tied every later result to the wrong call. Results are now tied by name, and undecided calls in order.

Testing (agent-environments-admin VM; the agent's turns on its default, Sonnet 5.5)

  • Unit: 113 new tests under tst/unit/agents/antigravity with an SDK stand-in. The cross-agent tests are extended. The full tst/unit and protocol suites give 19,629 passed and 4 failed; those 4 fail the same way on main on that VM, which has no unzip. ruff is clean.
  • Integration: tst/integration/agent/antigravity_env_date_test.py runs the pinned SDK against fake_openai. It checks:
    • the harness is a static binary;
    • the SDK's tools are AntigravityTool plus the three it can't select;
    • on an armed clock, no machine date appears in any model call across run_command, list_skills and view_file;
    • a resumed turn's history keeps its env time;
    • results are tied to their calls;
    • usage is counted per call. 5/5 pass.
  • Validator (a2a-agent validate): agent-config, mcp-config, skill-config, trajectory, peer-agents, snapshot (save, load and changelog) and install/v1 all supported. clock/v1 is synced and follows writes.
  • Bundle smoke: agent-env run agents --task antigravity-smoke passes. The image is also registered with Dependabot and in the release's image list and smoke checks.
  • Clock chaos (mail env, require_agent_clock): two concurrent rounds each passed 15/15. A first solo round passed 14/15; the one miss was my probe, which couldn't read /proc as root, and it passes in the concurrent rounds. The scenarios:
    • a frozen date in the shell and in the local-time line;
    • jumps forward and back between turns, with the conversation's history in order;
    • a clock before 1970;
    • 3600× rate;
    • a jump while a turn runs;
    • the harness keeping real time while what it starts follows the clock;
    • the store's real mtimes;
    • the follower and the egress proxy killed with -9, then an MCP tool turn;
    • teardown retiring the follower;
    • the A2A server killed with -9, which stops the container.
  • Promotion-gate replica (mail env, Claude Code judge): scored 1.0, with usage reported (3 model calls, 59,550 input tokens, $0.12).
  • install/v1 matrix: each target installs and answers 42 through its shell tool: bare ubuntu:24.04 (certifi's CAs), python:3.12-slim (its own), debian:bookworm-slim, trust lines that name a bundle, and the VM host.

Known, as with OpenCode's CLI: files the harness's own file tools write carry real mtimes, since the harness is on real time.

🤖 Generated with Claude Code

RetriggerView in GreptileConfidence Score: 2/5

Fix conversation recovery, image history, and snapshot isolation before merging, and satisfy the named-limit requirement.

Fix All in CursorFindings

  1. P1 Timed-out turns lose their conversation ▶
  2. P1 Earlier images disappear ▶
  3. P1 Restored contexts share history ▶
  4. P2 Repeated prompts reuse old time ▶
  5. P2 Smoke check skips the harness ▶
  6. P2 Registered skills can stay hidden ▶
  7. P2 Fallback limit lacks a name ▶
Fix with agent prompt
### Issue 1
src/agent_env/agents/agents/antigravity/antigravity_bridge.py:425-426
When a context's first turn times out, `_turn` returns the incoming `session_id`, which is `None`. It reads `agent.conversation_id` only after the stream finishes. The next turn therefore starts over, even if the first turn already ran commands and changed files. The SDK-error path has the same problem.

Capture the new conversation ID before draining the stream and preserve it on failure.

### Issue 2
src/agent_env/agents/agents/antigravity/antigravity_bridge.py:194-201
On the next turn, the model's history no longer contains the earlier image parts. The SDK store never receives the injected images, and each new relay receives only the current turn's attachments. A follow-up such as “read the other label in that image” therefore sends the earlier message without its image.

Save the attachment-to-message mapping with the conversation and restore those parts in later requests.

### Issue 3
src/agent_env/agents/agents/antigravity/a2a_server.py:428-431
Loading a snapshot into another context on the same agent replaces the source conversation's store and binds both contexts to it. Later turns can then run concurrently against one conversation because their context locks are separate. Restoring an older snapshot also rolls back the source's history.

Import under a fresh conversation ID, or reject loads whose archived ID is already bound.

### Issue 4
src/agent_env/agents/agents/antigravity/antigravity_date.py:121-124
`line_key` still gives identical messages started in the same second the same key. At an accelerated clock rate, or after a clock change, the later message can reuse the earlier env time without reading `date`. The existing test varies the prompt text, so it misses this case.

Include a stable turn identity in the key and test identical messages with the same harness timestamp.

### Issue 5
.github/scripts/infra_build.py:124-125
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.

### Issue 6
src/agent_env/agents/agents/antigravity/antigravity_kit.py:83-84
`with_frontmatter` treats any text starting with `---` as existing frontmatter. A Markdown body starting with a horizontal rule, such as `---\n\n# Report`, therefore gets no generated name or description. Registration succeeds, but the SDK cannot discover the skill through those fields.

Check for a complete frontmatter block rather than just its opening characters.

### Issue 7
src/agent_env/agents/agents/antigravity/antigravity_bridge.py:335
The new fallback uses an unnamed `2000` character limit. The repository requires magic numbers to be stored under descriptive names; this requirement must be satisfied before merging. Give this limit a named constant, as the module already does with `ERROR_MESSAGE_LIMIT`. The digest length in `line_key` is another instance of the same pattern.

---

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

Summary

Adds the bundled Antigravity agent, its model relay wiring, env-clock rewrites, snapshots, installation scripts, and tests.

  • Antigravity runs as an A2A agent and resumes its conversation between turns.
  • Antigravity model calls use the env’s clock while conversation history keeps its original times.
  • The Antigravity bundle can be installed, selected, and published with the other agent images.

Known limitation acknowledged by earakely-scale: files written by the harness's own file tools carry real mtimes because the harness runs on real time.

Diagram

sequenceDiagram
  participant Caller
  participant Server as A2A server
  participant SDK as Antigravity harness
  participant Relay as Turn model relay
  participant Model
  Caller->>Server: Send message and attachments
  Server->>SDK: Start or resume conversation
  SDK->>Relay: Model request
  Relay->>Relay: Rewrite time and add current images
  Relay->>Model: Add credentials and attribution
  Model-->>Relay: Response and usage
  Relay-->>SDK: Model response
  SDK-->>Server: Stream steps and tool hooks
  Server-->>Caller: Answer, trajectory, and usage
Loading

Reviews (1) · Last reviewed commit: "feat(agents): Antigravity agent on the e..." · Reviewed by Greptile

Google's Antigravity SDK (google-antigravity 0.1.24) behind the protocol's A2A agent framework, shipped in the agents
bundle as @local/agentenv-framework/agents/antigravity with the alias antigravity, a smoke task and a published image.
Each turn is one Agent.chat() in the server's process, resumed in the context's SDK conversation; the env's MCP servers
are its streamable-HTTP servers; its streamed steps, with each tool result from the SDK's hooks, are the trajectory
(antigravity-sdk/1).

The SDK's harness sends no key, so a model relay of the turn's own adds the endpoint's key, [model.headers] and the
run's attribution, and counts usage from every call, which the SDK doesn't report. builtin_tools selects the SDK's own
tools, so a task can turn its web tools off. The SDK retries a model call the endpoint answers with a transient error.

The image follows the env's clock as the other clocked agents do. The harness is a static binary libfaketime can't
reach, so it stays on real time with its conversation store; on an armed clock the relay puts the env's time in the
local-time line of each turn's message and shifts the stamps on each command's result, and records what each was
given, so a resumed conversation's history keeps its times. install/v1 installs it into a container or onto a host.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@socket-security

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addedpypi/​google-antigravity@​0.1.2497100100100100

View full report

Comment on lines +425 to +426
return AntigravityResult(session_id=session_id, tool_call_count=recorder.tool_calls, error_code="timeout",
error=f"the turn ran past its {timeout_s} s")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Timed-out turns lose their conversation

When a context's first turn times out, _turn returns the incoming session_id, which is None. It reads agent.conversation_id only after the stream finishes. The next turn therefore starts over, even if the first turn already ran commands and changed files. The SDK-error path has the same problem.

Capture the new conversation ID before draining the stream and preserve it on failure.

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/agent_env/agents/agents/antigravity/antigravity_bridge.py
Line: 425-426

Comment:
**Timed-out turns lose their conversation**

When a context's first turn times out, `_turn` returns the incoming `session_id`, which is `None`. It reads `agent.conversation_id` only after the stream finishes. The next turn therefore starts over, even if the first turn already ran commands and changed files. The SDK-error path has the same problem.

Capture the new conversation ID before draining the stream and preserve it on failure.

---

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

Comment on lines +194 to +201
def _with_media(request: dict, media: list[dict]) -> bool:
"""Add ``media`` to the request's last user message, the turn's own, unless they're there already: the harness
sends the turn's history again on each call, from a store that never saw them. Whether it changed the request."""
users = [message for message in request.get("messages") or [] if isinstance(message, dict)
and message.get("role") == "user"]
if not users or not media:
return False
message = users[-1]

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Earlier images disappear

On the next turn, the model's history no longer contains the earlier image parts. The SDK store never receives the injected images, and each new relay receives only the current turn's attachments. A follow-up such as “read the other label in that image” therefore sends the earlier message without its image.

Save the attachment-to-message mapping with the conversation and restore those parts in later requests.

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/agent_env/agents/agents/antigravity/antigravity_bridge.py
Line: 194-201

Comment:
**Earlier images disappear**

On the next turn, the model's history no longer contains the earlier image parts. The SDK store never receives the injected images, and each new relay receives only the current turn's attachments. A follow-up such as “read the other label in that image” therefore sends the earlier message without its image.

Save the attachment-to-message mapping with the conversation and restore those parts in later requests.

---

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

Comment on lines +428 to +431
await asyncio.to_thread(_restore_conversation, staged_conversation, conversation_id)
if staged is not None:
await asyncio.to_thread(_replace_workspace, staged)
self.set_session_ref_for_context(target_context_id, conversation_id)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Restored contexts share history

Loading a snapshot into another context on the same agent replaces the source conversation's store and binds both contexts to it. Later turns can then run concurrently against one conversation because their context locks are separate. Restoring an older snapshot also rolls back the source's history.

Import under a fresh conversation ID, or reject loads whose archived ID is already bound.

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/agent_env/agents/agents/antigravity/a2a_server.py
Line: 428-431

Comment:
**Restored contexts share history**

Loading a snapshot into another context on the same agent replaces the source conversation's store and binds both contexts to it. Later turns can then run concurrently against one conversation because their context locks are separate. Restoring an older snapshot also rolls back the source's history.

Import under a fresh conversation ID, or reject loads whose archived ID is already bound.

---

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

Comment on lines +121 to +124
def line_key(text: str, real: str) -> str:
"""A local-time line's or a command result's key: its time and the message text it is in, so two turns that start
in one second keep their own env times."""
return f"{real}#{hashlib.sha256(text.encode('utf-8', 'surrogatepass')).hexdigest()[:16]}"

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 Repeated prompts reuse old time

line_key still gives identical messages started in the same second the same key. At an accelerated clock rate, or after a clock change, the later message can reuse the earlier env time without reading date. The existing test varies the prompt text, so it misses this case.

Include a stable turn identity in the key and test identical messages with the same harness timestamp.

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/agent_env/agents/agents/antigravity/antigravity_date.py
Line: 121-124

Comment:
**Repeated prompts reuse old time**

`line_key` still gives identical messages started in the same second the same key. At an accelerated clock rate, or after a clock change, the later message can reuse the earlier env time without reading `date`. The existing test varies the prompt text, so it misses this case.

Include a stable turn identity in the key and test identical messages with the same harness timestamp.

---

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

Comment on lines +124 to +125
"agentenv-antigravity": ["docker", "run", "--rm", "--entrypoint", "sh", "{image}", "-c",
'python -c "import a2a_server"'],

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

Comment on lines +83 to +84
if skill_md.lstrip().startswith("---"):
return skill_md

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 Registered skills can stay hidden

with_frontmatter treats any text starting with --- as existing frontmatter. A Markdown body starting with a horizontal rule, such as ---\n\n# Report, therefore gets no generated name or description. Registration succeeds, but the SDK cannot discover the skill through those fields.

Check for a complete frontmatter block rather than just its opening characters.

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/agent_env/agents/agents/antigravity/antigravity_kit.py
Line: 83-84

Comment:
**Registered skills can stay hidden**

`with_frontmatter` treats any text starting with `---` as existing frontmatter. A Markdown body starting with a horizontal rule, such as `---\n\n# Report`, therefore gets no generated name or description. Registration succeeds, but the SDK cannot discover the skill through those fields.

Check for a complete frontmatter block rather than just its opening characters.

---

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

return json.loads(json.dumps(dump(mode="json", exclude={"exception"}), default=str))
except Exception: # noqa: BLE001 - a result's value may be anything
return {key: str(item) for key, item in dump(warnings=False).items() if key != "exception"}
return {"repr": str(value)[:2000]}

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 Fallback limit lacks a name

The new fallback uses an unnamed 2000 character limit. The repository requires magic numbers to be stored under descriptive names; this requirement must be satisfied before merging. Give this limit a named constant, as the module already does with ERROR_MESSAGE_LIMIT. The digest length in line_key is another instance of the same pattern.

Rule Used: Store magic numbers as class or instance variables with descriptive names rather than using them inline in the code. (source)

Learned From
scaleapi/scaleapi#126388

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/agent_env/agents/agents/antigravity/antigravity_bridge.py
Line: 335

Comment:
**Fallback limit lacks a name**

The new fallback uses an unnamed `2000` character limit. The repository requires magic numbers to be stored under descriptive names; this requirement must be satisfied before merging. Give this limit a named constant, as the module already does with `ERROR_MESSAGE_LIMIT`. The digest length in `line_key` is another instance of the same pattern.

**Rule Used:** Store magic numbers as class or instance variables with descriptive names rather than using them inline in the code. ([source](https://app.greptile.com/-/switch-tenant?tenant=scale-ai&next=%2Fcustom-context%3Fmemory%3D002e0051-41ad-46c1-9098-47433c580150))

**Learned From**
[scaleapi/scaleapi#126388](https://github.com/scaleapi/scaleapi/pull/126388)

---

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

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Fix in Cursor Fix in Claude Code Fix in Codex

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant