Repository navigation
feat(antigravity): add Gemini API Managed Agents image - #30
Conversation
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.
mayawang
left a comment
There was a problem hiding this comment.
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.
| // 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 != "" { |
There was a problem hiding this comment.
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.
| } | ||
| return 143, nil | ||
| } | ||
| if err != nil { |
There was a problem hiding this comment.
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.
| request[k] = v | ||
| } | ||
| // Later turns of a session continue from the session's last interaction. | ||
| if sessionID != "" && st.LastInteractionID != "" { |
There was a problem hiding this comment.
Should we only set this when previous_interaction_id isn't already in request? Right now it overwrites an explicit spec.config.previousInteractionId.
| _ = w.cmd.Process.Signal(syscall.SIGTERM) | ||
| select { | ||
| case <-w.done: | ||
| case <-time.After(10 * time.Second): |
There was a problem hiding this comment.
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.
| 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 { |
There was a problem hiding this comment.
nit: worth returning an error or logging a warning if caFile fails to read or AppendCertsFromPEM returns false, rather than falling back silently.
|
I'm merging this as a starting point and @mayawang will follow-up with the open comments. |
…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)
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:gemini-api environments connect(v0.5.0) in the task's workspace to execute the agent's tool calls.spec.configand polls it to completion.<workspace>/.ax/output.API calls go through the Gemini API Go SDK (
google.golang.org/genaiv1.79.1).spec.configholds the interaction request fields under camelCase keys:agent,inputs(a list of strings),previousInteractionId,systemInstruction,tools,agentConfig, … Harness options aretimeout,commandTimeout,disableBashandoutputFile. These keys are rejected: snake_case keys, fields the API deprecated, and fields the harness sets itself. Setting bothinputsandspec.goal.textis an error.GEMINI_API_KEYis stripped from the tool worker's environment. The worker gets only the environment key./usr/local/bin/ax-harnessis a symlink toax-antigravity, so Tasks withspec.goalstill 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.Open questions
ghcr.io/agentexecutor/antigravityis already used byagents/antigravity. Should this replace it, or get a different name?