Toolsets#
Toolsets extend agent capabilities by providing access to external functions, APIs, and services. They are bundled with the pantheon-agents package and can be used directly with agents.
Installation#
Toolsets are included with the core pantheon-agents package:
pip install pantheon-agents
All toolset dependencies are included:
Python code execution
Jupyter notebook integration
Web browsing and scraping
File operations
Code parsing (tree-sitter)
Overview#
Pantheon’s toolset system provides a unified interface for extending agent capabilities:
Local Execution: Tools run in the same process as the agent
Tool Decorator: Methods decorated with
@toolare automatically exposed to agentsType Safety: Automatic parameter validation from type hints
Async Support: Full support for async tool implementations
Architecture#
The toolset system consists of:
ToolSet Base Class: Base class that all toolsets inherit from
Tool Decorator: Marks methods as tools with docstring descriptions
Provider System: Handles tool discovery and execution
Built-in Toolsets#
File Operations#
FileManagerToolSet - Comprehensive file operations
read_file: Read file contents with optional line rangewrite_file: Write/create filesupdate_file: String replacement editingmanage_path: Create/delete/move files and directoriesglob: Pattern-based file searchgrep: Content search with regexapply_patch: Apply unified diff or V4A patchesobserve_images: Analyze images with LLM visionread_pdf: Extract text from PDFs
FileTransferToolSet - Chunked file transfer with streaming support
open_file_for_write: Get file handle for writingwrite_chunk: Write data chunks to open fileclose_file: Close file handleread_file: Read file with base64 encoding
Code Execution#
PythonInterpreterToolSet - Execute Python code in isolated environment
run_python_code: Execute Python with auto session managementmanage_interpreters: Create, list, delete interpreter sessions
ShellToolSet - Run shell commands with timeout support
run_command: Execute shell commandsget_shell_output: Fetch output from background commandsclose_shell: Close shell sessions
RInterpreterToolSet - Execute R code with session management
run_r_code: Execute R code with auto session managementnew_interpreter,delete_interpreter: Interpreter management
JuliaInterpreterToolSet - Execute Julia code with session management
run_julia_code: Execute Julia code with interpreter managementnew_interpreter,delete_interpreter: Interpreter management
IntegratedNotebookToolSet - Jupyter notebook with kernel management
create_notebook: Create or open notebooksadd_cell,update_cell,delete_cell: Cell operationsexecute_cell: Execute cells with output capturemanage_kernel: Restart, interrupt, shutdown kernels
Code Analysis#
CodeToolSet - Code navigation with tree-sitter AST analysis
view_file_outline: Get structural outline of code filesview_code_item: Extract specific code items by name
Web & Search#
WebToolSet - Web search and content retrieval
duckduckgo_search: Web search via DuckDuckGoweb_crawl: Fetch and extract content from URLs as markdown
Scraper API - Advanced web scraping with JavaScript rendering
scrape_url: Scrape with CSS/XPath selectorsSupports pagination, infinite scroll, screenshots
Knowledge & RAG#
KnowledgeToolSet - Knowledge base management with hybrid search
search_knowledge: Semantic + keyword search with Qdrantcreate_collection,delete_collection: Collection managementadd_source,remove_source: Document source managementindex_source: Index documents into vector store
Vector RAG - Vector-based retrieval augmented generation
Vector store integration
Document indexing and retrieval
Media#
ImageGenerationToolSet - AI image generation
generate_image: Create images with DALL-E, Gemini, or other providersSupports text prompts and image references
Database#
DatabaseAPIQueryToolSet - Biological database queries (26+ databases)
query: Query any supported databaselist_databases: List available databasesdatabase_info: Get database schema and examples
Workflow & Learning#
TaskToolSet - Modal workflow management
task_boundary: Track task progress and mode transitionsnotify_user: User communication with confidence scoring
SkillbookToolSet - Skill management for learning agents
add_skill,update_skill,remove_skill: Skill CRUDtag_skill: Track skill effectiveness (helpful/harmful)list_skills: Search and filter skills
PackageToolSet - Package and tool discovery
search_tools: Keyword or semantic search for toolssearch_packages: List and filter available packages
Evolution & Evaluation#
EvolutionToolSet - Evolutionary code optimization
evolve_code: Optimize single code filesevolve_codebase: Optimize multi-file projectsget_evolution_status: Monitor evolution progress
EvaluatorToolSet - Code evaluation and quality assessment
evaluate_code: Run custom evaluators on codeevaluate_codebase: Evaluate entire projectscompute_code_metrics: Static code metricsget_llm_code_review: AI-powered code review
Quick Start#
Using Built-in Toolsets#
Method 1: In Constructor
from pantheon.agent import Agent
from pantheon.toolsets import FileManagerToolSet, ShellToolSet
# Create toolsets
file_tools = FileManagerToolSet(name="files")
shell_tools = ShellToolSet(name="shell")
# Create agent and add toolsets at runtime
agent = Agent(
name="developer",
instructions="You are a developer assistant."
)
await agent.toolset(file_tools)
await agent.toolset(shell_tools)
await agent.chat()
Alternative: Chained calls
from pantheon.agent import Agent
from pantheon.toolsets import FileManagerToolSet, ShellToolSet
# Create agent first
agent = Agent(
name="developer",
instructions="You are a developer assistant."
)
# Add toolsets dynamically
await agent.toolset(FileManagerToolSet(name="files"))
await agent.toolset(ShellToolSet(name="shell"))
await agent.chat()
Creating Custom Tools#
from pantheon.toolset import ToolSet, tool
class MyToolSet(ToolSet):
@tool
def calculate(self, expression: str) -> float:
"""Evaluate a mathematical expression.
Args:
expression: The mathematical expression to evaluate
Returns:
The result of the calculation
"""
return eval(expression)
@tool
async def fetch_data(self, url: str) -> str:
"""Fetch data from a URL asynchronously."""
import aiohttp
async with aiohttp.ClientSession() as session:
async with session.get(url) as response:
return await response.text()
# Use with agent
agent = Agent(
name="assistant",
instructions="You are a helpful assistant."
)
await agent.toolset(MyToolSet(name="my_tools"))
Tool Decorator Options#
from pantheon.toolset import tool
class AdvancedToolSet(ToolSet):
@tool
def cpu_intensive_task(self, data: str) -> str:
"""CPU-intensive work."""
# Heavy computation here
return result
@tool
def io_bound_task(self, path: str) -> str:
"""I/O operations."""
# I/O operations here
return result
Creating Custom ToolSets#
Need specialized functionality? Create custom toolsets by extending the base ToolSet class. See Creating Custom ToolSets for a complete guide with examples including:
Session management for multi-user scenarios
Accessing execution context
Lifecycle methods (setup/cleanup)
Calling the LLM from within tools
from pantheon.toolset import ToolSet, tool
class TodoToolSet(ToolSet):
def __init__(self, name: str):
super().__init__(name)
self.todos = {}
@tool
async def add_todo(self, title: str, priority: str = "medium") -> dict:
"""Add a new todo item.
Args:
title: The todo item title
priority: Priority level (low, medium, high)
"""
session_id = self.get_session_id()
# Per-session storage
if session_id not in self.todos:
self.todos[session_id] = []
todo = {"id": len(self.todos[session_id]) + 1, "title": title}
self.todos[session_id].append(todo)
return {"success": True, "todo": todo}
Best Practices#
Clear Docstrings: Write descriptive docstrings - they become the tool description for the LLM
Type Hints: Always use type hints for parameters and return values
Error Handling: Handle errors gracefully and return informative error messages
Async When Possible: Use async for I/O-bound operations
Resource Cleanup: Implement cleanup in toolset lifecycle methods
MCP Integration#
Toolsets can be exposed as MCP (Model Context Protocol) servers:
from pantheon.endpoint.mcp import MCPGateway
from pantheon.toolsets import FileManagerToolSet
gateway = MCPGateway()
gateway.add_toolset(FileManagerToolSet("files"))
await gateway.serve()
See Utils Module for more details on MCP integration.