Skip to main content
Definable fully supports async tool functions. Use them when your tool performs I/O operations like HTTP requests, database queries, or file operations.

Defining Async Tools

Use async def with the @tool decorator:
The tool is used exactly the same way as a sync tool — the agent runtime handles the async execution automatically.

Using Async Tools

Async tools work with both sync and async agent execution:

When to Use Async Tools

Use async tools when your function:
  • Makes HTTP requests
  • Queries a database
  • Reads or writes files
  • Calls other async services
  • Performs any I/O that benefits from non-blocking execution

Async with Dependencies

Dependency injection works the same way with async tools:

Async with Hooks

Hooks can also be async:

Generators

Definable also supports generator and async generator tools for streaming results:

Mixing Sync and Async

You can freely mix sync and async tools on the same agent. The runtime handles both: