Skip to content
Closed
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/agents/tool.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import annotations

import asyncio
import inspect
import json
from collections.abc import Awaitable
Expand Down Expand Up @@ -413,9 +414,9 @@ async def _on_invoke_tool_impl(ctx: ToolContext[Any], input: str) -> Any:
result = await the_func(*args, **kwargs_dict)
else:
if schema.takes_context:
result = the_func(ctx, *args, **kwargs_dict)
result = await asyncio.to_thread(the_func, ctx, *args, **kwargs_dict)
else:
result = the_func(*args, **kwargs_dict)
result = await asyncio.to_thread(the_func, *args, **kwargs_dict)

if _debug.DONT_LOG_TOOL_DATA:
logger.debug(f"Tool {schema.name} completed.")
Expand Down