Tools = Agent Capabilities Tools are functions that your agent can call to interact with the world—from simple calculations to complex API integrations, database queries, or external service calls.
Function-Based Convert any Python function into an agent tool with automatic parameter validation
Contextual Access Tools are only available when needed, improving security and reducing confusion
Type Safety Automatic parameter validation and type checking prevent runtime errors
Framework Integration Compatible with existing tools from LangChain, CrewAI, and other frameworks
Basic Python Function
The simplest way to create a tool is with a regular Python function:
# barista_tools.py
def get_available_coffee_options () -> str :
"""
Get available coffee options, sizes, and prices.
Returns:
str: Formatted list of available coffee options with prices
"""
coffee_options = [
{
"type" : "Espresso" ,
"sizes" : [ "Small" , "Medium" , "Large" ],
"prices" : [ 2.5 , 3.0 , 3.5 ],
},
{
"type" : "Latte" ,
"sizes" : [ "Small" , "Medium" , "Large" ],
"prices" : [ 3.0 , 3.5 , 4.0 ],
}
]
result = "Available Coffee Options: \n "
for option in coffee_options:
result += f " { option[ 'type' ] } : "
for size, price in zip (option[ 'sizes' ], option[ 'prices' ]):
result += f " { size } ($ { price } ) "
result += " \n "
return result
def add_to_cart ( coffee_type : str , size : str , price : float ) -> str :
"""
Add a coffee item to the customer's cart.
Args:
coffee_type: Type of coffee (e.g., Espresso, Latte, Cappuccino)
size: Size of the coffee (Small, Medium, Large)
price: Price of the coffee item
Returns:
str: Confirmation message with updated cart total
"""
# Implementation logic here
item = {
"coffee_type" : coffee_type,
"size" : size,
"price" : price,
"id" : generate_item_id()
}
coffee_cart.append(item)
current_total = sum (item[ "price" ] for item in coffee_cart)
return f "Added { size } { coffee_type } to cart. Current total: $ { current_total :.2f} "
# Export tools for discovery
tools = [get_available_coffee_options, add_to_cart]
In YAML Configuration
Tools are referenced in your agent configuration:
name : barista
persona : "You are a helpful barista assistant..."
start_step_id : start
steps :
- step_id : start
description : "Greet customer and show menu options"
available_tools :
- get_available_coffee_options
routes :
- target : take_coffee_order
condition : Customer is ready to order
- step_id : take_coffee_order
description : "Take and manage coffee orders"
available_tools :
- get_available_coffee_options
- add_to_cart
- remove_item
- clear_cart
routes :
- target : finalize_order
condition : Customer wants to finalize order
# Tool configuration
tools :
tool_files :
- barista_tools.py
tool_arg_descriptions :
add_to_cart :
coffee_type : "Type of coffee (e.g., Espresso, Latte, Cappuccino)"
size : "Size of the coffee (Small, Medium, Large)"
price : "Price of the coffee"
You can provide additional context for tools:
tools :
tool_files :
- financial_tools.py
- external_apis.py
tool_defs :
calculate_budget :
args :
- key : monthly_income
type : float
description : "User's monthly income in dollars"
- key : has_dependents
type : bool
description : "Whether the user has dependents"
get_stock_price :
args :
- key : symbol
type : str
description : "Stock symbol (e.g., AAPL, GOOGL)"
- key : exchange
type : str
description : "Stock exchange (optional)"
Next Steps
External Tools Learn about integrating Python packages, CrewAI, and LangChain tools
Security & Best Practices Security considerations and tool development best practices
Testing Tools Learn how to test your tools independently
Examples See complete examples of tools in action