Letta Tools

By default, agents in Letta are created with the following tools:

ToolDescription
send_messageSends a message to the human user.
conversation_searchSearch prior conversation history
conversation_search_dateSearch prior conversation history using a date range
archival_memory_insertAdd a memory to archival memory
archival_memory_searchSearch archival memory via embedding search

Excluding default tools

To skip adding default tools, you can add in include_default_tools=False to the agent creation:

from letta import create_client 

client = create_client() 

# create an agent with no tools
agent_state = client.create_agent(include_default_tools=False) 

Custom Tools

You can create custom tools in Letta in Python. When you define the function for the tool, you must make sure to have a properly formatting docstring for Letta to parse the function schema.

def query_birthday_db(self, name: str): 
    """
    This tool queries an external database to 
    lookup the birthday of someone given their name.

    Args: 
        name (str): The name to look up 

    Returns: 
        birthday (str): The birthday in mm-dd-yyyy format
    
    """
    my_fake_data = {
        "bob": "03-06-1997", 
        "sarah": "03-06-1997"
    } 
    name = name.lower() 
    if name not in my_fake_data: 
        return None
    else: 
        return my_fake_data[name]

birthday_tool = client.create_tool(query_birthday_db)

Adding tools to agents

Once the tool is created, you can add it to an agent by passing the tool name to the tools parameter in the agent creation.

agent_state = client.create_agent(
    name="birthday_agent", 
    tools=[birthday_tool.name], 
)

External Libraries

Letta also has early support for adding tools from external libraries like Langchain and CrewAI.

Langchain Tools

Letta supports adding tools from Langchain.

from langchain_community.tools import TavilySearchResults
from letta.schemas.tool import Tool

# convert the tool to a Letta tool 
search_tool = Tool.from_langchain(TavilySearchResults())

# persist the tool 
client.add_tool(search_tool)

CrewAI Tools

Letta also supports adding tools from CrewAI. Make sure you first run pip install 'letta[crewai-tools]' to install the necessary dependencies.

from crewai_tools import ScrapeWebsiteTool
from letta.schemas.tool import Tool 

# convert the tool to a Letta tool
webscrape_tool = client.create_tool(Tool.from_crewai(ScrapeWebsiteTool()))

# persist the tool
client.add_tool(webscrape_tool)