What is a Tool?

A tool is a predefined function available for an agent to use when it decides to. It augments the LLM model used by the agent to interact with external data sources, APIs, or programs. For example, a tool can fetch the weather in London or sign and submit a transaction to Ethereum to update a portfolio.

Every tool extends the Tool class and specifies:

  • A name used in the prompt for an agent.
  • A description of what the tool does, the inputs it expects, and the output(s) it will return.
  • A type of tool output.
  • Inputs it expects.

Adding tool-use to your agent

Tools are passed to the agent object. The agent can run with any number of tools, including no tools at all.

Prerequisites

Make sure you’ve gone through the quick start guide and have the development environment set up.

Example usage

from galadriel.tools.web3 import dexscreener

agent = CodeAgent(
    model=model,
    tools=[dexscreener.fetch_market_data],
)

In this example, dexscreener.fetch_market_data is a tool available in galadriel.tools.web3.

Complete example code is here.

List of tools provided by Galadriel

Visit the Tools Integration page to explore our growing list of supported tools and learn how to integrate them. You can also leverage tools from Composio and Langchain.

Build your own tools

You can also build your own tools. There are two ways to do it.

Building simple tools

To build simple tools, annotate the function with @tool. Then, right under the function signature, provide the description explaining what the tool does, arguments it expects, and the return format. These values will be used by LLM to evaluate when and how to use the tool.

from galadriel.core_agent import tool

@tool
def get_time(location: str) -> str:
    """
    Get the current time in the given location.
    Args:
        location: the location
    """
    return f"The time in {location} is {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}"

Building more complex tools

To build complex tools, Extend the Tool class similarly to RetrieverTool.

Want to integrate your tool into Galardiel?

Contact our developers on Discord to integrate your tool into the Galadriel framework out of the box.

Conclusion

Tools significantly expand an agent’s capabilities, enabling interaction with external systems and data sources. Whether using built-in tools, third-party integrations, or custom implementations, tools make AI agents more powerful and versatile.

See next