@@ -714,7 +714,7 @@ async def test_async_tool_basic(server_transport: str, server_url: str) -> None:
714714 assert result .serverInfo .name == "Async Tool Basic"
715715
716716 # 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" })
718718 assert len (sync_result .content ) == 1
719719 assert isinstance (sync_result .content [0 ], TextContent )
720720 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:
745745 else :
746746 pytest .fail ("Async operation timed out" )
747747
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 )
749749 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" )
753772
754773
755774# Test async tools example with legacy protocol
0 commit comments