Skip to content

Self-improving AI Employees for everyone

feat(gemini): add Gemma 4 models to the gemini provider list

trohitgc5243fb8caa7
diff --git a/server/config/llm_defaults.json b/server/config/llm_defaults.json
index 955eddec..5f921497 100644
--- a/server/config/llm_defaults.json
+++ b/server/config/llm_defaults.json
@@ -74,12 +74,13 @@
},
"gemini": {
"default_model": "gemini-3.5-flash",
- "detection_patterns": ["gemini", "google"],
+ "detection_patterns": ["gemini", "google", "gemma"],
+ "_detection_patterns_note": "'gemma' makes is_model_valid_for_provider accept the API-served Gemma models (gemma-4-*-it) on gemini nodes — without it the four agent-path call sites silently swap gemma to default_model. Cerebras keeps its own 'gemma-4' pattern for its gemma-4-31b (no -it suffix); is_model_valid_for_provider is per-provider so both coexist. Only the runtime-unused detect_provider_from_model classifier prefers gemini for gemma-* names (dict order).",
"base_url": "https://generativelanguage.googleapis.com/v1beta",
"models_endpoint": "https://generativelanguage.googleapis.com/v1beta/models",
"api_key_param": "google_api_key",
"max_tokens_param": "max_output_tokens",
- "_models_note": "Real (concrete) model names only — no -latest rolling aliases. The same curated list (max_output_tokens keys) serves BOTH the Gemini Developer API (AIza keys) and Vertex / Agent Platform (AQ. keys); every entry live-verified on both endpoints (2026-06-12). Vertex 404s on -latest aliases and its models.list rejects API keys, which is why the dropdown is curated instead of live-fetched.",
+ "_models_note": "Real (concrete) model names only — no -latest rolling aliases. The curated list (max_output_tokens keys) serves BOTH the Gemini Developer API (AIza keys) and Vertex / Agent Platform (AQ. keys); gemini-* entries live-verified on both endpoints (2026-06-12). Vertex 404s on -latest aliases and its models.list rejects API keys, which is why the dropdown is curated instead of live-fetched. Gemma exception: gemma-4-31b-it + gemma-4-26b-a4b-it are served ONLY on the Developer API (free tier, ai.google.dev/gemma/docs/core/gemma_on_gemini_api, verified 2026-07-11) — Vertex keys must not see them, hence vertex_incompatible_models below. Gemma 4 supports systemInstruction and function calling natively (unlike the gemma-3 era); max output is undocumented, so the curated 8192 is a conservative fallback (registry cache wins when present).",
"max_output_tokens": {
"gemini-3.5-flash": 65536,
"gemini-3.1-pro-preview": 65536,
@@ -88,6 +89,8 @@
"gemini-2.5-pro": 65536,
"gemini-2.5-flash": 65535,
"gemini-2.5-flash-lite": 65535,
+ "gemma-4-31b-it": 8192,
+ "gemma-4-26b-a4b-it": 8192,
"_default": 8192
},
"context_length": {
@@ -98,8 +101,12 @@
"gemini-2.5-pro": 1048576,
"gemini-2.5-flash": 1048576,
"gemini-2.5-flash-lite": 1048576,
+ "gemma-4-31b-it": 262144,
+ "gemma-4-26b-a4b-it": 262144,
"_default": 1048576
},
+ "_vertex_incompatible_models_note": "Curated models that only exist on the Gemini Developer API, filtered out of fetch_models when the key is a Vertex / Agent Platform key (GeminiProvider._vertex). Gemma is Model Garden self-deploy on Vertex (the 26B MaaS variant needs a different '-maas' id on a different surface), so the plain ids 404 there.",
+ "vertex_incompatible_models": ["gemma-4-31b-it", "gemma-4-26b-a4b-it"],
"thinking_models": ["gemini-2.5", "gemini-3"],
"thinking_type": "budget",
"temperature_range": [0.0, 2.0],
diff --git a/server/config/model_registry.json b/server/config/model_registry.json
index 8d007591..fc1026ee 100644
--- a/server/config/model_registry.json
+++ b/server/config/model_registry.json
@@ -1,7 +1,7 @@
{
- "_generated": "2026-07-10T06:03:13.088476+00:00",
+ "_generated": "2026-07-11T06:45:11.819419+00:00",
"_source": "openrouter",
- "_model_count": 347,
+ "_model_count": 345,
"models": {
"openai/gpt-5.6-luna-pro": {
"id": "openai/gpt-5.6-luna-pro",
@@ -631,9 +631,9 @@
"provider": "z-ai",
"local_id": "glm-5.2",
"context_length": 1048576,
- "max_output_tokens": 1048576,
- "input_price_per_mtok": 0.92,
- "output_price_per_mtok": 3.0,
+ "max_output_tokens": 131072,
+ "input_price_per_mtok": 0.406,
+ "output_price_per_mtok": 1.276,
"supports_thinking": false,
"thinking_type": "none",
"temperature_range": [
@@ -1307,18 +1307,12 @@
],
"is_reasoning_model": false,
"supported_parameters": [
- "frequency_penalty",
- "logit_bias",
- "logprobs",
"max_tokens",
- "presence_penalty",
"response_format",
"seed",
- "stop",
"structured_outputs",
"tool_choice",
- "tools",
- "top_logprobs"
+ "tools"
]
},
"xai/grok-4.3": {
@@ -1994,9 +1988,9 @@
"provider": "deepseek",
"local_id": "deepseek-v4-flash",
"context_length": 1048576,
- "max_output_tokens": 65536,
- "input_price_per_mtok": 0.09,
- "output_price_per_mtok": 0.18,
+ "max_output_tokens": 384000,
+ "input_price_per_mtok": 0.077,
+ "output_price_per_mtok": 0.154,
"supports_thinking": false,
"thinking_type": "none",
"temperature_range": [
@@ -4825,39 +4819,6 @@
"top_p"
]
},
- "arcee-ai/trinity-mini": {
- "id": "arcee-ai/trinity-mini",
- "name": "Arcee AI: Trinity Mini",
- "provider": "arcee-ai",
- "local_id": "trinity-mini",
- "context_length": 131072,
- "max_output_tokens": 131072,
- "input_price_per_mtok": 0.045,
- "output_price_per_mtok": 0.15,
- "supports_thinking": false,
- "thinking_type": "none",
- "temperature_range": [
- 0.0,
- 2.0
- ],
- "is_reasoning_model": false,
- "supported_parameters": [
- "include_reasoning",
- "logprobs",
- "max_completion_tokens",
- "max_tokens",
- "reasoning",
- "response_format",
- "stop",
- "structured_outputs",
- "temperature",
- "tool_choice",
- "tools",
- "top_k",
- "top_logprobs",
- "top_p"
- ]
- },
"deepseek/deepseek-v3.2": {
"id": "deepseek/deepseek-v3.2",
"name": "DeepSeek: DeepSeek V3.2",
@@ -10347,37 +10308,6 @@
"web_search_options"
]
},
- "meta/llama-3-8b-instruct": {
- "id": "meta-llama/llama-3-8b-instruct",
- "name": "Meta: Llama 3 8B Instruct",
- "provider": "meta",
- "local_id": "llama-3-8b-instruct",
- "context_length": 8192,
- "max_output_tokens": 0,
- "input_price_per_mtok": 0.14,
- "output_price_per_mtok": 0.14,
- "supports_thinking": false,
- "thinking_type": "none",
- "temperature_range": [
- 0.0,
- 2.0
- ],
- "is_reasoning_model": false,
- "supported_parameters": [
- "frequency_penalty",
- "logit_bias",
- "max_tokens",
- "min_p",
- "presence_penalty",
- "repetition_penalty",
- "response_format",
- "stop",
- "structured_outputs",
- "temperature",
- "top_k",
- "top_p"
- ]
- },
"mistralai/mixtral-8x22b-instruct": {
"id": "mistralai/mixtral-8x22b-instruct",
"name": "Mistral: Mixtral 8x22B Instruct",
diff --git a/server/config/pricing.json b/server/config/pricing.json
index 27a777e2..c3479faf 100644
--- a/server/config/pricing.json
+++ b/server/config/pricing.json
@@ -33,6 +33,8 @@
"gemini-3-pro-preview": {"input": 2.00, "output": 12.00},
"gemini-2.5-pro": {"input": 1.25, "output": 10.00},
"gemini-2.5-flash": {"input": 0.30, "output": 2.50},
+ "gemma-4-31b-it": {"input": 0.0, "output": 0.0},
+ "gemma-4-26b-a4b-it": {"input": 0.0, "output": 0.0},
"_default": {"input": 0.50, "output": 3.00}
},
"groq": {
diff --git a/server/services/llm/providers/gemini.py b/server/services/llm/providers/gemini.py
index 8b6ba955..1e97fa29 100644
--- a/server/services/llm/providers/gemini.py
+++ b/server/services/llm/providers/gemini.py
@@ -97,19 +97,22 @@ class GeminiProvider:
async def fetch_models(self, api_key: str) -> List[str]:
"""Validate the key, then return the curated model list.
- The same curated list (``max_output_tokens`` keys from the gemini
+ The curated list (``max_output_tokens`` keys from the gemini
block in llm_defaults.json — real model names, no ``-latest``
- aliases) serves both backends, so the dropdown is identical for
- AI Studio and Vertex keys. Only the key probe differs: Vertex
- rejects API keys on ``models.list`` (401 — requires an OAuth
- principal), so a free ``count_tokens`` call verifies the key
- there; the Developer API uses its models endpoint. Invalid keys
- raise the typed SDK error which the unifier translates into
- ``NodeUserError``.
+ aliases) serves both backends; Vertex keys additionally drop the
+ ``vertex_incompatible_models`` entries (Gemma is Developer-API
+ only — on Vertex it is a Model Garden self-deploy and the plain
+ ids 404). Only the key probe differs: Vertex rejects API keys on
+ ``models.list`` (401 — requires an OAuth principal), so a free
+ ``count_tokens`` call verifies the key there; the Developer API
+ uses its models endpoint. Invalid keys raise the typed SDK error
+ which the unifier translates into ``NodeUserError``.
"""
models = self._curated_models()
if self._vertex:
+ vertex_blocked = self._vertex_incompatible_models()
+ models = [m for m in models if m not in vertex_blocked]
probe_model = models[0] if models else "gemini-2.5-flash"
await self._client.aio.models.count_tokens(
model=probe_model, contents="hello"
@@ -137,6 +140,16 @@ class GeminiProvider:
)
return [m for m in max_tokens_map if m != "_default"]
+ @staticmethod
+ def _vertex_incompatible_models() -> frozenset:
+ from services.llm import config as llm_config
+
+ return frozenset(
+ llm_config.LLM_DEFAULTS.get("providers", {})
+ .get("gemini", {})
+ .get("vertex_incompatible_models", [])
+ )
+
# ------------------------------------------------------------------
# internals
# ------------------------------------------------------------------
diff --git a/server/tests/llm/test_vertex_key.py b/server/tests/llm/test_vertex_key.py
index 05b661a4..8363e85b 100644
--- a/server/tests/llm/test_vertex_key.py
+++ b/server/tests/llm/test_vertex_key.py
@@ -10,7 +10,8 @@ every execution path picks it up with no call-site edits.
One curated model list (the ``max_output_tokens`` keys in
llm_defaults.json — real model names, no ``-latest`` aliases) serves
-both backends.
+both backends, minus the ``vertex_incompatible_models`` entries which
+are Developer-API-only (Gemma) and dropped from the Vertex branch.
"""
from unittest.mock import AsyncMock, MagicMock, patch
@@ -29,6 +30,14 @@ def _curated_gemini_models():
return [m for m in max_tokens_map if m != "_default"]
+def _vertex_incompatible_models():
+ from services.llm import config as llm_config
+
+ return llm_config.LLM_DEFAULTS["providers"]["gemini"].get(
+ "vertex_incompatible_models", []
+ )
+
+
# ---------------------------------------------------------------------------
# Key-prefix detection helper
# ---------------------------------------------------------------------------
@@ -74,6 +83,66 @@ class TestCuratedModelList:
assert default in _curated_gemini_models()
+# ---------------------------------------------------------------------------
+# Gemma on the Developer API — curated inclusion + Vertex exclusion
+# ---------------------------------------------------------------------------
+
+
+class TestGemmaCuration:
+ """Gemma 4 (gemma-4-31b-it / gemma-4-26b-a4b-it) is served on the
+ Gemini Developer API only (free tier; supports systemInstruction and
+ tools). It must appear in the curated list, be valid for the gemini
+ provider (else the agent paths silently swap it to default_model),
+ and be excluded from the Vertex branch where the plain ids 404.
+ """
+
+ GEMMA_MODELS = ("gemma-4-31b-it", "gemma-4-26b-a4b-it")
+
+ def test_gemma_models_in_curated_list(self):
+ curated = _curated_gemini_models()
+ for model in self.GEMMA_MODELS:
+ assert model in curated
+
+ def test_gemma_models_are_vertex_incompatible(self):
+ blocked = _vertex_incompatible_models()
+ for model in self.GEMMA_MODELS:
+ assert model in blocked
+
+ def test_vertex_incompatible_is_subset_of_curated(self):
+ """Every vertex-blocked entry must exist in the curated list —
+ a stale blocklist entry means a renamed/removed model."""
+ curated = set(_curated_gemini_models())
+ for model in _vertex_incompatible_models():
+ assert model in curated, (
+ f"{model!r} in vertex_incompatible_models but not curated"
+ )
+
+ def test_default_model_not_vertex_incompatible(self):
+ """The Vertex count_tokens probe and the invalid-model swap both
+ fall back to default_model — it must be servable on Vertex."""
+ from services.llm import config as llm_config
+
+ default = llm_config.LLM_DEFAULTS["providers"]["gemini"]["default_model"]
+ assert default not in _vertex_incompatible_models()
+
+ def test_gemma_valid_for_gemini_provider(self):
+ """The four runtime swap sites (execute_agent, execute_chat_agent,
+ temporal agent, RLM) gate on is_model_valid_for_provider — without
+ a matching detection pattern gemma silently swaps to default."""
+ from services.ai import is_model_valid_for_provider
+
+ for model in self.GEMMA_MODELS:
+ assert is_model_valid_for_provider(model, "gemini") is True
+
+ def test_cerebras_gemma_still_valid_for_cerebras(self):
+ """Cerebras serves its own gemma-4-31b (no -it suffix); adding
+ 'gemma' to gemini's patterns must not break cerebras validity —
+ the check is per-provider, not first-match-wins."""
+ from services.ai import is_model_valid_for_provider
+
+ assert is_model_valid_for_provider("gemma-4-31b", "cerebras") is True
+
+
# ---------------------------------------------------------------------------
# Native path: GeminiProvider client construction + fetch_models
# ---------------------------------------------------------------------------
@@ -112,15 +181,16 @@ class TestGeminiProviderVertexMode:
@pytest.mark.asyncio
async def test_fetch_models_vertex_probes_and_returns_curated_list(self):
"""Vertex model listing rejects API keys, so the key is verified
- with a free count_tokens call and the shared curated list is
- returned."""
+ with a free count_tokens call and the curated list minus the
+ Developer-API-only entries (Gemma) is returned."""
provider, _ = self._make("AQ.test-key")
provider._client = MagicMock()
provider._client.aio.models.count_tokens = AsyncMock()
models = await provider.fetch_models("AQ.test-key")
- expected = _curated_gemini_models()
+ blocked = set(_vertex_incompatible_models())
+ expected = [m for m in _curated_gemini_models() if m not in blocked]
assert models == expected
assert len(models) > 0
provider._client.aio.models.count_tokens.assert_awaited_once_with(
@@ -129,9 +199,9 @@ class TestGeminiProviderVertexMode:
@pytest.mark.asyncio
async def test_fetch_models_ai_studio_returns_same_curated_list(self):
- """Both key types serve the SAME model list — the AI Studio
- branch probes the key via the models endpoint, then returns the
- shared curated list."""
+ """The AI Studio branch probes the key via the models endpoint,
+ then returns the FULL curated list — including Developer-API-only
+ entries like Gemma that the Vertex branch filters out."""
provider, _ = self._make("AIzaSyTest")
mock_response = MagicMock()