Skip to main content

AgentGuard

Constitutional Governance Kernel for AI Agents

"Your AI agents are only as safe as the system governing them." "If your agent can break AgentGuard, it better be good at breaking Bitcoin."

License: MIT Python 3.10+ PyPI


Install

pip install agentguard-kernel

The Problem

You're building with AI agents. Your agent has access to your database, your payments, your users.

What happens when it does something it shouldn't?

Most teams have no answer. No pause button. No audit trail. No trust scoring. No approval gate. Just an agent with full access and a prayer.

AgentGuard changes that.


Quick Start

from agentguard import TrustEngine

engine = TrustEngine(db_path="trust.db")

# New agent starts TRUSTED
level = engine.get_trust_level("my-agent-001")
print(level)  # → TRUSTED

# Quick permission check
if engine.is_allowed("my-agent-001"):
    # proceed with action
    pass

# Agent does something bad
result = engine.apply_penalty("my-agent-001", "spam")
print(result)  # → {"new_points": 20, "new_level": "LIMITED"}

# Agent does something worse
result = engine.apply_penalty("my-agent-001", "abuse")
print(result)  # → {"new_points": 50, "new_level": "OBSERVED"}

# Agent recovers with good behaviour
engine.upgrade_trust("my-agent-001", reason="passed_review")

# Emergency: hard revoke
engine.revoke("my-agent-001", reason="critical_violation")

# Full audit trail
history = engine.get_history("my-agent-001")

# See all agents
agents = engine.list_agents()

Trust Levels

TRUSTED → LIMITED → OBSERVED → SUSPICIOUS → QUARANTINED → REVOKED
Level Points What it means
TRUSTED 0–19 Full access, normal operation
LIMITED 20–39 Restricted actions, monitored
OBSERVED 40–59 All actions logged, some blocked
SUSPICIOUS 60–79 Most actions require approval
QUARANTINED 80–99 Almost fully restricted
REVOKED 100 Completely blocked

Violation Penalties

Violation Points
fake_verification 50
hate_speech 60
drug_listing 40
unauthorized_access 40
high_risk_activity 35
abuse 30
multiple_flags 25
spam 20

API Reference

TrustEngine(db_path="trust.db")

Initialize with a SQLite database path. Uses trust.db by default.

get_trust_level(user_id) → str

Returns the current trust level string.

get_trust_score(user_id) → dict

Returns {"level": ..., "points": ..., "appeal_status": ...}.

is_allowed(user_id) → bool

Returns False for QUARANTINED or REVOKED agents. Use this as your fast gate check.

apply_penalty(user_id, violation_type, details="") → dict

Applies a penalty. Returns {"new_points": ..., "new_level": ...}.

upgrade_trust(user_id, reason="") → dict

Rewards good behaviour, reduces points by 15.

revoke(user_id, reason="") → dict

Hard stop — immediately sets agent to REVOKED.

submit_appeal(user_id, reason, evidence) → dict

Agent submits an appeal for review.

get_history(user_id, limit=50) → list

Full audit trail for an agent.

list_agents() → list

All tracked agents and their trust state.


Architecture

┌─────────────────────────────────────────────────┐
│                   Your App                       │
├─────────────────────────────────────────────────┤
│         AgentGuard Kernel                        │
│    Trust Engine │ Risk Scoring │ Audit Log       │
├─────────────────────────────────────────────────┤
│              SQLite (Community)                  │
│         PostgreSQL (Enterprise)                  │
└─────────────────────────────────────────────────┘

Zero dependencies. Drop into any project in 5 minutes.


Enterprise Edition

The community kernel is free and open source.

Enterprise adds: REST API, JWT auth, Ed25519 capability tokens, human approval gate, real-time event stream, dashboard UI, global emergency stop, multi-tenant orgs, PostgreSQL + Redis, SSO/SAML, webhooks, SLA, and priority support.

📧 bkdk62309@gmail.com — response within 24 hours.


License

MIT — free to use, modify, and build on.


Author

Dheeraj Kumar Biswakarma 🐙 github.com/Mangomindai/agentguard

Metadata

Release files for agentguard-kernel 0.1.0

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

Built distribution (wheel)

Table of built distributions (wheels) for agentguard-kernel 0.1.0
File Interpreter ABI Platform Actions
agentguard_kernel-0.1.0-py3-none-any.whl Python 3 none any Details for agentguard_kernel-0.1.0-py3-none-any.whl

Release files / agentguard_kernel-0.1.0-py3-none-any.whl

Download URL agentguard_kernel-0.1.0-py3-none-any.whl
Size 7.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9814d64ae7657c512b276bdd8a1649323c9811ec85031d46a6bbb8b45f7415cc
BLAKE2b-256 checksum
How to use checksums
002c17b9c395817d2553bdac3ad6f293d1a1a2f748cefb6a28ef759bec9c4968
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.2

Security for agentguard-kernel 0.1.0

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.0 This release

1 release file 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