Repository navigation
Conversation
…ERTEXAI Configuring the agents for Vertex AI does not move all Gemini traffic off the Gemini API key. Helper agents build their own google endpoints or google-genai clients from the key: the Flash step summarizer (get_google_llm), the explorer's native engine, the object detector and the video analyzer. With a free-tier key those calls hit 429 RESOURCE_EXHAUSTED and stall runs even when the main model is on Vertex. Honour google-genai's own switch, GOOGLE_GENAI_USE_VERTEXAI. When it is set, every google endpoint is created as ChatGoogleGenerativeAI with vertexai=True, the project from VERTEX_AI_PROJECT or GOOGLE_CLOUD_PROJECT and the location from VERTEX_AI_LOCATION or GOOGLE_CLOUD_LOCATION (default global, where Gemini 3 is served), authenticated with Application Default Credentials. The explorer and video analyzer skip their native developer-API path on Vertex, since it needs the API key and the Files API, and use the LangChain path. Because these calls go through google-genai, they keep the developer-API message conversion and do not hit the ChatVertexAI part-order error from google#156. The explicit vertexai provider is unchanged. Tests clear the flag so a local .env cannot change their behaviour.
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.
Closes #227
Summary
Adds one switch that moves all Gemini traffic to Vertex AI: setting google-genai's own
GOOGLE_GENAI_USE_VERTEXAI=truemakes everygoogleendpoint, helper agents included, run on Vertex with Application Default Credentials. Today the step summarizer, explorer, object detector and video analyzer build their Gemini clients fromGOOGLE_API_KEY, so they keep hitting the developer API (free-tier 429s, busy-time 503s) even when the main model is meant to run on Vertex.This complements #186: that PR fixes the explicit
vertexaiprovider (ChatVertexAI part order, #156). This one leaves that provider unchanged and instead routesgoogleendpoints through google-genai withvertexai=True, which keeps the developer-API message conversion, so it does not hit the #156 error either.Changes
artemis/llm/google/provider.py:use_vertex_backend()readsGOOGLE_GENAI_USE_VERTEXAI;vertex_project()readsVERTEX_AI_PROJECTthenGOOGLE_CLOUD_PROJECT;vertex_location()readsVERTEX_AI_LOCATIONthenGOOGLE_CLOUD_LOCATION, defaultglobal(where Gemini 3 is served). Env-only, so the module stays free of SDK and settings imports.ModelFactory.create_model: with the switch on, thegooglebranch passesvertexai=True, project and location instead of an API key. Everything else (thinking level, safety settings, grounding patch) is shared, soget_google_llmcallers such as the step summarizer follow automatically..env.exampledocuments the three variables.tests/unit/test_vertex_backend.pycovers the flag values, project/location precedence, the factory kwargs with and without the switch, and the explorer engine choice.tests/conftest.pyclears the flag so a developer's local.envcannot change test behaviour (without it,test_explorer_runfails on a machine that has the switch on).Verification
make lint,make typecheck,make test(2540 passed, 7 skipped)GOOGLE_CLOUD_PROJECTand ADC set: gemini-3.8-flash, gemini-3.5-flash-lite and gemini-robotics-er-2-preview each answered on Vertexglobal, and a replayed second turn (tool call, tool result, new observation) returned the next tool call where ChatVertexAI had returned the Vertex Gemini 3.8 Flash fails after the first ARTEMIS tool-calling turn #156 400.