Skip to content

Commit b4531db

Browse files
claude89757eavanvalkenburg
authored andcommitted
Fix failing tests for prepare_function_call_results behavior
- test_tool_result_with_none: Update expected value to 'null' (JSON serialization of None) - test_tool_result_with_model_dump_objects: Use Pydantic BaseModel instead of plain class
1 parent d3621a6 commit b4531db

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

python/packages/ag-ui/tests/test_events_comprehensive.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,8 @@ async def test_tool_result_with_none():
201201
assert len(events) == 2
202202
assert events[0].type == "TOOL_CALL_END"
203203
assert events[1].type == "TOOL_CALL_RESULT"
204-
assert events[1].content == ""
204+
# prepare_function_call_results serializes None as JSON "null"
205+
assert events[1].content == "null"
205206

206207

207208
async def test_multiple_tool_results_in_sequence():
@@ -759,20 +760,18 @@ def __init__(self, text: str):
759760

760761

761762
async def test_tool_result_with_model_dump_objects():
762-
"""Test FunctionResultContent with objects that have model_dump method."""
763-
from agent_framework_ag_ui._events import AgentFrameworkEventBridge
763+
"""Test FunctionResultContent with Pydantic BaseModel objects."""
764+
from pydantic import BaseModel
764765

765-
class MockModel:
766-
def __init__(self, value: int):
767-
self._value = value
766+
from agent_framework_ag_ui._events import AgentFrameworkEventBridge
768767

769-
def model_dump(self, mode: str = "python"):
770-
return {"value": self._value}
768+
class MockModel(BaseModel):
769+
value: int
771770

772771
bridge = AgentFrameworkEventBridge(run_id="test_run", thread_id="test_thread")
773772

774773
update = AgentRunResponseUpdate(
775-
contents=[FunctionResultContent(call_id="call_123", result=[MockModel(1), MockModel(2)])]
774+
contents=[FunctionResultContent(call_id="call_123", result=[MockModel(value=1), MockModel(value=2)])]
776775
)
777776
events = await bridge.from_agent_run_update(update)
778777

0 commit comments

Comments
 (0)