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

Error adk_web_server.py:1431 - Error in event_generator: Failed to parse the parameter file_patterns: List[str] | None = None of function cleanup_unused_files

Open rrbemfica opened this issue 1 month ago • 5 comments

** Please make sure you read the contribution guide and file the issues in the right place. ** Contribution guide.

Describe the bug When I tried to edit an agent in builder mode in adk web, I got the following error:

adk_web_server.py:1431 - Error in event_generator: Failed to parse the parameter file_patterns: List[str] | None = None of function cleanup_unused_files for automatic function calling. Automatic function calling works best with simpler function signature schema, consider manually parsing your function declaration for function cleanup_unused_files.

I was not able to use the AI chat to interact with builder.

To Reproduce Steps to reproduce the behavior:

  1. Install adk.
  2. run adk web
  3. Open adk web editor, create a new agent.
  4. Error in console: adk_web_server.py:1431 - Error in event_generator: Failed to parse the parameter file_patterns: List[str] | None = None of function cleanup_unused_files for automatic function calling. Automatic function calling works best with simpler function signature schema, consider manually parsing your function declaration for function cleanup_unused_files.

Expected behavior I was expecting to use the assistant to create the agent.

Screenshots N/A, no aparent error on the UI

Desktop (please complete the following information):

  • OS: macOS
  • Python version(python -V): 3.14
  • ADK version(pip show google-adk): 1.18.0

Model Information:

  • Are you using LiteLLM: No
  • Which model is being used: gemini-2.5-flash

Additional context N/A

rrbemfica avatar Nov 18 '25 01:11 rrbemfica

Hi @ymodak , could your team help reproduce before assign this back to @wyf7107 ? Thanks!

DeanChensj avatar Nov 19 '25 01:11 DeanChensj

@rrbemfica The issue is that ADK's function parser doesn't support Python 3.10+ pipe operator union syntax (|) in function signatures. As a workaround, replace List[str] | None with Union[List[str], None] from the typing module, or better yet, make the parameter required (List[str]) and handle the None case inside your function. This will allow the web builder to parse your functions correctly. Thanks!

surajksharma07 avatar Nov 19 '25 09:11 surajksharma07

@rrbemfica The issue is that ADK's function parser doesn't support Python 3.10+ pipe operator union syntax (|) in function signatures. As a workaround, replace List[str] | None with Union[List[str], None] from the typing module, or better yet, make the parameter required (List[str]) and handle the None case inside your function. This will allow the web builder to parse your functions correctly. Thanks!

Is the documentation incorrect, then? https://google.github.io/adk-docs/tools-custom/function-tools/#required-parameters

Is the parser broken, or the documentation wrong. Either way, something needs to get fixed.

busbaby avatar Nov 30 '25 16:11 busbaby

@busbaby the documentation shows the modern pipe operator syntax because that's the recommended Python 3.10+ style, but the parser hasn't been updated to support it yet.

This is definitely a bug in the parser that needs fixing.

We'll prioritize updating the parser to handle both Union[X, Y] and X | Y syntax so it matches what the docs show. Thanks!

surajksharma07 avatar Nov 30 '25 17:11 surajksharma07

@wyf7107 Please have a look into it.

surajksharma07 avatar Nov 30 '25 17:11 surajksharma07