Skip to main content

Agent Governance Layer - Middleware for AI agent action control

Project description

๐Ÿ›ก๏ธ Sentinel

Zero-trust governance for AI agents. One decorator. Full control.

Python 3.11+ License: MIT Tests Coverage


The Problem

You gave your AI agent access to real tools. Now it can:

  • Transfer money
  • Send emails
  • Delete records
  • Execute code

What could possibly go wrong?

Everything.


The Solution

from sentinel import protect, SentinelConfig

config = SentinelConfig(rules_path="rules.json")

@protect(config)
async def transfer_funds(amount: float, destination: str) -> str:
    return f"Transferred ${amount} to {destination}"

That's it. Three lines. Your agent now requires human approval for high-risk actions.


What Happens Next

Agent: "I'll transfer $5,000 to vendor@example.com"

============================================================
๐Ÿ›ก๏ธ SENTINEL APPROVAL REQUIRED
============================================================
Agent: sales-agent
Function: transfer_funds
Amount: $5,000.00
Context:
  current_balance: $10,000.00
  daily_limit_remaining: $3,000.00

Reason: Amount exceeds $100 threshold
------------------------------------------------------------
Approve? [y/n]: _

You decide. Not the AI.


Features

Feature Description
๐ŸŽฏ Rule Engine JSON-configurable policies (thresholds, blocks, approvals)
๐Ÿ”” Multi-channel Approval Terminal, Webhook, or Dashboard UI
๐Ÿ“Š Context for Decisions Show balance, limits, history to approvers
๐Ÿ“ Audit Log JSONL logs for compliance (GDPR, SOC2 ready)
๐Ÿง  Anomaly Detection Statistical analysis blocks unusual patterns
๐Ÿ”— LangChain Native protect_tools() wraps any LangChain tool
๐Ÿ–ฅ๏ธ Visual Dashboard Streamlit UI with approve/deny buttons

Quick Start

Installation

# Install from PyPI (recommended)
pip install agentic-sentinel

# Or install from GitHub
pip install git+https://github.com/azdhril/Sentinel.git

# With dashboard support
pip install agentic-sentinel[dashboard]

# With LangChain support
pip install agentic-sentinel[langchain]

Basic Usage

from sentinel import protect, SentinelConfig

config = SentinelConfig(
    rules_path="rules.json",
    approval_interface="terminal",
    fail_mode="secure",  # Block on errors, not allow
)

@protect(config)
async def delete_user(user_id: int) -> str:
    return f"Deleted user {user_id}"

Rules Configuration

{
  "version": "1.0",
  "default_action": "allow",
  "rules": [
    {
      "id": "financial_limit",
      "function_pattern": "transfer_*",
      "conditions": [{"param": "amount", "operator": "gt", "value": 100}],
      "action": "require_approval",
      "message": "Transfers over $100 require approval"
    },
    {
      "id": "block_deletes",
      "function_pattern": "delete_*",
      "action": "block",
      "message": "Delete operations are disabled"
    }
  ]
}

LangChain Integration

from langchain.agents import create_openai_tools_agent
from sentinel.integrations.langchain import protect_tools

# Your existing tools
tools = [search_tool, email_tool, payment_tool]

# One line to protect them all
protected_tools = protect_tools(tools, sentinel_config)

# Use as normal
agent = create_openai_tools_agent(llm, protected_tools, prompt)

Dashboard

Start the visual command center:

pip install agentic-sentinel[dashboard]
python -m sentinel.dashboard

Open http://localhost:8501:

  • See pending approvals in real-time
  • Click to approve or deny
  • View audit history and metrics
  • Track "Value Protected" across your org

Track your protection metrics: The dashboard shows "Total Value Protected" - the sum of all transactions that required approval. Use this metric to demonstrate ROI to stakeholders and justify governance investments.


Anomaly Detection

Sentinel doesn't just check rules. It learns patterns.

config = SentinelConfig(
    rules_path="rules.json",
    anomaly_detection=True,
    anomaly_statistical=True,
)
Normal behavior:    $50, $60, $70, $80, $90
Anomalous request:  $5,000

Z-Score: 311.8 standard deviations
Risk: CRITICAL (10.0)
Action: BLOCKED AUTOMATICALLY

No rule needed. The math speaks for itself.


Fail-Secure by Default

Most systems fail-open: if something breaks, actions are allowed.

Sentinel fails-secure: if something breaks, actions are blocked.

config = SentinelConfig(
    fail_mode="secure",  # Default: block on any error
    # fail_mode="safe",  # Alternative: allow on error (not recommended)
)

A security product that fails open isn't a security product.


Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                      YOUR AI AGENT                          โ”‚
โ”‚  (LangChain / CrewAI / AutoGPT / Custom)                   โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                      โ”‚
                      โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                   SENTINEL LAYER                            โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚
