antigravity: forward GOOGLE_CLOUD_{PROJECT,LOCATION} env to AGY config#223
Merged
Conversation
9f2a968 to
ad287b8
Compare
19df981 to
74caaa5
Compare
rakyll
approved these changes
Jun 30, 2026
74caaa5 to
11a39ff
Compare
The AGY SDK requires vertex/project/location on its AgentConfig but does not read these env vars itself. Setting GOOGLE_GENAI_USE_VERTEXAI=True plus GOOGLE_CLOUD_PROJECT/LOCATION per the README's auth instructions therefore reaches the credential check, then dies later inside AGY with a confusing 'project and location, or an API key' error. Have the sidecar forward the env vars to gemini_config at startup, with programmatic config taking precedence. Validate fail-fast: if vertex is requested but project/location are missing, raise ValueError at startup naming the missing env var, instead of failing per-request later.
11a39ff to
32a65f2
Compare
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
The README documents
GOOGLE_CLOUD_PROJECT/GOOGLE_CLOUD_LOCATION/GOOGLE_GENAI_USE_VERTEXAI=Trueas the way to run the antigravity sidecar against Vertex AI, but the AGY SDK does not read these env vars — it requiresvertex/project/locationexplicitly onLocalAgentConfig. After #177 bumped togoogle-antigravity==0.1.5(which restructured the config API), this surfaces as: user sets all 3 documented env vars →ax execfails per-request withA Gemini API key is required.This PR makes the sidecar read those env vars at startup and pass them to
LocalAgentConfig.__init__so AGY's@model_validatorpicks them up. Also moves credential validation from per-request to startup with a single exit point inmain()for symmetry with the vertex env validation.Why pass to
__init__rather than mutateAGY's
_apply_shorthand_configsruns once at construction (as a@pydantic.model_validator(mode="after")). Post-init mutation ofconfig.{vertex,project,location}does NOT regenerateconfig.models, so AGY's per-endpointvalidate_endpoint()still sees the defaultGeminiAPIEndpoint(api_key=None)and rejects the request. Passing via__init__(**_vertex_kwargs_from_env())lets the validator generate the correctVertexEndpoint(project=..., location=...).Changes
python/antigravity/harness_server.py:_env_use_vertex()helper (env flag check)._vertex_kwargs_from_env()— returnsdictof{vertex, project, location}from env, or{}if env doesn't request Vertex. RaisesValueErrorif Vertex requested but project/location missing._build_default_config()callsLocalAgentConfig(..., **_vertex_kwargs_from_env())so env values flow through AGY's__init__validators._has_credentialsrewritten to mirror AGY's per-endpoint validation: onlyGEMINI_API_KEYenv,config.api_key, orconfig.vertex=True + config.{project,location}(droppedGOOGLE_API_KEYand per-model api_keys; AGY doesn't accept them)._run_turn) to startup (main); single try/except inmain()is the only exit point — helpers raiseValueError,mainprintsERROR: ...to stderr and exits 1.loaded_configmodule global with_build_default_config()factory injected into the servicer constructor. TODOs mark where Antigravity harness read and apply configs from rpc requests #194's per-requestharness_configlayering will plug in._-prefix (_serve,_enhance_config_from_env,_resolve_localhost).python/antigravity/harness_server_test.py:_build_default_config_picks_up_vertex_envtest + 2 credential tests (vertex requires project+location; Express Mode) + 2 servicer DI tests.Verification
Unit tests: 17/17 pass against
google-antigravity==0.1.5(current PyPI wheel, uploaded 2026-06-25).go build+go test: clean.End-to-end via
ax exec→ax serve→ sidecar → AGY → Vertex AI:GOOGLE_GENAI_USE_VERTEXAI=True+GOOGLE_CLOUD_PROJECT=cloud-ai-agentic-coding+GOOGLE_CLOUD_LOCATION=globalVertex AI backend configured: project=... location=....ax exec "capital of France?"→ real Vertex/Gemini response:Paris is the capital of France.GOOGLE_GENAI_USE_VERTEXAI=True+GOOGLE_CLOUD_LOCATION=us-east1ERROR: Vertex AI backend requested but missing required config: project (set GOOGLE_CLOUD_PROJECT)ERROR: No Gemini credentials configured. Set GEMINI_API_KEY (AI Studio) or GOOGLE_GENAI_USE_VERTEXAI=True + GOOGLE_CLOUD_{PROJECT,LOCATION} (Vertex AI).Sidecar log:
[gRPC] Running chat query→[gRPC] Turn completed successfully. No mocked-tool involvement — response is real model output from Vertex AI.Out of scope
harness_configlayering (Antigravity harness read and apply configs from rpc requests #194) — TODO markers placed.Closes #225.