@@ -714,7 +714,7 @@ async def test_async_tool_basic(server_transport: str, server_url: str) -> None:
714
714
assert result .serverInfo .name == "Async Tool Basic"
715
715
716
716
# Test sync tool (should work normally)
717
- sync_result = await session .call_tool ("process_text " , {"text" : "hello" })
717
+ sync_result = await session .call_tool ("process_text_sync " , {"text" : "hello" })
718
718
assert len (sync_result .content ) == 1
719
719
assert isinstance (sync_result .content [0 ], TextContent )
720
720
assert sync_result .content [0 ].text == "Processed: HELLO"
@@ -745,11 +745,30 @@ async def test_async_tool_basic(server_transport: str, server_url: str) -> None:
745
745
else :
746
746
pytest .fail ("Async operation timed out" )
747
747
748
- # Test hybrid tool (process_text can work in sync or async mode)
748
+ # Test hybrid tool (process_text should only run in async mode in this version )
749
749
hybrid_result = await session .call_tool ("process_text" , {"text" : "world" })
750
- assert len (hybrid_result .content ) == 1
751
- assert isinstance (hybrid_result .content [0 ], TextContent )
752
- assert "Processed: WORLD" in hybrid_result .content [0 ].text
750
+ assert hybrid_result .operation is not None
751
+ token = hybrid_result .operation .token
752
+
753
+ # Poll for completion with timeout
754
+ max_attempts = 20
755
+ attempt = 0
756
+ while attempt < max_attempts :
757
+ status = await session .get_operation_status (token )
758
+ if status .status == "completed" :
759
+ final_hybrid_result = await session .get_operation_result (token )
760
+ assert not final_hybrid_result .result .isError
761
+ assert len (final_hybrid_result .result .content ) == 1
762
+ assert isinstance (final_hybrid_result .result .content [0 ], TextContent )
763
+ assert "Processed: WORLD" in final_hybrid_result .result .content [0 ].text
764
+ break
765
+ elif status .status == "failed" :
766
+ pytest .fail (f"Async operation failed: { status .error } " )
767
+
768
+ attempt += 1
769
+ await anyio .sleep (0.5 )
770
+ else :
771
+ pytest .fail ("Async operation timed out" )
753
772
754
773
755
774
# Test async tools example with legacy protocol
0 commit comments