Tools (also known as function calling) allow your AI agents to interact with external systems and services, expanding their capabilities beyond text generation. When an LLM needs to perform an action, it calls a tool and uses the result to formulate its response.
What are Tools?
In LarAgent, a Tool is a function or class that an agent can invoke to perform actions or retrieve information. Tools bridge the gap between AI reasoning and real-world operations. Common use cases include:- Fetching data from APIs or databases
- Sending emails or notifications
- Performing calculations
- Interacting with external services
Creating Tools
LarAgent offers three ways to define tools, each suited for different use cases:Tool Attribute
Recommended. Transform agent methods into tools with a simple attribute — best for most use cases.
Tool Classes & Inline
Create reusable tool classes or build tools dynamically at runtime.
Quick Examples
- Tool Attribute
- Tool Class
- Inline Tool
The simplest approach — add the
#[Tool] attribute to any method in your agent class:Tool Execution Flow
When an agent uses tools:1
LLM Decision
The LLM analyzes the conversation and determines a tool call is needed.
2
Tool Invocation
LarAgent automatically executes the requested tool with the provided arguments.
3
Result Processing
The tool’s return value is sent back to the LLM as context.
4
Response Generation
The LLM uses the tool result to formulate its final response.

