File tree Expand file tree Collapse file tree 1 file changed +13
-13
lines changed Expand file tree Collapse file tree 1 file changed +13
-13
lines changed Original file line number Diff line number Diff line change @@ -67,7 +67,6 @@ async def main():
67
67
68
68
from __future__ import annotations as _annotations
69
69
70
- import asyncio
71
70
import contextvars
72
71
import json
73
72
import logging
@@ -556,19 +555,20 @@ async def execute_async():
556
555
logger .exception (f"Async execution failed for { tool_name } " )
557
556
self .async_operations .fail_operation (operation .token , str (e ))
558
557
559
- asyncio .create_task (execute_async ())
560
-
561
- # Return operation result with immediate content
562
- logger .info (f"Returning async operation result for { tool_name } " )
563
- return types .ServerResult (
564
- types .CallToolResult (
565
- content = immediate_content ,
566
- operation = types .AsyncResultProperties (
567
- token = operation .token ,
568
- keepAlive = operation .keep_alive ,
569
- ),
558
+ async with anyio .create_task_group () as tg :
559
+ tg .start_soon (execute_async )
560
+
561
+ # Return operation result with immediate content
562
+ logger .info (f"Returning async operation result for { tool_name } " )
563
+ return types .ServerResult (
564
+ types .CallToolResult (
565
+ content = immediate_content ,
566
+ operation = types .AsyncResultProperties (
567
+ token = operation .token ,
568
+ keepAlive = operation .keep_alive ,
569
+ ),
570
+ )
570
571
)
571
- )
572
572
573
573
# tool call
574
574
results = await func (tool_name , arguments )
You can’t perform that action at this time.
0 commit comments