Repository navigation
Conversation
Vertex AI Model Garden MaaS serves Gemma 4 via Vertex AI's
OpenAI-compatible chat-completions endpoint, which rejects
role='tool_responses' with 400 INVALID_ARGUMENT ("Unrecognized 'role'
field for a message; found: 'tool_responses'."). Self-deployed Vertex AI
Model Garden Gemma 4 endpoints also accept role='tool'.
Add 'vertex_ai' to _STANDARD_TOOL_ROLE_PROVIDERS so Gemma 4 on Vertex AI
sends standard role='tool' while preserving 'tool_responses' for Ollama
and hosted_vllm.
Fixes google#7977
rladeira
force-pushed
the
fix/gemma4-vertex-maas-tool-role
branch
from
November 3, 2026 20:46
5c8a013 to
d5cace7
Compare
Collaborator
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.
Please ensure you have read the contribution guide before creating a pull request.
Link to Issue or Description of Change
1. Link to an existing issue (if applicable):
2. Or, if no issue exists, describe the change:
Problem:
_is_gemma4_modelingoogle/adk/models/lite_llm.pycauses ADK to send tool results withrole="tool_responses"whenever the model name matchesgemma-?4, unless the effective provider is in_STANDARD_TOOL_ROLE_PROVIDERS({"openai", "azure", "lm_studio"}, added in7d190e6efor #6482).When calling Gemma 4 on Vertex AI Model Garden MaaS via LiteLLM (
vertex_ai/google/gemma-4-26b-a4b-it-maas), LiteLLM dispatches to Vertex AI's OpenAI-compatible chat-completions endpoint (.../endpoints/openapi/chat/completions), which strictly validates OpenAI message roles and rejectsrole="tool_responses"with400 INVALID_ARGUMENT ("Unrecognized 'role' field for a message; found: 'tool_responses'.").Solution:
Add
"vertex_ai"to_STANDARD_TOOL_ROLE_PROVIDERSand update the_is_gemma4_modeldocstring and_content_to_message_paramcomment:7d190e6ewith no public API changes.vertex_ai/google/gemma-4-*) andcustom_llm_provider="vertex_ai"routes, including_ensure_tool_resultshealing.google/gemma4@gemma-4-e2b-itviavertex_ai/gemma/...:predictwith@requestFormat="chatCompletions"and dedicated/chat/completions), which also acceptsrole="tool"cleanly.role="tool_responses"forollama/...andhosted_vllm/....Testing Plan
Unit Tests:
Added parametrized cases in
tests/unittests/models/test_lite_llm_gemma_tool_role.pycoveringvertex_ai/google/gemma-4-26b-a4b-it-maasandcustom_llm_provider="vertex_ai"acrossTestLiteLlmGenerateContentandTestEnsureToolResults.pytestsummary:Manual End-to-End (E2E) Tests:
vertex_ai/google/gemma-4-26b-a4b-it-maas,vertex_location="global"):google/gemma4@gemma-4-e2b-itviavertex_ai/gemma/gemma-4-e2b-it:predictand dedicated/chat/completions):Checklist
Additional context
None.