π OpenHands: AI-Driven Development
Load previous conversation by id (CLI) (#10156)
Engel Nyst73a7c7786db2
diff --git a/openhands/cli/main.py b/openhands/cli/main.pyindex 647d4459a6..fd5f8b18cc 100644--- a/openhands/cli/main.py+++ b/openhands/cli/main.py@@ -129,12 +129,13 @@ async def run_session(conversation_instructions: str | None = None,session_name: str | None = None,skip_banner: bool = False,+ conversation_id: str | None = None,) -> bool:reload_microagents = Falsenew_session_requested = Falseexit_reason = ExitReason.INTENTIONAL- sid = generate_sid(config, session_name)+ sid = conversation_id or generate_sid(config, session_name)is_loaded = asyncio.Event()is_paused = asyncio.Event() # Event to track agent pause requestsalways_confirm_mode = False # Flag to enable always confirm mode@@ -705,6 +706,7 @@ After reviewing the file, please ask the user what they would like to do with ittask_str,session_name=args.name,skip_banner=banner_shown,+ conversation_id=args.conversation,)# If a new session was requested, run itdiff --git a/openhands/core/config/utils.py b/openhands/core/config/utils.pyindex 7191a92e6f..81ac040a5f 100644--- a/openhands/core/config/utils.py+++ b/openhands/core/config/utils.py@@ -770,6 +770,12 @@ def get_parser() -> argparse.ArgumentParser:type=str,default='',)+ parser.add_argument(+ '--conversation',+ help='The conversation id to continue',+ type=str,+ default=None,+ )parser.add_argument('--eval-ids',default=None,diff --git a/tests/unit/test_arg_parser.py b/tests/unit/test_arg_parser.pyindex 6858c858a4..619b24b63f 100644--- a/tests/unit/test_arg_parser.py+++ b/tests/unit/test_arg_parser.py@@ -139,13 +139,14 @@ def test_help_message(capsys):'--selected-repo SELECTED_REPO','--override-cli-mode OVERRIDE_CLI_MODE','--log-level LOG_LEVEL',+ '--conversation CONVERSATION',]for element in expected_elements:assert element in help_output, f"Expected '{element}' to be in the help message"option_count = help_output.count(' -')- assert option_count == 21, f'Expected 21 options, found {option_count}'+ assert option_count == 22, f'Expected 22 options, found {option_count}'def test_selected_repo_format():diff --git a/tests/unit/test_cli.py b/tests/unit/test_cli.pyindex ffe3024d40..2eb5df7492 100644--- a/tests/unit/test_cli.py+++ b/tests/unit/test_cli.py@@ -359,6 +359,7 @@ async def test_main_without_task(mock_args.llm_config = Nonemock_args.name = Nonemock_args.file = None+ mock_args.conversation = Nonemock_parse_args.return_value = mock_args# Mock config@@ -412,6 +413,7 @@ async def test_main_without_task(None,session_name=None,skip_banner=False,+ conversation_id=None,)@@ -553,6 +555,7 @@ async def test_main_with_session_name_passes_name_to_run_session(mock_args.llm_config = Nonemock_args.name = test_session_name # Set the session namemock_args.file = None+ mock_args.conversation = Nonemock_parse_args.return_value = mock_args# Mock config@@ -606,6 +609,7 @@ async def test_main_with_session_name_passes_name_to_run_session(None,session_name=test_session_name,skip_banner=False,+ conversation_id=None,)