Tool Forge — Self-Creating Tools System
Agents detect when they need a tool that doesn't exist and write it on the fly. RAG-backed tool discovery keeps context lean by only surfacing relevant tools.
Architecture
Agent needs capability → search tool registry (RAG) → found? use it : create it → index new tool → execute
Components
- registry.py — ChromaDB-backed tool registry with semantic search
- forge.py — Tool creation engine (generates Python tools from natural language specs)
- runner.py — Safe tool execution sandbox
- cli.py — CLI interface:
search,create,run,list,describe
Usage
# Search for an existing tool
python3 cli.py search "convert CSV to JSON"
# Create a new tool on the fly
python3 cli.py create "convert CSV to JSON" --desc "Takes a CSV file path, returns JSON array"
# Run a tool
python3 cli.py run csv_to_json --args '{"file_path": "data.csv"}'
# List all tools
python3 cli.py list
# Index existing tools from the tools/ directory
python3 cli.py index-existing
For Agents
from tool_forge import ToolForge
forge = ToolForge()
# Returns matching tools or creates one if none found
tool = forge.ensure_tool("convert CSV to JSON", auto_create=True)
result = tool.run(file_path="data.csv")