From de4ac2d93f4bde068e7b68fa5e01cd552f14a33d Mon Sep 17 00:00:00 2001 From: Haihan Jiang Date: Mon, 13 Jul 2026 13:51:54 -0700 Subject: [PATCH] fix: make discussion answering model configurable Merge https://github.com/google/adk-python/pull/6113 ## Summary - Configure the discussion answering agents through `LLM_MODEL_NAME` instead of hardcoding `gemini-3.5-flash`. - Let the GitHub workflow override both the answering model and Vertex location with repository variables. - Downgrade the default model from `gemini-3.5-flash` to `gemini-2.5-flash` because `gemini-3.5-flash` 404s on Vertex AI Search (#6104). - Document the new knobs. Fixes #6104 ## Testing - `git diff --check` - `python3.12 -m py_compile contributing/samples/adk_team/adk_answering_agent/settings.py contributing/samples/adk_team/adk_answering_agent/agent.py contributing/samples/adk_team/adk_answering_agent/gemini_assistant/agent.py` Co-authored-by: Kathy Wu COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/6113 from Haihan-Jiang:codex/adk-python-answering-model-config aea24eab14eaf479b7d42f59f25a94e0baa713a5 PiperOrigin-RevId: 947224603 --- .github/workflows/discussion_answering.yml | 3 ++- .../samples/adk_team/adk_answering_agent/README.md | 8 +++++++- .../samples/adk_team/adk_answering_agent/agent.py | 3 ++- .../adk_answering_agent/gemini_assistant/agent.py | 3 ++- .../samples/adk_team/adk_answering_agent/settings.py | 2 ++ 5 files changed, 15 insertions(+), 4 deletions(-) diff --git a/.github/workflows/discussion_answering.yml b/.github/workflows/discussion_answering.yml index 73024cdd..c25bb1c1 100644 --- a/.github/workflows/discussion_answering.yml +++ b/.github/workflows/discussion_answering.yml @@ -57,10 +57,11 @@ jobs: GITHUB_TOKEN: ${{ secrets.ADK_TRIAGE_AGENT }} ADK_GCP_SA_KEY: ${{ secrets.ADK_GCP_SA_KEY }} GOOGLE_CLOUD_PROJECT: ${{ secrets.GOOGLE_CLOUD_PROJECT }} - GOOGLE_CLOUD_LOCATION: ${{ secrets.GOOGLE_CLOUD_LOCATION }} + GOOGLE_CLOUD_LOCATION: ${{ vars.ADK_ANSWERING_LOCATION || secrets.GOOGLE_CLOUD_LOCATION }} VERTEXAI_DATASTORE_ID: ${{ secrets.VERTEXAI_DATASTORE_ID }} GEMINI_API_DATASTORE_ID: ${{ secrets.GEMINI_API_DATASTORE_ID }} GOOGLE_GENAI_USE_VERTEXAI: 1 + LLM_MODEL_NAME: ${{ vars.ADK_ANSWERING_MODEL || 'gemini-2.5-flash' }} OWNER: 'google' REPO: 'adk-python' INTERACTIVE: 0 diff --git a/contributing/samples/adk_team/adk_answering_agent/README.md b/contributing/samples/adk_team/adk_answering_agent/README.md index 7b7ccc83..f7508380 100644 --- a/contributing/samples/adk_team/adk_answering_agent/README.md +++ b/contributing/samples/adk_team/adk_answering_agent/README.md @@ -114,6 +114,7 @@ The following environment variables are required for the agent to connect to the - `GOOGLE_CLOUD_PROJECT=YOUR_PROJECT_ID`: **(Required)** The Google Cloud project ID. - `GOOGLE_CLOUD_LOCATION=LOCATION`: **(Required)** The Google Cloud region. - `VERTEXAI_DATASTORE_ID=YOUR_DATASTORE_ID`: **(Required)** The full Vertex AI datastore ID for the document store (i.e. knowledge base), with the format of `projects/{project_number}/locations/{location}/collections/{collection}/dataStores/{datastore_id}`. +- `LLM_MODEL_NAME`: The Gemini model used by the answering agent. Defaults to `gemini-2.5-flash`. - `OWNER`: The GitHub organization or username that owns the repository (e.g., `google`). Needed for both modes. - `REPO`: The name of the GitHub repository (e.g., `adk-python`). Needed for both modes. - `INTERACTIVE`: Controls the agent's interaction mode. For the automated workflow, this is set to `0`. For interactive mode, it should be set to `1` or left unset. @@ -124,4 +125,9 @@ The following environment variables are required to upload the docs to update th - `ADK_DOCS_ROOT_PATH=YOUR_ADK_DOCS_ROOT_PATH`: **(Required)** Path to the root of the downloaded adk-docs repo. - `ADK_PYTHON_ROOT_PATH=YOUR_ADK_PYTHON_ROOT_PATH`: **(Required)** Path to the root of the downloaded adk-python repo. -For local execution in interactive mode, you can place these variables in a `.env` file in the project's root directory. For the GitHub workflow, they should be configured as repository secrets. +For local execution in interactive mode, you can place these variables in a +`.env` file in the project's root directory. For the GitHub workflow, required +credentials should be configured as repository secrets. The workflow also +supports the optional repository variables `ADK_ANSWERING_MODEL` and +`ADK_ANSWERING_LOCATION` to override the default model and location without +changing the workflow file. diff --git a/contributing/samples/adk_team/adk_answering_agent/agent.py b/contributing/samples/adk_team/adk_answering_agent/agent.py index 04ef4c69..05a7dc45 100644 --- a/contributing/samples/adk_team/adk_answering_agent/agent.py +++ b/contributing/samples/adk_team/adk_answering_agent/agent.py @@ -15,6 +15,7 @@ from adk_answering_agent.gemini_assistant.agent import root_agent as gemini_assistant_agent from adk_answering_agent.settings import BOT_RESPONSE_LABEL from adk_answering_agent.settings import IS_INTERACTIVE +from adk_answering_agent.settings import LLM_MODEL_NAME from adk_answering_agent.settings import OWNER from adk_answering_agent.settings import REPO from adk_answering_agent.settings import VERTEXAI_DATASTORE_ID @@ -38,7 +39,7 @@ else: root_agent = Agent( - model="gemini-3.5-flash", + model=LLM_MODEL_NAME, name="adk_answering_agent", description="Answer questions about ADK repo.", instruction=f""" diff --git a/contributing/samples/adk_team/adk_answering_agent/gemini_assistant/agent.py b/contributing/samples/adk_team/adk_answering_agent/gemini_assistant/agent.py index d93fa1d2..f012ff48 100644 --- a/contributing/samples/adk_team/adk_answering_agent/gemini_assistant/agent.py +++ b/contributing/samples/adk_team/adk_answering_agent/gemini_assistant/agent.py @@ -19,6 +19,7 @@ from typing import List from adk_answering_agent.settings import ADK_GCP_SA_KEY from adk_answering_agent.settings import GEMINI_API_DATASTORE_ID +from adk_answering_agent.settings import LLM_MODEL_NAME from adk_answering_agent.utils import error_response from google.adk.agents.llm_agent import Agent from google.api_core.exceptions import GoogleAPICallError @@ -72,7 +73,7 @@ def search_gemini_api_docs(queries: List[str]) -> Dict[str, Any]: root_agent = Agent( - model="gemini-3.5-flash", + model=LLM_MODEL_NAME, name="gemini_assistant", description="Answer questions about Gemini API.", instruction=""" diff --git a/contributing/samples/adk_team/adk_answering_agent/settings.py b/contributing/samples/adk_team/adk_answering_agent/settings.py index e7b1f827..41401a68 100644 --- a/contributing/samples/adk_team/adk_answering_agent/settings.py +++ b/contributing/samples/adk_team/adk_answering_agent/settings.py @@ -41,5 +41,7 @@ OWNER = os.getenv("OWNER", "google") REPO = os.getenv("REPO", "adk-python") BOT_RESPONSE_LABEL = os.getenv("BOT_RESPONSE_LABEL", "bot responded") DISCUSSION_NUMBER = os.getenv("DISCUSSION_NUMBER") +DEFAULT_LLM_MODEL_NAME = "gemini-2.5-flash" +LLM_MODEL_NAME = os.getenv("LLM_MODEL_NAME", DEFAULT_LLM_MODEL_NAME) IS_INTERACTIVE = os.getenv("INTERACTIVE", "1").lower() in ["true", "1"]