Skip to main content

toolbroidge

toolbroidge is a developer-facing Python library for defining tools once with type-annotated Python functions and Pydantic v2 validation, then translating and running those tools across OpenAI, Anthropic, or Gemini. It gives agent loops a small canonical tool model, strict provider schemas, concurrent tool execution, streaming argument reassembly, structured output retries, and explicit refusal handling without bringing in a larger orchestration framework.

Installation

pip install toolbroidge

Provider clients are optional:

pip install "toolbroidge[openai]"
pip install "toolbroidge[anthropic]"
pip install "toolbroidge[gemini]"

Minimal Example

from toolbroidge import Agent, tool

@tool("Use when adding two numbers. Do not use for non-arithmetic tasks.")
def add(left: int, right: int) -> int:
    return left + right

provider = YourProvider()
agent = Agent(provider=provider, tools=[add])
run = agent.run("What is 2 + 3?")
print(run.output)

Provider Shape Comparison

Provider Tool wire shape
OpenAI {type:"function", function:{name, description, parameters, strict:true}}
Anthropic {name, description, input_schema}
Gemini {functionDeclarations:[{name, description, parameters}]}

Parallel Calls

When a model response contains multiple tool calls, toolbroidge fans them out with ThreadPoolExecutor, then correlates results by tool call id before the next model turn.

model response
  |-- call id=a -> tool A --\
  |-- call id=b -> tool B ----> {a: result_a, b: result_b, c: result_c}
  |-- call id=c -> tool C --/
                         next model turn

Refusal Handling

Structured output accepts a Pydantic BaseModel. Parse errors and schema violations retry up to three times with the typed error injected for the next attempt. Refusals return immediately as Refusal.

from pydantic import BaseModel
from toolbroidge import Agent, Refusal

class Answer(BaseModel):
    value: int

agent = Agent(provider=provider, tools=[], output_schema=Answer)
result = agent.run("Return a number")

if isinstance(result.output, Refusal):
    print(result.output.reason)
else:
    print(result.output.value)

Provider API Key Demo

The repository includes a simple smoke-test app at examples/provider_demo.py. It defines two tools once with @tool, translates them to the selected provider's tool schema, asks the model to call tools, executes returned calls in parallel, and prints correlated results by tool call id.

Install the package and the provider extras you want to test:

python3 -m pip install -e ".[openai,anthropic,gemini]"

Run with OpenAI:

export OPENAI_API_KEY="sk-..."
python3 examples/provider_demo.py --provider openai

Run with Anthropic:

export ANTHROPIC_API_KEY="sk-ant-..."
python3 examples/provider_demo.py --provider anthropic

Run with Gemini:

export GEMINI_API_KEY="..."
python3 examples/provider_demo.py --provider gemini

Optional model overrides:

export OPENAI_MODEL="gpt-6-luna"
export ANTHROPIC_MODEL="claude-3-5-haiku-latest"
export GEMINI_MODEL="gemini-3.5-flash-lite"

Metadata

Release files for toolbroidge 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for toolbroidge 0.1.1
File Size Uploaded Provenance
toolbroidge-0.1.1.tar.gz 9.5 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for toolbroidge 0.1.1
File Interpreter ABI Platform
toolbroidge-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 19.8 kB

Release files / toolbroidge-0.1.1.tar.gz

Download URL toolbroidge-0.1.1.tar.gz
Size 9.5 kB
Tags Source
SHA-256 checksum
How to use checksums
4ca43a4cd0a695a50fc9a738f6e9fa07206eef75a85fe9927a36f3d9efc4af57
BLAKE2b-256 checksum
How to use checksums
5aeb7690a712aa4e2aa050597515e7d5931ab077f6585743d63ab498e388d657
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Release files / toolbroidge-0.1.1-py3-none-any.whl

Download URL toolbroidge-0.1.1-py3-none-any.whl
Size 10.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
45a0742c83c3e2e765b6ec5be551779356aa61f794f26f02fb63914c38e669e7
BLAKE2b-256 checksum
How to use checksums
4b67117383b781abb71bd09adf46f31df8af9b09aa5bc3f0606f4e085b323693
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Security for toolbroidge 0.1.1

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.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files No provenance

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