Agent API Reference

Agent

class llm_async.agent.Agent(provider: BaseProvider, model: str, tools: list[Callable[[...], Any]], parallel_tools: bool = True, max_iter: int = 10)[source]

Bases: object

Run provider completions with decorated tools until a final response is produced.

The agent passes its tools to the provider, executes requested tool calls, appends tool results to the message list, and repeats until the model stops requesting tools or max_iter is reached.

Create an agent for a provider, model, and list of decorated tool functions.

async acomplete(messages: Sequence[Message | Mapping[str, Any]], **kwargs: Any) Response[source]

Complete a conversation, automatically executing any tool calls.

Additional keyword arguments are forwarded to the provider’s acomplete call.

Tool Decorator

llm_async.tool.tool(func: Callable[[...], Any]) Callable[[...], Any][source]

Decorate a function as an LLM tool.

The decorated function remains callable and receives a tool attribute containing a generated llm_async.models.Tool definition. The generated schema uses the function name, docstring, and supported parameter type annotations.

For examples and supported type annotations, see Agent and Tool Decorator.