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, LLMConfig, EmbeddingConfig

client = create_client() 

# set default llm config for agents
client.set_default_llm_config(
    LLMConfig.default_config(model_name="gpt-4o-mini")
)

# set default embedding config for agents
client.set_default_embedding_config(
    EmbeddingConfig.default_config(model_name="text-embedding-ada-002")
)

# create an agent with no tools
agent_state = client.create_agent(include_base_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, Composio, and CrewAI. These integrations work by converting external libraries’ tools into Letta tools.

Langchain Tools

Letta supports adding tools from Langchain. To use tools from Langchain, make sure you run pip install 'letta[external-tools]' to install the necessary dependencies.

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)

Now, you can include to tool when you create agents with Letta. See a working example here.

Composio Tools

To use Letta with Composio tools, make sure you install dependencies with pip install 'letta[external-tools]. Then, make sure you log in to Composio and add any necessary authentication.

composio login
composio add github

For example, to use

from composio_langchain import Action

# Add the composio tool
tool = Tool.get_composio_tool(
    action=Action.GITHUB_STAR_A_REPOSITORY_FOR_THE_AUTHENTICATED_USER
)

# persist the tool
client.add_tool(tool)

Now, you can include the tool to be used with your agent. See a working example here.

CrewAI Tools

Letta also supports adding tools from CrewAI. Make sure you first run pip install 'letta[external-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)

Now, you can include the tool when you create agents with Letta. See a working example here.