Skip to main content

tool-prune

Calibrated tool selection and schema pruning for AI agents. Zero dependencies.

pip install tool-prune

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) # 1.0

prune() narrows schemas to Top-K candidates or identifies direct matches in ~140ms. dispatch() runs immediate tool execution if confidence clears the threshold. That's the whole API.

Schema pruning for LLMs

from tool_prune import ToolPrune

router = ToolPrune(tools)
top_tools = router.filter(user_prompt, k=3)

response = llm.chat(
    tools=top_tools,
    messages=[{"role": "user", "content": user_prompt}]
)

Drops prompt tokens by 75-85% and eliminates context distraction 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.

Demo

python examples/quickstart.py

Runs live quickstart routing with your TYPESAFE_API_KEY.

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

tool_prune-0.1.0.tar.gz (3.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tool_prune-0.1.0-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

File details

Details for the file tool_prune-0.1.0.tar.gz.

File metadata

  • Download URL: tool_prune-0.1.0.tar.gz
  • Upload date:
  • Size: 3.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.6

File hashes

Hashes for tool_prune-0.1.0.tar.gz
Algorithm Hash digest
SHA256 09ad3225affd0b8f4c79c5f12a7962f02d89236a18a0efa802d2ad03d1de3c1c
MD5 bc895917511fb22dd3049da25f9c18cd
BLAKE2b-256 4e52bc8efcd40c77e81830277a90ca3c7d735fd067781c9a2dba4650d4d6c1d1

See more details on using hashes here.

File details

Details for the file tool_prune-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: tool_prune-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.6

File hashes

Hashes for tool_prune-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 86b10d3e91f4ce119f823de232d49103188b9880d67b05cbe999cc2e89e9241c
MD5 017d7a3cd225573366f108d833ff9a54
BLAKE2b-256 7358152a80040d6477206272f68f6a148fcf8d997f0840b276765f0a2bd28c89

See more details on using hashes here.

Release history Release notifications | RSS feed

0.2.0

2 files

0.1.1

2 files

This release

0.1.0 This release

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page