Skip to content

Commit cbedafd

Browse files
guptaishaancopybara-github
authored andcommitted
fix: use typing.Optional in cleanup_unused_files to fix parse error
The `cleanup_unused_files` tool was declared with `list[str] | None` union-type annotations (PEP 604 / Python 3.10+ syntax). ADK's automatic function calling schema parser does not support this syntax, causing the error "Failed to parse the parameter file_patterns: List[str] | None = None" whenever the agent builder assistant was invoked. The fix replaces the two affected parameters (`file_patterns` and `used_files`) with `Optional[List[str]]` and `List[str]` from the `typing` module, which is the style already used throughout the other tool files in the same package (e.g. `delete_files.py`). No behaviour change — only the type annotation form is updated. Fixes #3591 Merge #6502 PiperOrigin-RevId: 958737849
1 parent ad9c113 commit cbedafd

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)