diff --git a/openhands_cli/utils.py b/openhands_cli/utils.py index 1c2bb270..b37d16fe 100644 --- a/openhands_cli/utils.py +++ b/openhands_cli/utils.py @@ -264,6 +264,4 @@ def json_callback(event: Event) -> None: return data = event.model_dump() - pretty_json = json.dumps(data, indent=2, sort_keys=True) - print("--JSON Event--") - print(pretty_json) + print(json.dumps(data)) diff --git a/tests/test_utils.py b/tests/test_utils.py index 47a7262e..29e8a86d 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -194,12 +194,9 @@ def test_json_callback_filters_system_events_and_outputs_others(self): with patch("builtins.print") as mock_print: json_callback(message_event) - # Should have two print calls: header and JSON - assert mock_print.call_count == 2 - mock_print.assert_any_call("--JSON Event--") - - # Verify valid JSON output - json_output = mock_print.call_args_list[1][0][0] + # Should emit a single JSONL line per event + mock_print.assert_called_once() + json_output = mock_print.call_args[0][0] parsed_json = json.loads(json_output) assert isinstance(parsed_json, dict) @@ -216,11 +213,8 @@ def test_json_callback_real_message_event_processing(self): json_callback(event) # Verify the output structure - assert mock_print.call_count == 2 - mock_print.assert_any_call("--JSON Event--") - - # Get and validate the JSON output - json_output = mock_print.call_args_list[1][0][0] + mock_print.assert_called_once() + json_output = mock_print.call_args[0][0] parsed_json = json.loads(json_output) # Verify essential fields are present