fix(models): let LiteLlm pin the tool-result role - #7042
Open
claxman wants to merge 2 commits into
Open
Conversation
Gemma-4 names always sent role=tool_responses. Servers that validate OpenAI roles reject that value. An explicit tool_result_role keeps the auto-detect as the default. Fixes google#6482
A PrivateAttr drop silently lost the override on model_dump and model_copy. Other BaseLlm knobs are declared fields. Fixes google#6482
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):
Problem:
_content_to_message_paramsets roletool_responseswhenever the model name matches Gemma-4. On this tree,google/gemma-4-e4byieldstool_responsesandopenai/gpt-4oyieldstool.grep tool_result_role src/google/adk/models/lite_llm.pywas empty. #6482 reports that this breaks servers that validate OpenAI roles.Solution:
LiteLlm(tool_result_role="tool")is a declared field that pins the role. Unset keeps Gemma-4 auto-detect. It is popped from_additional_argsso LiteLLM does not see it._resolve_tool_result_roleis used by_content_to_message_param,_ensure_tool_results, and_get_completion_inputs.Testing Plan
Unit Tests:
14 passed.
Reverted
lite_llm.pyto b018062 and reran the file: 6 failed, 8 passed. Restored: 14 passed.Manual End-to-End (E2E) Tests:
Not run here. No LM Studio on this machine. The LM Studio gemma-4-e4b repro from the issue with
LiteLlm(model=..., tool_result_role="tool")would cover it if the reporter can run it.Additional context
Claim: #6482 (comment)
Checklist