Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions openhands_cli/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
16 changes: 5 additions & 11 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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
Expand Down