Skip to content
Open
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
25 changes: 25 additions & 0 deletions tests/realtime/test_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"""
Expand Down