Documentation Index Fetch the complete documentation index at: https://docs.definable.ai/llms.txt
Use this file to discover all available pages before exploring further.
A Toolkit is a collection of related tools packaged together. Instead of managing individual tool functions, you group them into a class that can be shared across agents and projects.
Subclass Toolkit and define tool methods:
from definable.agent import Toolkit
from definable.tool.decorator import tool
class MathToolkit ( Toolkit ):
@tool
def add ( self , a : float , b : float ) -> float :
"""Add two numbers."""
return a + b
@tool
def multiply ( self , a : float , b : float ) -> float :
"""Multiply two numbers."""
return a * b
@tool
def divide ( self , a : float , b : float ) -> str :
"""Divide two numbers."""
if b == 0 :
return "Error: Division by zero"
return str (a / b)
Tools are discovered automatically — any method decorated with @tool is included.
Pass toolkit instances to an agent:
from definable.agent import Agent
from definable.model import OpenAIChat
agent = Agent(
model = OpenAIChat( id = "gpt-4o" ),
toolkits = [MathToolkit()],
)
output = agent.run( "What is 15 * 23, then divide the result by 5?" )
print (output.content)
Pass shared dependencies that all tools in the toolkit can access:
class DatabaseToolkit ( Toolkit ):
def __init__ ( self , connection_string : str ):
self .db = Database(connection_string)
super (). __init__ ()
@tool
def run_query ( self , sql : str ) -> str :
"""Execute a SQL query."""
return str ( self .db.execute(sql))
@tool
def list_tables ( self ) -> str :
"""List all database tables."""
return str ( self .db.get_tables())
# Usage
toolkit = DatabaseToolkit( "postgresql://localhost/mydb" )
agent = Agent( model = model, toolkits = [toolkit])
Agents can use both individual tools and toolkits together:
@tool
def get_current_time () -> str :
"""Get the current time."""
from datetime import datetime
return datetime.now().isoformat()
agent = Agent(
model = OpenAIChat( id = "gpt-4o" ),
tools = [get_current_time],
toolkits = [MathToolkit(), DatabaseToolkit(conn_str)],
)
Property Type Description toolsList[Function]All tool functions in the toolkit namestrToolkit name (defaults to the class name) dependenciesdictShared dependencies dictionary
Definable includes two built-in toolkits:
KnowledgeToolkit Give agents explicit tools to search a knowledge base on demand.
MCPToolkit Expose tools from MCP servers to your agents.