From c332dd50135dbbfc7fc5ae73fadbb9d6b2e2b6bb Mon Sep 17 00:00:00 2001 From: Zaid Date: Tue, 23 Jun 2026 00:33:02 +0530 Subject: [PATCH] fix(cli): use Optional[List[str]] in cleanup_unused_files to fix parser error ADK's automatic function calling system cannot parse the PEP 604 union syntax `list[str] | None` when building the tool schema for Gemini. This causes the following error every time the ADK web server runs: Failed to parse the parameter file_patterns: List[str] | None = None of function cleanup_unused_files for automatic function calling All sibling tools in this directory (delete_files.py, read_files.py, write_files.py, etc.) already use `Optional[List[str]]` from `typing`. This commit aligns cleanup_unused_files.py with that established pattern. Changes: - Add `from typing import List` and `from typing import Optional` - Replace `list[str] | None` with `Optional[List[str]]` on both optional parameters (file_patterns, exclude_patterns) - Change `used_files: list[str]` to `used_files: List[str]` for style consistency with sibling tools Fixes #3591 --- .../adk/cli/built_in_agents/tools/cleanup_unused_files.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/google/adk/cli/built_in_agents/tools/cleanup_unused_files.py b/src/google/adk/cli/built_in_agents/tools/cleanup_unused_files.py index 7ceca3832ea..2271ce3546c 100644 --- a/src/google/adk/cli/built_in_agents/tools/cleanup_unused_files.py +++ b/src/google/adk/cli/built_in_agents/tools/cleanup_unused_files.py @@ -17,6 +17,8 @@ from __future__ import annotations from typing import Any +from typing import List +from typing import Optional from google.adk.tools.tool_context import ToolContext @@ -25,10 +27,10 @@ async def cleanup_unused_files( - used_files: list[str], + used_files: List[str], tool_context: ToolContext, - file_patterns: list[str] | None = None, - exclude_patterns: list[str] | None = None, + file_patterns: Optional[List[str]] = None, + exclude_patterns: Optional[List[str]] = None, ) -> dict[str, Any]: """Identify and optionally delete unused files in project directories.