# AgentShield: Python Firewall for AI Agent Spend Control

This repository profile is provided by osrepos.com, an open source repository discovery platform.

Source: osrepos.com
Repository profile: https://osrepos.com/repo/kindrat86-agentshield
Generated for open source discovery and AI-assisted research.

AgentShield is a pure Python library designed to prevent runaway AI agents from exceeding budget limits. It offers 10 composable spend rules, evaluated in under 1ms, providing robust cost control. Although its core development has transitioned to sipi.bot, the AgentShield Python package remains available for existing users and its test fixtures are open-source.

GitHub: https://github.com/kindrat86/agentshield
OSRepos URL: https://osrepos.com/repo/kindrat86-agentshield

## Summary

AgentShield is a pure Python library designed to prevent runaway AI agents from exceeding budget limits. It offers 10 composable spend rules, evaluated in under 1ms, providing robust cost control. Although its core development has transitioned to sipi.bot, the AgentShield Python package remains available for existing users and its test fixtures are open-source.

## Topics

- Python
- AI Agents
- Cost Control
- Budget Management
- LLM
- Firewall
- Spend Management
- DevTools

## Repository Information

Last analyzed by OSRepos: Wed Sep 16 2026 01:29:07 GMT+0100 (Western European Summer Time)
Detail views: 1
GitHub clicks: 0

## Safety Notice

OSRepos shares public repositories for knowledge and discovery only. Review source code, dependencies, licenses, and security implications before running or installing anything.

## Content

## Introduction

AgentShield is a pure Python library designed to act as a firewall for AI agent spending. It helps stop runaway AI agents before they consume excessive budget by offering 10 composable spend rules, evaluated per-transaction in under 1ms. While the project's primary development has been consolidated into [sipi.bot](https://sipi.bot/pilot?source=agentshield-github), the AgentShield Python package and its test fixtures remain available for existing users and open-source contributions.

## Why Use & Benefits

AI agents, while powerful, can sometimes incur unexpected costs. AgentShield provides a robust solution to manage and control these expenditures with its lightweight, high-performance engine. Key benefits include its pure Python 3.11 stdlib implementation with zero dependencies, ensuring easy integration and minimal overhead. It uses `decimal.Decimal` for precise money calculations, operates statelessly, and guarantees deterministic results, all while evaluating transactions in less than 1ms. The library offers a comprehensive set of 10 rule types, from `transaction_limit` and `daily_total` to `velocity` and `merchant_allowlist`, allowing fine-grained control over agent spending.

## Installation

To get started with AgentShield, install the package via pip:

bash
pip install agentshield-spend


Note: The import name for the library is `agentshield`, as the PyPI name `agentshield` belongs to an unrelated project.

## Examples

Here's a quick example demonstrating how to use AgentShield to evaluate a transaction against defined spend rules:

python
from agentshield import SpendControlEngine

engine = SpendControlEngine()

# A transaction your agent wants to make
transaction = {
    "amount": 500.00,
    "merchant": "openai-api",
    "category": "llm_inference",
    "agent_id": "my-agent",
    "timestamp": "2026-08-10T10:00:00Z",
}

# Your spend-control rules
rules = [
    {"id": "r1", "type": "transaction_limit", "priority": 1,
     "params": {"max_amount": 250}, "action": "BLOCK"},
    {"id": "r2", "type": "daily_total", "priority": 2,
     "params": {"max_daily": 2000}, "action": "BLOCK"},
    {"id": "r3", "type": "velocity", "priority": 3,
     "params": {"window_minutes": 60, "max_count": 10}, "action": "FLAGGED"},
]

# Prior transactions today (for daily_total and velocity checks)
prior_transactions = []

# Evaluate, returns in <1ms
result = engine.evaluate(transaction, rules, prior_transactions)
print(result["decision"])  # BLOCKED
print(result["reason"])    # Transaction amount $500.00 exceeds limit of $250.00


## Links

For more information and to explore the project further, refer to these links:

*   [Canonical product](https://sipi.bot)
*   [Paid implementation pilot](https://sipi.bot/pilot?source=agentshield-github)
*   [sipi.bot public eval report](https://sipi.bot/eval-report/)
*   [GitHub Repository](https://github.com/kindrat86/agentshield)