Compare commits

...

3 Commits

Author SHA1 Message Date
Engel Nyst 0a692cb7b9 debug 2025-06-19 17:38:04 +02:00
Engel Nyst 5156fe958b Merge branch 'main' of github.com:All-Hands-AI/OpenHands into enyst/cli-args 2025-06-19 16:59:08 +02:00
Engel Nyst cc86e32598 read command line args in CLI 2025-06-19 16:47:59 +02:00
3 changed files with 15 additions and 8 deletions
+9 -3
View File
@@ -1,3 +1,4 @@
import argparse
import asyncio
import logging
import os
@@ -348,9 +349,10 @@ async def run_setup_flow(config: OpenHandsConfig, settings_store: FileSettingsSt
await modify_llm_settings_basic(config, settings_store)
async def main_with_loop(loop: asyncio.AbstractEventLoop) -> None:
async def main_with_loop(
loop: asyncio.AbstractEventLoop, args: argparse.Namespace
) -> None:
"""Runs the agent in CLI mode."""
args = parse_arguments()
logger.setLevel(logging.WARNING)
@@ -455,10 +457,14 @@ async def main_with_loop(loop: asyncio.AbstractEventLoop) -> None:
def main():
"""Main entry point for the OpenHands CLI."""
print(f'DEBUG: sys.argv = {sys.argv}')
args = parse_arguments()
print(f'DEBUG: parsed args.config_file = {args.config_file}')
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
try:
loop.run_until_complete(main_with_loop(loop))
loop.run_until_complete(main_with_loop(loop, args))
except KeyboardInterrupt:
print('Received keyboard interrupt, shutting down...')
except ConnectionRefusedError as e:
+1
View File
@@ -288,6 +288,7 @@ class LLM(RetryMixin, DebugMixin):
# Record start time for latency measurement
start_time = time.time()
# we don't support streaming here, thus we get a ModelResponse
logger.warning(f'LLM: {self.config.model}\n{self.config.base_url}')
resp: ModelResponse = self._completion_unwrapped(*args, **kwargs)
# Calculate and record latency
+5 -5
View File
@@ -379,7 +379,7 @@ async def test_main_without_task(
mock_run_session.return_value = False
# Run the function
await cli.main_with_loop(loop)
await cli.main_with_loop(loop, mock_args)
# Assertions
mock_parse_args.assert_called_once()
@@ -462,7 +462,7 @@ async def test_main_with_task(
mock_run_session.side_effect = [True, False]
# Run the function
await cli.main_with_loop(loop)
await cli.main_with_loop(loop, mock_args)
# Assertions
mock_parse_args.assert_called_once()
@@ -557,7 +557,7 @@ async def test_main_with_session_name_passes_name_to_run_session(
mock_run_session.return_value = False
# Run the function
await cli.main_with_loop(loop)
await cli.main_with_loop(loop, mock_args)
# Assertions
mock_parse_args.assert_called_once()
@@ -718,7 +718,7 @@ async def test_main_security_check_fails(
mock_check_security.return_value = False
# Run the function
await cli.main_with_loop(loop)
await cli.main_with_loop(loop, mock_args)
# Assertions
mock_parse_args.assert_called_once()
@@ -801,7 +801,7 @@ async def test_config_loading_order(
mock_run_session.return_value = False # No new session requested
# Run the function
await cli.main_with_loop(loop)
await cli.main_with_loop(loop, mock_args)
# Assertions for argument parsing and config setup
mock_parse_args.assert_called_once()