Skip to content

feat(antigravity): add Gemini API Managed Agents image - #30

Merged
rakyll merged 10 commits into
mainfrom
feat/antigravity-managed-agents
Nov 24, 2026
Merged

rakyll merged 10 commits into
mainfrom
feat/antigravity-managed-agents

Conversation

@rakyll

@rakyll rakyll commented Nov 23, 2026 •

Copy link
Copy Markdown
Collaborator

Adds a top-level antigravity/ image that runs a Gemini API Managed Agent (Antigravity by default) as an AX task. The agent loop runs in the Gemini API, and every tool call runs inside the task's sandbox.

How it works

For each task, the Go launcher ax-antigravity:

  1. Creates a self-hosted environment.
  2. Runs gemini-api environments connect (v0.5.0) in the task's workspace to execute the agent's tool calls.
  3. Creates a background interaction from spec.config and polls it to completion.
  4. Writes the answer to <workspace>/.ax/output.

API calls go through the Gemini API Go SDK (google.golang.org/genai v1.79.1).

  • Config: spec.config holds the interaction request fields under camelCase keys: agent, inputs (a list of strings), previousInteractionId, systemInstruction, tools, agentConfig, … Harness options are timeout, commandTimeout, disableBash and outputFile. These keys are rejected: snake_case keys, fields the API deprecated, and fields the harness sets itself. Setting both inputs and spec.goal.text is an error.
  • Suspend and resume: on SIGTERM the harness leaves the interaction running and exits 143. The relaunched harness reattaches to it, and a relaunch after success does nothing.
  • Keys: GEMINI_API_KEY is stripped from the tool worker's environment. The worker gets only the environment key.
  • Launcher path: /usr/local/bin/ax-harness is a symlink to ax-antigravity, so Tasks with spec.goal still start. Renaming that default is Rename the default image launcher from ax-harness to ax-launcher google/ax#711.

Testing

  • go test -race ./...: tests against a fake Gemini API and a fake worker, covering defaults, request fields, inputs, sessions, continuation, failures, worker crashes, reattach and suspend/resume.
  • The Docker image build has not been run yet.

Open questions

  • Image name: ghcr.io/agentexecutor/antigravity is already used by agents/antigravity. Should this replace it, or get a different name?
  • CI: no CI workflow or release catalog entry yet. Both depend on the naming decision.

Add a top-level antigravity image whose Go launcher, ax-antigravity, runs a
Gemini API Managed Agent with its tools executed in the task's sandbox. For
each task it creates a self-hosted environment, runs gemini-api environments
connect in /workspace, and creates a background interaction from spec.config
through the Gemini API Go SDK. A relaunch after a suspend reattaches to the
running interaction.
@rakyll
rakyll marked this pull request as ready for review November 23, 2026 01:30

@mayawang mayawang left a comment

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.

Is top-level antigravity/ intentional, or should this live under agents/ like agents/antigravity? I'd lean toward a separate image name like antigravity-managed until the egress gateway handles WebSockets, so existing users don't silently move to passing GEMINI_API_KEY in spec.env.

Heads-up I also have #29 open under agents/antigravity/ if you plan to move or replace it. Left a few quick notes inline, mainly a catch around AX_SESSION_FILE skipping deleteEnvironment.

Comment thread antigravity/main.go
// finish keeps a session's environment for its next turn, and deletes a
// one-off task's environment.
func (h *harness) finish(api *client, st *state, sessionID string) {
if sessionID != "" {

@mayawang mayawang Nov 23, 2026 •

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.

ax-server always defaults spec.sessionId to metadata.uid, so AX_SESSION_FILE is never empty on a real task. With this check, deleteEnvironment never runs and every task leaks its remote environment and key under .ax/sessions/<uid>.

Feels like a contract question between ax and the launcher: either ax stops defaulting sessionId for one-off tasks, or we shouldn't use AX_SESSION_FILE to drive remote cleanup.

Comment thread antigravity/main.go
}
return 143, nil
}
if err != nil {

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.

On requires_action, line 676 already cancels the interaction, so returning here without clearing st.Pending makes a resume reattach to a cancelled interaction. Skipping h.finish here also skips cleanup on terminal errors like requires_action or maxContinuations.

Comment thread antigravity/main.go
request[k] = v
}
// Later turns of a session continue from the session's last interaction.
if sessionID != "" && st.LastInteractionID != "" {

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.

Should we only set this when previous_interaction_id isn't already in request? Right now it overwrites an explicit spec.config.previousInteractionId.

Comment thread antigravity/worker.go
_ = w.cmd.Process.Signal(syscall.SIGTERM)
select {
case <-w.done:
case <-time.After(10 * time.Second):

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.

ax-runner uses a 10s stop grace period before SIGKILL, so waiting 10s here races it. Around 5s gives the parent room to exit 143 cleanly, and same caveat on the WithoutCancel call at main.go:706 capped at 1m by api.go:61.

Comment thread antigravity/api.go
func newClient(ctx context.Context, baseURL, apiKey, caFile string) (*client, error) {
transport := http.DefaultTransport.(*http.Transport).Clone()
if caFile != "" {
if pem, err := os.ReadFile(caFile); err == nil {

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.

nit: worth returning an error or logging a warning if caFile fails to read or AppendCertsFromPEM returns false, rather than falling back silently.

@rakyll

rakyll commented Nov 24, 2026

Copy link
Copy Markdown
Collaborator Author

I'm merging this as a starting point and @mayawang will follow-up with the open comments.

@rakyll
rakyll merged commit 6648113 into main Nov 24, 2026
3 checks passed
mayawang added a commit that referenced this pull request Nov 24, 2026
…cher symlink (#31)

Follow up on review items from #30 (6648113):

- api.go / main.go: fail fast with a clear error when a configured CA bundle
  (SSL_CERT_FILE or explicit AX_CA_BUNDLE) cannot be read or contains no valid
  PEM certificates, instead of silently falling back to system roots.
- main.go: preserve an explicit spec.config.previousInteractionId on session
  follow-up turns instead of overwriting it with st.LastInteractionID.
- main.go: cancel in-flight interactions and clear st.Pending / run finish() on
  terminal errors (requires_action, spec.config.timeout, maxContinuations,
  worker crash giving up), and delete newly created environments on worker
  start failure or initial create failure. Bound remote cancel/delete calls
  with a 15s timeout and clean up atomic write temp files on error.
- worker.go: lower worker stop timeout from 10s to 5s so gemini-api exits ahead
  of ax-runner's 10s SIGTERM grace period before SIGKILL. Align createTimeout
  with api.go's 1m http.Client timeout.
- Dockerfile: link /usr/local/bin/ax-launcher instead of deprecated ax-harness
  (follows google/ax#734).
- README.md: document the current google/ax spec.sessionId defaulting behavior.
- ci.yaml: add a go vet and go test -race job for antigravity/.

Verification:
- ./scripts/verify/boilerplate.sh (pass)
- cd antigravity && go vet ./... (clean)
- cd antigravity && go test -race -count=1 ./... (all 18 tests/subtests pass)
- cd antigravity && go build ./ (binary builds cleanly)
- gofmt -l antigravity/ (clean)
- python3 yaml.safe_load check on .github/workflows/ci.yaml (valid)
- Note: docker build ./antigravity was not run locally (no Docker socket)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants