Tool
Extending agent capabilities
Agents, by default, are isolated and operate only within the context we provide them. To enable agents to interact with the external world, agents use tools. A tool allows an agent to perform actions or gather additional data based on the input it receives. The results of these actions can be sent back to the LLM, enabling it to refine its next response.
An agent can have multiple tools and can invoke them as needed. Agents may also call tools in sequence to handle more complex tasks.
Tools in AXAR
In AXAR, tools are defined as instance methods and annotated with the @tool
decorator. Since tools are plain typescript methods, they provide a structured interface for the agent to interact with them.
Here’s an example:
What just happened?
Tools are methods
The agent has two tools: getCurrentTime()
and getWeatherInfo()
. Both are annotated with @tool
, which includes a brief description of what each tool does. This annotation makes the tools accessible for the agent to call whenever needed.
Structured input
Tools can only take a single parameter, which must be an object with a defined schema. In this example, getWeatherInfo()
expects a parameter of type WeatherParams
, and its schema is defined using the @schema
annotation.
Dynamic calling
The agent calls getCurrentTime()
and getWeatherInfo()
as needed, preparing any required parameters at runtime. These tools let the agent access external data, like the current time or weather, which it uses to create a more meaningful response.
By combining tools with the agent’s LLM, you can make your agent smarter, allowing it to perform actions, fetch external data, and respond in a more meaningful way.
Last updated