-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Description
** Please make sure you read the contribution guide and file the issues in the right place. **
Contribution guide.
Describe the bug
A critical indentation error in the _get_completion_inputs function causes generation_params to be set to None during the iteration process. The if not generation_params: check is incorrectly placed inside the for loop, which means if any iteration doesn't find a matching key in config_dict, the entire generation_params dictionary gets set to None. This causes subsequent iterations to fail with TypeError: 'NoneType' object does not support item assignment when trying to assign values.
To Reproduce
Steps to reproduce the behavior:
-
Install Google ADK: pip install google-adk -
Initialize a LiteLLM model with a configuration that has some but not all generation parameters -
Run a query that triggers LLM generation -
See error in the _get_completion_inputs function
Example code that may trigger the issue:
from google.adk.models.lite_llm import LiteLLM
# This might cause the issue if generation_config is not properly handled
model = LiteLLM(model_name="gpt-3.5-turbo")Expected behavior
The generation_params should remain a dictionary throughout the iteration process, and only be set to None after all parameters have been processed if no valid parameters were found.
Screenshots
If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
- OS: Ubuntu 24.04
- Python version(python -V): Python 3.13
- ADK version(pip show google-adk): 1.12.0
Model Information:
-
The issue is not model-specific but occurs in the LiteLLM configuration parsing logic -
Affects all models used through the LiteLLM interface
Additional context
The problematic code in /usr/local/lib/python3.13/site-packages/google/adk/models/lite_llm.py
generation_params = {}
param_mapping = {
"max_output_tokens": "max_completion_tokens",
"stop_sequences": "stop",
}
for key in (
"temperature",
"max_output_tokens",
"top_p",
"top_k",
"stop_sequences",
"presence_penalty",
"frequency_penalty",
):
if key in config_dict:
mapped_key = param_mapping.get(key, key)
generation_params[mapped_key] = config_dict[key]
if not generation_params: # ← WRONG INDENTATION - INSIDE LOOP!
generation_params = None # This executes after every iteration
return messages, tools, response_format, generation_paramsFile "/usr/local/lib/python3.13/site-packages/google/adk/models/lite_llm.py", line 590, in _get_completion_inputs
generation_params[mapped_key] = config_dict[key]
TypeError: 'NoneType' object does not support item assignment