-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Labels
tools[Component] This issue is related to tools[Component] This issue is related to tools
Description
Describe the bug
When optimize_data_file=True is set on a CodeExecutor and a CSV file is uploaded, ADK automatically generates preprocessing code that includes an explore_df() function. This function calls crop() which is not defined, causing a NameError.
The issue is in _DATA_FILE_HELPER_LIB in src/google/adk/flows/llm_flows/_code_execution.py (line 97):
df_unique = df.apply(lambda x: crop(str(list(x.unique()))))The crop function is used but never defined in _DATA_FILE_HELPER_LIB.
To Reproduce
- Install
google-adk==1.21.0 - Create an agent with a CodeExecutor that has
optimize_data_file=True - Upload a CSV file to the agent
- The agent will execute the auto-generated preprocessing code and fail with:
NameError: name 'crop' is not defined
Traceback (most recent call last):
File "<stdin>", line 45
File "<stdin>", line 23
File "<stdin>", line 23
NameError: name 'crop' is not defined
Expected behavior
The crop function should be defined in _DATA_FILE_HELPER_LIB, or the call to crop() should be removed/replaced with an alternative.
Suggested fix
Add the crop function definition to _DATA_FILE_HELPER_LIB:
def crop(s: str, max_len: int = 100) -> str:
"""Truncate string to max_len characters."""
return s[:max_len] + '...' if len(s) > max_len else sDesktop (please complete the following information):
- OS: macOS
- Python version: 3.13 (sandbox)
- ADK version: 1.21.0
Model Information:
- Are you using LiteLLM: Yes
- Which model is being used: Claude (via Bedrock)
Metadata
Metadata
Assignees
Labels
tools[Component] This issue is related to tools[Component] This issue is related to tools