{"name":"AgentShield: Python Firewall for AI Agent Spend Control","description":"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","url":"https://osrepos.com/repo/kindrat86-agentshield","source":"osrepos.com","sourceDescription":"This repository profile is provided by osrepos.com, an open source repository discovery platform.","repositoryProfile":"https://osrepos.com/repo/kindrat86-agentshield","generatedFor":"open source discovery and AI-assisted research","markdown":"https://osrepos.com/repo/kindrat86-agentshield.md","json":"https://osrepos.com/repo/kindrat86-agentshield.json","topics":["Python","AI Agents","Cost Control","Budget Management","LLM","Firewall","Spend Management","DevTools"],"keywords":["Python","AI Agents","Cost Control","Budget Management","LLM","Firewall","Spend Management","DevTools"],"stars":null,"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.","content":"## Introduction\n\nAgentShield 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.\n\n## Why Use & Benefits\n\nAI 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.\n\n## Installation\n\nTo get started with AgentShield, install the package via pip:\n\nbash\npip install agentshield-spend\n\n\nNote: The import name for the library is `agentshield`, as the PyPI name `agentshield` belongs to an unrelated project.\n\n## Examples\n\nHere's a quick example demonstrating how to use AgentShield to evaluate a transaction against defined spend rules:\n\npython\nfrom agentshield import SpendControlEngine\n\nengine = SpendControlEngine()\n\n# A transaction your agent wants to make\ntransaction = {\n    \"amount\": 500.00,\n    \"merchant\": \"openai-api\",\n    \"category\": \"llm_inference\",\n    \"agent_id\": \"my-agent\",\n    \"timestamp\": \"2026-08-10T10:00:00Z\",\n}\n\n# Your spend-control rules\nrules = [\n    {\"id\": \"r1\", \"type\": \"transaction_limit\", \"priority\": 1,\n     \"params\": {\"max_amount\": 250}, \"action\": \"BLOCK\"},\n    {\"id\": \"r2\", \"type\": \"daily_total\", \"priority\": 2,\n     \"params\": {\"max_daily\": 2000}, \"action\": \"BLOCK\"},\n    {\"id\": \"r3\", \"type\": \"velocity\", \"priority\": 3,\n     \"params\": {\"window_minutes\": 60, \"max_count\": 10}, \"action\": \"FLAGGED\"},\n]\n\n# Prior transactions today (for daily_total and velocity checks)\nprior_transactions = []\n\n# Evaluate, returns in <1ms\nresult = engine.evaluate(transaction, rules, prior_transactions)\nprint(result[\"decision\"])  # BLOCKED\nprint(result[\"reason\"])    # Transaction amount $500.00 exceeds limit of $250.00\n\n\n## Links\n\nFor more information and to explore the project further, refer to these links:\n\n*   [Canonical product](https://sipi.bot)\n*   [Paid implementation pilot](https://sipi.bot/pilot?source=agentshield-github)\n*   [sipi.bot public eval report](https://sipi.bot/eval-report/)\n*   [GitHub Repository](https://github.com/kindrat86/agentshield)","metrics":{"detailViews":1,"githubClicks":0},"dates":{"published":null,"modified":"2026-09-16T00:29:07.000Z"}}