async_tools.py
- Provide your Agent with a list of tools, preferably asynchronous for optimal performance. However, synchronous functions can also be used since they will execute concurrently on separate threads.
- Run the Agent using either the
arunoraprint_responsemethod, enabling concurrent execution of tool calls.
Concurrent execution of tools requires a model that supports parallel function
calling. For example, OpenAI models have a
parallel_tool_calls parameter
(enabled by default) that allows multiple tool calls to be requested and
executed simultaneously.gpt-4o makes three simultaneous tool calls to atask1, atask2 and atask3. Normally these tool calls would execute sequentially, but using the aprint_response function, they run concurrently, improving execution time.
