diff --git a/tests/realtime/test_session.py b/tests/realtime/test_session.py index c1c919a866..9ea712a013 100644 --- a/tests/realtime/test_session.py +++ b/tests/realtime/test_session.py @@ -1505,6 +1505,31 @@ def __str__(self) -> str: assert _serialize_tool_output(BrokenDataclass(lock=threading.Lock())) == "broken-dataclass" + @dataclasses.dataclass + class ToolResult: + label: str + values: list[int] + + @pytest.mark.parametrize( + ("value", "expected"), + [ + pytest.param(None, "null", id="none"), + pytest.param( + ["hello", 1, True, None], + json.dumps(["hello", 1, True, None]), + id="list", + ), + pytest.param( + ToolResult(label="demo", values=[1, 2]), + json.dumps({"label": "demo", "values": [1, 2]}), + id="dataclass", + ), + pytest.param(b"abc", "b'abc'", id="bytes"), + ], + ) + def test_serialize_tool_output_edge_cases(self, value: Any, expected: str) -> None: + assert _serialize_tool_output(value) == expected + @pytest.mark.asyncio async def test_mixed_tool_types_filtering(self, mock_model, mock_agent): """Test that function tools and handoffs are properly separated"""