fix: live Gemini mode works + GCP deploy path validated#3
Merged
Conversation
Live LLM mode:
- backend/app/config.py: env_file is now a tuple (./.env, ../.env) so the key
loads whether you run from repo root or backend/.
- backend/app/agent.py: build the chat endpoint per provider. Gemini's
OpenAI-compat path is <base>/chat/completions (base already ends in /openai);
generic OpenAI uses /v1/chat/completions. Fixes 404 from double /v1.
- Default model bumped gemini-1.5-flash -> gemini-2.5-flash (1.5-flash retired
for the key). .env.example updated to match.
- backend/tests/test_chat.py::test_chat_stub no longer asserts stub content, so
it passes in both stub and live mode.
- Verified: /api/chat and /goals/{id}/run return real Gemini 2.5-flash replies.
GCP deploy path (validated):
- deploy/cloudbuild.yaml now pushes to Artifact Registry
(us-central1-docker.pkg.dev/<proj>/demo-agent/demo-agent-backend:latest),
matching where the image is published.
- deploy/gcp-vm-startup.sh pulls from Artifact Registry (REGION/AR_REPO/IMAGE
overridable) instead of the non-existent gcr.io path.
- deploy/terraform/main.tf firewall rule adds source_ranges=["0.0.0.0/0"]
(required by GCP); terraform plan is clean (2 to add).
- Added .gitignore entries for terraform state + provider cache.
Note: .env (with the real key) is git-ignored and never committed.
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
Turns the boilerplate from stub-only into a live, deployable agent and fixes the GCP deploy path.
Live LLM mode (verified with a real Gemini call)
backend/app/config.py:env_fileis now a tuple(./.env, ../.env)so the API key loads whether you run from the repo root orbackend/.backend/app/agent.py: builds the chat endpoint per provider. Gemini's OpenAI-compat path is<base>/chat/completions(base already ends in/openai); generic OpenAI uses/v1/chat/completions. Fixes the 404 from a doubled/v1.gemini-1.5-flash→gemini-2.5-flash(1.5-flash is retired for the key)..env.exampleupdated.backend/tests/test_chat.py::test_chat_stubno longer asserts stub content, so it passes in both stub and live mode./api/chatand/goals/{id}/runreturn real Gemini 2.5-flash replies.GCP deploy path (validated)
deploy/cloudbuild.yamlpushes to Artifact Registryus-central1-docker.pkg.dev/<proj>/demo-agent/demo-agent-backend:latest(matches where the image is published).deploy/gcp-vm-startup.shpulls from Artifact Registry (REGION/AR_REPO/IMAGE overridable) instead of the non-existentgcr.iopath.deploy/terraform/main.tffirewall addssource_ranges=["0.0.0.0/0"](required by GCP).terraform planis clean (2 to add)..gitignorenow excludes terraform state + provider cache.Notes
evals/test_agent.py::test_live_chatnow runs for real when a key is present; the monthly-cap rule still holds (one call, not looped)..env(with the real key) is git-ignored and never committed.gcloud compute instances create(which uses the working gcloud auth) instead. Rungcloud auth application-default loginbefore usingterraform apply.Test plan
pytest tests→ 6 passed (live key present)pytest evals→ 5 passed (live call real)/api/chat+/goals/{id}/runreturn real repliesdocker compose up --buildhealthyterraform planclean (2 to add)