adk-python icon indicating copy to clipboard operation
adk-python copied to clipboard

SheetsToolset overloads LLM with 500k+ tokens caused by loaded tools

Open SAMFVH opened this issue 1 year ago • 2 comments

The sheets_spreadsheets_create tool within SheetsToolset contains an excessively verbose schema, causing the initial prompt to contain over 500k tokens. With over 100,000 references to color properties and styling options, causing massive token consumption that makes the toolset unusable in practice. To Reproduce

Steps to reproduce the behavior:

Create an agent which loads the google api toolset: SheetsToolset:

Install pip install google-adk==1.4.2 Initialize SheetsToolset and inspect the create tool:

Set a breakpoint to googleapi_to_openapi_converter.py line 106.

def convert(self) -> Dict[str, Any]: """Convert the Google API spec to OpenAPI v3 format.

Returns:
    Dict containing the converted OpenAPI v3 specification
"""
if not self._google_api_spec:
  self.fetch_google_api_spec()

# Convert basic API information
self._convert_info()

# Convert server information
self._convert_servers()

# Convert authentication/authorization schemes
self._convert_security_schemes()

# Convert schemas (models)
self._convert_schemas()

# Convert endpoints/paths
self._convert_resources(self._google_api_spec.get("resources", {}))

# Convert top-level methods, if any
self._convert_methods(self._google_api_spec.get("methods", {}), "/")

return self._openapi_spec

Tokencount exceeds 500k tokens.

Count occurrences of "color" in the schema Observe 100,000+ color-related properties in the spec

Expected behavior The sheets_spreadsheets_create endpoint should have a minimal schema focused on essential properties without exhaustive styling options. Color and formatting properties should be optional or excluded from the base tool. Creating a sheet, editing, updating, basic formatting.

OS: macOS 15.5 Python version: 3.11.0 ADK version: 1.4.2

Model Information: Affects all models - the schema alone exceeds most context windows before any actual usage Used gemini-2.5-pro.

The Google Sheets API discovery document includes comprehensive styling options for every possible cell property (backgroundColor, foregroundColor, borders, etc.) with full RGBA specifications. This is multiplied across:

Cell properties Row properties Column properties Sheet properties Conditional formatting rules Chart specifications

Recommended fix: Create an LLM proof (minimal) open api spec.

SAMFVH avatar Jul 23 '25 08:07 SAMFVH

+1

Also encountering this issue. The SheetsToolset is basically unusable due to large token count. My agent can't handle 1 call to the toolset.

jiya-zhang avatar Oct 28 '25 00:10 jiya-zhang

Thanks for reporting this issue.

This has to be solved by the Sheets API team.

For example, we have BQ team contributing the BQ tools that tailored for Agents/ADK. Please reach out to the sheets API team to contribute such an API. Thanks.

hangfei avatar Oct 28 '25 20:10 hangfei