diff --git a/src/google/adk/cli/cli.py b/src/google/adk/cli/cli.py index 4802ea4..8f466ad 100644 --- a/src/google/adk/cli/cli.py +++ b/src/google/adk/cli/cli.py @@ -105,6 +105,7 @@ async def run_cli( input_file: Optional[str] = None, saved_session_file: Optional[str] = None, save_session: bool, + session_id: Optional[str] = None, ) -> None: """Runs an interactive CLI for a certain agent. @@ -118,6 +119,7 @@ async def run_cli( saved_session_file: Optional[str], the absolute path to the json file that contains a previously saved session, exclusive with input_file. save_session: bool, whether to save the session on exit. + session_id: Optional[str], the session ID to save the session to on exit. """ if agent_parent_dir not in sys.path: sys.path.append(agent_parent_dir) @@ -175,7 +177,7 @@ async def run_cli( ) if save_session: - session_id = input('Session ID to save: ') + session_id = session_id or input('Session ID to save: ') session_path = f'{agent_module_path}/{session_id}.session.json' # Fetch the session again to get all the details. diff --git a/src/google/adk/cli/cli_tools_click.py b/src/google/adk/cli/cli_tools_click.py index 2898673..ee59b5f 100644 --- a/src/google/adk/cli/cli_tools_click.py +++ b/src/google/adk/cli/cli_tools_click.py @@ -122,6 +122,15 @@ def validate_exclusive(ctx, param, value): default=False, help="Optional. Whether to save the session to a json file on exit.", ) +@click.option( + "--session_id", + type=str, + help=( + "Optional. The session ID to save the session to on exit when" + " --save_session is set to true. User will be prompted to enter a" + " session ID if not set." + ), +) @click.option( "--replay", type=click.Path( @@ -156,6 +165,7 @@ def validate_exclusive(ctx, param, value): def cli_run( agent: str, save_session: bool, + session_id: Optional[str], replay: Optional[str], resume: Optional[str], ): @@ -179,6 +189,7 @@ def cli_run( input_file=replay, saved_session_file=resume, save_session=save_session, + session_id=session_id, ) )