No description
- Python 100%
| example | ||
| README.md | ||
Python Tools
Drop-in Python tools for catboi. Each subdirectory is automatically discovered and registered as an agent tool at startup.
Quick Start
-
Create a new directory under
python-tools/:python-tools/ └── my_tool/ ├── tool.json └── main.py -
Define your tool in
tool.json:{ "name": "my_tool", "description": "What the tool does", "parameters": { "param_name": { "type": "string", "description": "What this parameter is for" } }, "required": ["param_name"] } -
Implement the logic in
main.py:import json import sys args = json.loads(sys.stdin.read()) param = args.get("param_name", "") # ... your logic here ... print("result") -
Restart catboi — the tool is picked up automatically.
How It Works
- The
PythonToolLoaderscans each subdirectory ofpython-tools/for atool.jsonmanifest andmain.pyscript. - For each valid tool directory, a
PythonBridgeToolis created and registered inAgentToolRegistry. - When the LLM calls the tool,
PythonBridgeToolexecutesmain.pyviaProcessBuilder:- Input: Tool arguments are passed as a JSON object to the script's stdin.
- Output: The script's stdout is captured and returned as the tool result.
- Errors: If the script exits with a non-zero code, stderr is returned as an error message.
- Timeout: Scripts have a 30-second execution timeout.
tool.json Reference
| Field | Type | Required | Description |
|---|---|---|---|
name |
string |
Yes | Unique tool name (used for dispatching) |
description |
string |
No | What the tool does (shown to the LLM) |
parameters |
object |
No | Map of parameter name → property object |
required |
array of string |
No | List of required parameter names |
Each parameter property object:
| Field | Type | Description |
|---|---|---|
type |
string |
Parameter type (e.g. string, integer) |
description |
string |
What this parameter is for |
Tips
- Use any Python libraries you need — just make sure they're installed in the environment where catboi runs.
- For debugging, print to stderr (
print("debug", file=sys.stderr)) — only stdout is captured as the tool result. - Keep scripts fast — the default timeout is 30 seconds.
- The working directory is set to the tool's own directory, so you can read local data files with relative paths.