Skip to content

antigravity: forward GOOGLE_CLOUD_{PROJECT,LOCATION} env to AGY config#223

Merged
joycel-github merged 1 commit into
mainfrom
harness-forward-vertex-env
Jun 30, 2026
Merged

antigravity: forward GOOGLE_CLOUD_{PROJECT,LOCATION} env to AGY config#223
joycel-github merged 1 commit into
mainfrom
harness-forward-vertex-env

Conversation

@joycel-github

@joycel-github joycel-github commented Jun 29, 2026

Copy link
Copy Markdown
Collaborator

Summary

The README documents GOOGLE_CLOUD_PROJECT / GOOGLE_CLOUD_LOCATION / GOOGLE_GENAI_USE_VERTEXAI=True as the way to run the antigravity sidecar against Vertex AI, but the AGY SDK does not read these env vars — it requires vertex/project/location explicitly on LocalAgentConfig. After #177 bumped to google-antigravity==0.1.5 (which restructured the config API), this surfaces as: user sets all 3 documented env vars → ax exec fails per-request with A 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_validator picks them up. Also moves credential validation from per-request to startup with a single exit point in main() for symmetry with the vertex env validation.

Why pass to __init__ rather than mutate

AGY's _apply_shorthand_configs runs once at construction (as a @pydantic.model_validator(mode="after")). Post-init mutation of config.{vertex,project,location} does NOT regenerate config.models, so AGY's per-endpoint validate_endpoint() still sees the default GeminiAPIEndpoint(api_key=None) and rejects the request. Passing via __init__(**_vertex_kwargs_from_env()) lets the validator generate the correct VertexEndpoint(project=..., location=...).

Changes

  • python/antigravity/harness_server.py:
    • New _env_use_vertex() helper (env flag check).
    • New _vertex_kwargs_from_env() — returns dict of {vertex, project, location} from env, or {} if env doesn't request Vertex. Raises ValueError if Vertex requested but project/location missing.
    • _build_default_config() calls LocalAgentConfig(..., **_vertex_kwargs_from_env()) so env values flow through AGY's __init__ validators.
    • _has_credentials rewritten to mirror AGY's per-endpoint validation: only GEMINI_API_KEY env, config.api_key, or config.vertex=True + config.{project,location} (dropped GOOGLE_API_KEY and per-model api_keys; AGY doesn't accept them).
    • Credential check moved from per-request (_run_turn) to startup (main); single try/except in main() is the only exit point — helpers raise ValueError, main prints ERROR: ... to stderr and exits 1.
    • Replaced loaded_config module 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-request harness_config layering will plug in.
    • Renamed module-private helpers to _-prefix (_serve, _enhance_config_from_env, _resolve_localhost).
  • python/antigravity/harness_server_test.py:
    • 6 vertex env tests + 1 end-to-end _build_default_config_picks_up_vertex_env test + 2 credential tests (vertex requires project+location; Express Mode) + 2 servicer DI tests.
    • Existing tests updated to inject config via constructor (no module-global mutation).

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 execax serve → sidecar → AGY → Vertex AI:

Scenario Env Result
Vertex happy path GOOGLE_GENAI_USE_VERTEXAI=True + GOOGLE_CLOUD_PROJECT=cloud-ai-agentic-coding + GOOGLE_CLOUD_LOCATION=global Sidecar boots: Vertex AI backend configured: project=... location=.... ax exec "capital of France?" → real Vertex/Gemini response: Paris is the capital of France.
Vertex + missing PROJECT GOOGLE_GENAI_USE_VERTEXAI=True + GOOGLE_CLOUD_LOCATION=us-east1 Exits 1 at startup: ERROR: Vertex AI backend requested but missing required config: project (set GOOGLE_CLOUD_PROJECT)
No credentials (none) Exits 1 at startup: 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

Closes #225.

@joycel-github joycel-github force-pushed the harness-forward-vertex-env branch 17 times, most recently from 9f2a968 to ad287b8 Compare June 30, 2026 07:24
@joycel-github joycel-github marked this pull request as ready for review June 30, 2026 07:30
@joycel-github joycel-github requested review from anj-s and rakyll June 30, 2026 07:30
@joycel-github joycel-github force-pushed the harness-forward-vertex-env branch 3 times, most recently from 19df981 to 74caaa5 Compare June 30, 2026 09:29
Comment thread python/antigravity/harness_server.py Outdated
@joycel-github joycel-github force-pushed the harness-forward-vertex-env branch from 74caaa5 to 11a39ff Compare June 30, 2026 17:26
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.
@joycel-github joycel-github force-pushed the harness-forward-vertex-env branch from 11a39ff to 32a65f2 Compare June 30, 2026 17:28
@joycel-github joycel-github merged commit 17869d2 into main Jun 30, 2026
8 checks passed
@joycel-github joycel-github deleted the harness-forward-vertex-env branch June 30, 2026 19:28
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.

antigravity: PyPI 0.1.5 wheel updated 2026-06-25 with breaking API change; PR #223 broken against current PyPI

2 participants