โ”‚  โ”‚   @protect  โ”‚โ†’ โ”‚   Rules     โ”‚โ†’ โ”‚  Anomaly Detection  โ”‚ โ”‚
โ”‚  โ”‚  Decorator  โ”‚  โ”‚   Engine    โ”‚  โ”‚  (Z-Score Analysis) โ”‚ โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚
โ”‚                          โ”‚                                  โ”‚
โ”‚                          โ–ผ                                  โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”   โ”‚
โ”‚  โ”‚              Approval Interface                      โ”‚   โ”‚
โ”‚  โ”‚   Terminal  |  Webhook/API  |  Dashboard UI         โ”‚   โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜   โ”‚
โ”‚                          โ”‚                                  โ”‚
โ”‚                          โ–ผ                                  โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”   โ”‚
โ”‚  โ”‚                   Audit Logger                       โ”‚   โ”‚
โ”‚  โ”‚            (JSONL - Compliance Ready)               โ”‚   โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜   โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                      โ”‚
                      โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                   EXTERNAL TOOLS                            โ”‚
โ”‚  (Payment APIs, Databases, Email Services, etc.)           โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Why Sentinel?

Without Sentinel With Sentinel
Agent transfers $50,000 by mistake Agent asks permission first
You find out from your bank You approve or deny in real-time
Logs show "function called" Logs show who approved, when, why
"The AI did it" "John approved it at 3:42 PM"

Use Cases

  • Fintech: Approve transactions over threshold
  • HR Tech: Review before sending offer letters
  • DevOps: Gate production deployments
  • Healthcare: Verify before prescription changes
  • Legal: Review before contract modifications
  • SaaS: Reduce impulsive cancellations

Early Adopters

Sentinel is being used to protect AI agents in:

  • ๐Ÿฆ Financial services automation
  • ๐Ÿ“ง Customer communication workflows
  • ๐Ÿ”ง DevOps and infrastructure management
  • ๐Ÿ“Š Data pipeline operations

Want to be featured here? Open an issue and tell us your use case!


Roadmap

  • Core interception engine
  • JSON rule configuration
  • Terminal approval interface
  • Webhook/API approval
  • Streamlit Dashboard
  • Statistical anomaly detection
  • LangChain integration
  • Audit logging (JSONL)
  • Slack/Teams approval
  • LLM-based semantic analysis (optional)
  • Cloud-hosted dashboard
  • SOC2 compliance package

Configuration

Sentinel can be configured via environment variables. Copy the example file:

cp .env.example .env

Then edit .env with your values. Key variables:

Variable Default Description
SENTINEL_LOG_DIR ./sentinel_logs Directory for audit logs
SENTINEL_FAIL_MODE secure secure (block on error) or safe (allow on error)
SENTINEL_WEBHOOK_URL - URL for webhook approval requests
SENTINEL_WEBHOOK_TOKEN - Auth token for webhook
OPENAI_API_KEY - For LLM anomaly detection (optional)

See .env.example for all available options.


Contributing

We welcome contributions! See CONTRIBUTING.md for guidelines.

# Clone and install dev dependencies
git clone https://github.com/azdhril/Sentinel.git
cd Sentinel
pip install -e ".[dev]"

# Run tests
pytest tests/ -v

# Run with coverage
pytest tests/ -v --cov=sentinel --cov-report=term-missing

License

MIT License. Use it, fork it, sell it. Just don't blame us if your AI still does something stupid.


Enterprise

Need custom integration, SLA, or compliance features?

Open an Issue โ†’


Stop hoping your AI behaves. Start knowing.

Get Started โ€ข Documentation โ€ข Report Bug

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

agentic_sentinel-0.1.0.tar.gz (68.1 kB view details)

Uploaded Source

Built Distribution

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

agentic_sentinel-0.1.0-py3-none-any.whl (54.6 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for agentic_sentinel-0.1.0.tar.gz
Algorithm Hash digest
SHA256 08baaf1091ec2a348fc103ce547f7ca5a3ea61b5c97374dbc460cfb9a8c8f034
MD5 a86f54b971aaf1450b1fa721613459b3
BLAKE2b-256 035774ab67d698dae6af4fe1f336c4b14fa849c31dfc20cb57e0a593ce3fbe3e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for agentic_sentinel-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c568385d3da607aded3ce62ec23e4eaacae7a671c316cd721bbdf79dda4b564b
MD5 852485dd397d6b11b2518ed966825757
BLAKE2b-256 f2cc78466e2bfb7b0776ada1b6072f85603450fba994e9165ba2b3e92f7a468a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page