Python library

ToolGuard

ToolGuard is a tiny, pure‑Python library that lets you validate the actions an autonomous AI agent (or any code) is about to take before they are executed.

A crystal hourglass with chrome clockwork gears inside, sand falling through the mechanism
examples/quickstart.pyPython
from toolguard import Guard, guarded, RequiredKeysRule, TypesRule, BoundsRule

# Define a simple rule set for a fake "charge" tool.
my_guard = Guard(
    {
        "charge": [
            RequiredKeysRule(["amount", "currency"]),
            TypesRule({"amount": "int", "currency": "str"}),
            BoundsRule("amount", min=1),  # amount must be a positive integer
        ]
    }
)

# Decorate the implementation so every call is validated first.
@guarded(my_guard, "charge")
def charge(amount: int, currency: str):
    """Pretend to charge a credit card."""
    print(f"[charge] Successfully charged {amount} {currency}.")

def main() -> None:
    print("=== Valid call ===")
    charge(2500, "usd")  # Should succeed.
21tests, all passing
0dependencies
3.9+Python
MITlicense

The API

Every name listed here exists in the shipped source.

  1. ToolCallBlocked

    Raised by Guard.enforce when a tool call violates one or more rules.

  2. GuardResult

    Result of a Guard.check call.

  3. Guard

    Container for a set of validation rules per tool.

  4. guarded(guard, tool_name)

    Decorator that validates a function call against guard before execution.

  5. RequiredKeysRule

    Ensures that all keys are present in the argument mapping.

  6. TypesRule

    Ensures that arguments have the expected types.

  7. BoundsRule

    Ensures a numeric argument lies within optional min / max bounds.

  8. EnumRule

    Ensures a value is one of an allowed set.

  9. RegexRule

    Ensures a string argument matches a regular expression.

  10. RelativeRule

    Custom rule defined by a callable that receives the argument mapping.

Questions

Anything else? Write to hello@get-agents-kit.com.

Has it been tested?
Yes. Before listing, it was built into a wheel, installed with no network access in an isolated sandbox, and its 21 tests passed against the installed package. The quickstart above ran as part of that check.
Does it have dependencies?
None. It uses the Python standard library only.
How do I install it?
pip install toolguard-0.1.0-py3-none-any.whl Then follow the README or run the quickstart.
Can I get a refund?
Yes. Within 14 days of purchase, reply to your receipt email.

Get ToolGuard

  • Installable wheel (toolguard-0.1.0-py3-none-any.whl)
  • Full source code and README
  • 21 tests, all passing
  • MIT license
$49
One-time payment. Yours to keep.Get it now - $49

Secure checkout by Lemon Squeezy. 14-day refund.