From a134ba6f7a09bb7728ce4f36413d657f0557feb5 Mon Sep 17 00:00:00 2001 From: "Xiang (Sean) Zhou" Date: Fri, 23 May 2025 18:05:48 -0700 Subject: [PATCH] feat: add toolset cleanup logic to run_cli PiperOrigin-RevId: 762638389 --- src/google/adk/cli/cli.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/google/adk/cli/cli.py b/src/google/adk/cli/cli.py index 6d267de..d23cd7e 100644 --- a/src/google/adk/cli/cli.py +++ b/src/google/adk/cli/cli.py @@ -96,6 +96,7 @@ async def run_interactively( if event.content and event.content.parts: if text := ''.join(part.text or '' for part in event.content.parts): click.echo(f'[{event.author}]: {text}') + await runner.close() async def run_cli( @@ -145,7 +146,7 @@ async def run_cli( input_path=input_file, ) elif saved_session_file: - with open(saved_session_file, 'r') as f: + with open(saved_session_file, 'r', encoding='utf-8') as f: loaded_session = Session.model_validate_json(f.read()) if loaded_session: @@ -184,7 +185,7 @@ async def run_cli( user_id=session.user_id, session_id=session.id, ) - with open(session_path, 'w') as f: + with open(session_path, 'w', encoding='utf-8') as f: f.write(session.model_dump_json(indent=2, exclude_none=True)) print('Session saved to', session_path)