tool-prune
Calibrated tool selection and schema pruning for AI agents. Dual-engine: zero-dependency offline TurboQuant or TypeSafe System One.
pip install tool-prune
# Optional SIMD acceleration
pip install turbovec
# Optional: TypeSafe API key for cloud reasoning
export TYPESAFE_API_KEY="apikey_..."
Quick start
from tool_prune import prune
tools = {
"read_file": "Read raw text from local filesystem path",
"run_query": "Execute SQL queries against database",
"web_search": "Search public web for documentation or articles"
}
# Works offline out of the box with TurboQuant:
match = prune("what tables exist in the db?", tools)
print(match.tool) # 'run_query'
print(match.engine) # 'turboquant'
prune() narrows schemas offline via TurboQuant by default, or routes to TypeSafe System One when TYPESAFE_API_KEY is present. That's the whole API.
Schema pruning for LLMs
from tool_prune import ToolPrune
router = ToolPrune(tools)
top_tools = router.filter(user_prompt, k=5)
response = llm.chat(
tools=top_tools,
messages=[{"role": "user", "content": user_prompt}]
)
Cuts prompt tokens by up to 92% and eliminates context confusion without losing tools.
Fast-path direct dispatch
result = router.dispatch("read ./pyproject.toml", {
"read_file": lambda q, m: open("pyproject.toml").read(),
"run_query": lambda q, m: db.query(q),
"fallback": lambda q, m: call_llm(q)
})
Runs deterministic handlers in under 160ms with zero token cost.
Dual engine
local_match = prune(query, tools, engine="turboquant")
cloud_match = prune(query, tools, engine="typesafe", api_key="...")
- turboquant: 100% offline, zero network, zero dependencies. Uses
turbovec(Rust SIMD) if installed, with built-in FWHT fallback. - typesafe: Cloud System One reasoning (Jev). 100% Top-1 accuracy on subtle distractors with calibrated probabilities.
Demo
python examples/quickstart.py
License
MIT © Hemanth.HM
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tool_prune-0.2.0.tar.gz.
File metadata
- Download URL: tool_prune-0.2.0.tar.gz
- Upload date:
- Size: 6.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.14.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9a2608b5237458699db556416b9411bd30aa1e1db5f1e775a3ad4bb67e4d4eab
|
|
| MD5 |
85cc0c1953b50d4ab3c858072c76256c
|
|
| BLAKE2b-256 |
c257b6eccd330413e563ed83a0a4085c0e2327078afb990f8b7b42779f87b125
|
File details
Details for the file tool_prune-0.2.0-py3-none-any.whl.
File metadata
- Download URL: tool_prune-0.2.0-py3-none-any.whl
- Upload date:
- Size: 7.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.14.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bb15d4f6cda985a8b8dddad2a8665e8c0b1d497ba7c1d74fa0a091322a8b908c
|
|
| MD5 |
649ef7197c7619863a2906fcf65646f0
|
|
| BLAKE2b-256 |
4144f2580f744abf378cb917db31eab71f77ec745cf8e1f6031aaaabb8771a5c
|