tool-prune
Calibrated tool selection and schema pruning for AI agents. Zero-dependency offline TurboQuant, custom local decision engines, or TypeSafe System One.
pip install tool-prune
# Optional Rust SIMD acceleration (0.041 ms search)
pip install turbovec numpy
# 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"
}
match = prune("what tables exist in the db?", tools)
print(match.tool) # 'run_query'
print(match.confidence) # 0.815
print(match.engine) # 'turboquant'
prune() runs offline via 4-bit PolarQuant + 1024-bit QJL TurboQuant (1.35 ms pure stdlib, 0.041 ms with turbovec, 100% BFCL v3 Top-1 and 100-Tool Top-5 recall) by default, or routes to TypeSafe System One when TYPESAFE_API_KEY is set. Accepts plain dicts, MCP inputSchema, Anthropic input_schema, and OpenAI { "type": "function", "function": ... } tool lists.
Schema pruning for LLMs
from tool_prune import prune
router = prune(mcp_tools)
# Conformal auto-selection (or pass k=5):
top_tools = router.filter(user_prompt, allow_empty=True)
response = llm.chat(
tools=top_tools,
messages=[{"role": "user", "content": user_prompt}]
)
Cuts prompt schema tokens by up to 98% while preserving your exact SDK tool dicts.
Fast-path direct dispatch
result = router.dispatch("read ./pyproject.toml", {
"read_file": lambda q: open("pyproject.toml").read(),
"run_query": lambda q: db.query(q),
"fallback": lambda q, m: call_llm(q, m.auto_tools)
})
Pluggable engines
local_match = prune(query, tools, engine="turboquant")
simd_match = prune(query, tools, engine="turbovec")
cloud_match = prune(query, tools, engine="typesafe", api_key="...")
custom_match = prune(query, tools, engine=decision_engine)
- turboquant: 100% offline, zero network, zero dependencies (
1.35 mspure Python stdlib). - turbovec: Optional Rust SIMD backend (
0.041 mskernel latency) sharing the same Corpus-IDF feature pipeline. - custom engine: Any object with
choice({ "state", "question", "options" })or callable(query, criteria, kwargs) -> candidates. - typesafe: Cloud System One reasoning (Jev) with calibrated probabilities.
Demo
python examples/quickstart.py
License
MIT © Hemanth.HM
Metadata
Release files for tool-prune 0.4.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| tool_prune-0.4.0.tar.gz | 15.1 kB | Without provenance | Details for tool_prune-0.4.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| tool_prune-0.4.0-py3-none-any.whl | Python 3 | none | any | Details for tool_prune-0.4.0-py3-none-any.whl |
Total release size: 29.9 kB
Release files / tool_prune-0.4.0.tar.gz
| Download URL | tool_prune-0.4.0.tar.gz |
|---|---|
| Size | 15.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4d9808c6b4a1d13745e197d53f01c8d810ebc34c969cd3fa94e60e498a938cdb
|
|
BLAKE2b-256 checksum How to use checksums |
915e0467d71ceb20303998b6a80f79c2a325ffaa331bcd4b30d93f108a21dc15
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / tool_prune-0.4.0-py3-none-any.whl
| Download URL | tool_prune-0.4.0-py3-none-any.whl |
|---|---|
| Size | 14.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a4b4e30280a10027335945de1f0874c5a871c2a0b7467f7f7357457a61080107
|
|
BLAKE2b-256 checksum How to use checksums |
4586f58f267444d0916fba8b03fc746b81c45c4baeae1d622c2c6eeb32db7bc1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Security for tool-prune 0.4.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.