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():
6767
6868from __future__ import annotations as _annotations
6969
70- import asyncio
7170import contextvars
7271import json
7372import logging
@@ -556,19 +555,20 @@ async def execute_async():
556555 logger .exception (f"Async execution failed for { tool_name } " )
557556 self .async_operations .fail_operation (operation .token , str (e ))
558557
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+ )
570571 )
571- )
572572
573573 # tool call
574574 results = await func (tool_name , arguments )
You can’t perform that action at this time.
0 commit comments