Repository navigation
feat(agents): Antigravity agent on the env's clock - #925
earakely-scale wants to merge 1 commit into
Conversation
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>
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
| 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") |
There was a problem hiding this 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.
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.| 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] |
There was a problem hiding this comment.
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.| 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) |
There was a problem hiding this 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.
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.| 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]}" |
There was a problem hiding this 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.
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.| "agentenv-antigravity": ["docker", "run", "--rm", "--entrypoint", "sh", "{image}", "-c", | ||
| 'python -c "import a2a_server"'], |
There was a problem hiding this comment.
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.| if skill_md.lstrip().startswith("---"): | ||
| return skill_md |
There was a problem hiding this 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.
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.| 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]} |
There was a problem hiding this comment.
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!
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(aliasantigravity), with a smoke task and a published image (agentenv-antigravity). It follows the env's clock like the other clocked agents. The hub'santigravity-carbonis out of tree; this is the in-tree one FD-6998 asks for.Agent.chat()in the A2A server's process. A context's later turns resume its SDK conversation.AgentEnv-Roleand timeouts of 60 s and 300 s.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 withcall_ref.SKILL.mdwithout 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
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.builtin_toolsselects the SDK's own tools, so{"disable": ["search_web", "read_url_content"]}turns the web tools off;ask_questionandgenerate_imageare always off andfinishalways on.mcp_load_failedas an infra error.gemini/gemini-4-carbonand 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 current local time is: …line in each turn's message, which gets the env's time fromdate;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
antigravity_env_date_test.py) found two leaks:Created At/Completed At.Testing (agent-environments-admin VM; the agent's turns on its default, Sonnet 5.5)
tst/unit/agents/antigravitywith an SDK stand-in. The cross-agent tests are extended. The fulltst/unitand protocol suites give 19,629 passed and 4 failed; those 4 fail the same way onmainon that VM, which has nounzip. ruff is clean.tst/integration/agent/antigravity_env_date_test.pyruns the pinned SDK againstfake_openai. It checks:AntigravityToolplus the three it can't select;run_command,list_skillsandview_file;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.agent-env run agents --task antigravity-smokepasses. The image is also registered with Dependabot and in the release's image list and smoke checks.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/procas root, and it passes in the concurrent rounds. The scenarios:-9, then an MCP tool turn;-9, which stops the container.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
Fix conversation recovery, image history, and snapshot isolation before merging, and satisfy the named-limit requirement.
Fix with agent prompt
Summary
Adds the bundled Antigravity agent, its model relay wiring, env-clock rewrites, snapshots, installation scripts, and tests.
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
Reviews (1) · Last reviewed commit: "feat(agents): Antigravity agent on the e..." · Reviewed by Greptile