@@ -16,26 +16,29 @@ async def test_empty_name_returns_error(self):
1616 from cecli .tools .delegate import Tool
1717
1818 result = await Tool .execute (None , delegations = [{"name" : "" , "prompt" : "do it" }])
19- assert "Error" in result
20- assert "name" in result
19+ errors = result .to_dict ()["errors" ]
20+ assert errors
21+ assert "name" in errors [0 ]
2122
2223 @pytest .mark .asyncio
2324 async def test_empty_prompt_returns_error (self ):
2425 """Missing prompt returns error string."""
2526 from cecli .tools .delegate import Tool
2627
2728 result = await Tool .execute (None , delegations = [{"name" : "reviewer" , "prompt" : "" }])
28- assert "Error" in result
29- assert "prompt" in result
29+ errors = result .to_dict ()["errors" ]
30+ assert errors
31+ assert "prompt" in errors [0 ]
3032
3133 @pytest .mark .asyncio
3234 async def test_both_empty_returns_name_error (self ):
3335 """Both empty — name error comes first."""
3436 from cecli .tools .delegate import Tool
3537
3638 result = await Tool .execute (None , delegations = [{"name" : "" , "prompt" : "" }])
37- assert "Error" in result
38- assert "name" in result
39+ errors = result .to_dict ()["errors" ]
40+ assert errors
41+ assert "name" in errors [0 ]
3942
4043 @pytest .mark .asyncio
4144 async def test_valid_delegate_calls_spawn (self ):
@@ -61,8 +64,8 @@ async def test_valid_delegate_calls_spawn(self):
6164 mock_instance .spawn .assert_called_once_with (
6265 "reviewer" , "review this" , parent = mock_coder
6366 )
64- assert "agent started with id" in result
65- assert "child-uuid-123" in result
67+ assert "agent started with id" in str ( result )
68+ assert "child-uuid-123" in str ( result )
6669
6770 async def test_delegate_multiple_delegations (self ):
6871 """Multiple delegations show correct dispatch count."""
@@ -90,9 +93,9 @@ async def spawn_side_effect(name, prompt, parent=None):
9093 ],
9194 )
9295
93- assert "2/2 dispatched" in result
94- assert "agent1" in result
95- assert "agent2" in result
96+ assert "2/2 dispatched" in str ( result )
97+ assert "agent1" in str ( result )
98+ assert "agent2" in str ( result )
9699
97100 @pytest .mark .asyncio
98101 async def test_delegate_spawn_error_returns_error_string (self ):
@@ -106,8 +109,8 @@ async def test_delegate_spawn_error_returns_error_string(self):
106109 MockService .get_instance .return_value = mock_instance
107110
108111 result = await Tool .execute (mock_coder , delegations = [{"name" : "ghost" , "prompt" : "x" }])
109- assert "failed" in result
110- assert "unknown agent" in result
112+ errors = result . to_dict ()[ "result" ]
113+ assert errors
111114
112115 async def test_delegate_runtime_error_returns_error_string (self ):
113116 """RuntimeError from spawn returns error string."""
@@ -122,8 +125,8 @@ async def test_delegate_runtime_error_returns_error_string(self):
122125 result = await Tool .execute (
123126 mock_coder , delegations = [{"name" : "reviewer" , "prompt" : "x" }]
124127 )
125- assert "failed" in result
126- assert "max reached" in result
128+ errors = result . to_dict ()[ "result" ]
129+ assert errors
127130
128131 async def test_unexpected_exception_caught (self ):
129132 """Any other exception returns error string (doesn't propagate)."""
@@ -138,5 +141,5 @@ async def test_unexpected_exception_caught(self):
138141 result = await Tool .execute (
139142 mock_coder , delegations = [{"name" : "reviewer" , "prompt" : "x" }]
140143 )
141- assert "failed" in result
142- assert "unexpected" in result
144+ errors = result . to_dict ()[ "result" ]
145+ assert errors
0 commit comments