Skip to content

Commit c332dd5

Browse files
committed
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
1 parent d00ad67 commit c332dd5

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

src/google/adk/cli/built_in_agents/tools/cleanup_unused_files.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
from __future__ import annotations
1818

1919
from typing import Any
20+
from typing import List
21+
from typing import Optional
2022

2123
from google.adk.tools.tool_context import ToolContext
2224

@@ -25,10 +27,10 @@
2527

2628

2729
async def cleanup_unused_files(
28-
used_files: list[str],
30+
used_files: List[str],
2931
tool_context: ToolContext,
30-
file_patterns: list[str] | None = None,
31-
exclude_patterns: list[str] | None = None,
32+
file_patterns: Optional[List[str]] = None,
33+
exclude_patterns: Optional[List[str]] = None,
3234
) -> dict[str, Any]:
3335
"""Identify and optionally delete unused files in project directories.
3436

0 commit comments

Comments
 (0)