File tree Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -27,7 +27,9 @@ def _convert_call_tool_result(
2727 non_text_contents .append (content )
2828
2929 tool_content : str | list [str ] = [content .text for content in text_contents ]
30- if len (text_contents ) == 1 :
30+ if not text_contents :
31+ tool_content = ""
32+ elif len (text_contents ) == 1 :
3133 tool_content = tool_content [0 ]
3234
3335 if call_tool_result .isError :
Original file line number Diff line number Diff line change 1919)
2020
2121
22+ def test_convert_empty_text_content ():
23+ # Test with a single text content
24+ result = CallToolResult (
25+ content = [],
26+ isError = False ,
27+ )
28+
29+ text_content , non_text_content = _convert_call_tool_result (result )
30+
31+ assert text_content == ""
32+ assert non_text_content is None
33+
34+
2235def test_convert_single_text_content ():
2336 # Test with a single text content
2437 result = CallToolResult (
You can’t perform that action at this time.
0 commit comments