Skip to main content

Python SDK for AI Agent Security Platform

Project description

AgentGuard Python SDK

Enterprise-grade security for AI agents - Runtime protection, policy enforcement, and comprehensive audit trails

PyPI version Python versions License: MIT

🚀 Quick Start

pip install agentguard-sdk
from agentguard import AgentGuard

# Initialize the security client
guard = AgentGuard(
    api_key="your-api-key",
    ssa_url="https://ssa.agentguard.io"
)

# Secure your agent tool calls
result = await guard.execute_tool(
    tool_name="web-search",
    parameters={"query": "AI agent security"},
    context={"session_id": "user-session-123"}
)

print(f"Secure result: {result.data}")
print(f"Security decision: {result.security_decision}")

✨ Features

  • 🛡️ Runtime Security Enforcement - Mediate all agent tool/API calls through security policies
  • 📋 Policy-Based Access Control - Define and enforce security policies with ease
  • 🔍 Comprehensive Audit Trails - Track every agent action with tamper-evident logs
  • High Performance - <100ms latency for security decisions
  • 🔧 Type Hints - Full type annotations for better IDE support
  • 🎯 Request Transformation - Automatically transform risky requests into safer alternatives
  • 🔐 Zero-Trust Architecture - Never trust, always verify
  • 📊 Real-time Monitoring - Track agent behavior and security events
  • 🔄 Async Support - Built-in async/await support for modern Python applications

📖 Installation

Using pip

pip install agentguard-sdk

Using poetry

poetry add agentguard-sdk

From source

git clone https://github.com/agentguard-ai/agentguard-python.git
cd agentguard-python
pip install -e .

🎯 Usage Examples

Basic Usage

from agentguard import AgentGuard

guard = AgentGuard(
    api_key="your-api-key",
    ssa_url="http://localhost:3000"
)

# Synchronous execution
result = guard.execute_tool_sync(
    tool_name="file-write",
    parameters={
        "path": "/data/output.txt",
        "content": "Agent generated content"
    },
    context={
        "session_id": "agent-session-456",
        "user_id": "user-123"
    }
)

if result.success:
    print(f"Tool executed securely: {result.data}")
else:
    print(f"Security policy blocked: {result.error}")

Async Usage

import asyncio
from agentguard import AgentGuard

async def main():
    guard = AgentGuard(
        api_key="your-api-key",
        ssa_url="http://localhost:3000"
    )
    
    result = await guard.execute_tool(
        tool_name="database-query",
        parameters={"query": "SELECT * FROM users LIMIT 10"},
        context={"session_id": "session-789"}
    )
    
    print(result.data)

asyncio.run(main())

Policy Testing

from agentguard import PolicyTester

tester = PolicyTester()

# Test your policies before deployment
result = tester.test_policy(
    policy=my_policy,
    request={
        "tool_name": "database-query",
        "parameters": {"query": "SELECT * FROM users"}
    }
)

print(f"Policy decision: {result.decision}")
print(f"Reasoning: {result.reason}")

Policy Builder

from agentguard import PolicyBuilder

policy = (
    PolicyBuilder()
    .name("restrict-file-operations")
    .description("Prevent file write operations")
    .add_rule(
        condition={"tool_name": "file-write"},
        action="deny",
        reason="File write operations are not allowed"
    )
    .add_rule(
        condition={"tool_name": "file-read"},
        action="allow",
        reason="File read operations are permitted"
    )
    .build()
)

print(f"Policy created: {policy}")

🔧 Configuration

Basic Configuration

guard = AgentGuard(
    api_key="your-api-key",
    ssa_url="https://ssa.agentguard.io",
    timeout=5.0,
    max_retries=3
)

Advanced Configuration

guard = AgentGuard(
    api_key=os.getenv("AGENTGUARD_API_KEY"),
    ssa_url=os.getenv("AGENTGUARD_SSA_URL"),
    
    # Timeout settings
    timeout=10.0,
    max_retries=3,
    retry_delay=1.0,
    
    # Logging
    log_level="INFO",
    
    # Custom headers
    headers={
        "X-Custom-Header": "value"
    },
    
    # Callback hooks
    on_security_decision=lambda decision: print(f"Decision: {decision}"),
    on_error=lambda error: print(f"Error: {error}")
)

📚 Documentation

🤝 Contributing

We welcome contributions! Please see our Contributing Guide for details.

📄 License

MIT © AgentGuard

🔒 Security

Security is our top priority. If you discover a security vulnerability, please email agentguard@proton.me instead of using the issue tracker.

See SECURITY.md for more details.

🌟 Why AgentGuard?

The Problem

AI agents are powerful but pose significant security risks:

  • Unrestricted access to tools and APIs
  • No audit trail of agent actions
  • Difficult to enforce security policies
  • Hard to debug agent behavior

The Solution

AgentGuard provides:

  • Runtime Security - Every tool call is evaluated before execution
  • Policy Enforcement - Define what agents can and cannot do
  • Audit Trails - Complete visibility into agent actions
  • Request Transformation - Automatically make risky requests safer
  • Zero-Trust - Never trust, always verify

🚀 Roadmap

  • Core SDK with policy enforcement
  • Type hints and async support
  • Comprehensive test suite
  • Drop-in integrations (LangChain, CrewAI, AutoGPT)
  • Built-in guardrails library
  • Cost monitoring and budget enforcement
  • Visual policy management UI
  • Real-time monitoring dashboard

💬 Community


Built with ❤️ by the AgentGuard team

GitHubPyPIEmail

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

agentguard_sdk-0.2.0.tar.gz (35.2 kB view details)

Uploaded Source

Built Distribution

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

agentguard_sdk-0.2.0-py3-none-any.whl (20.1 kB view details)

Uploaded Python 3

File details

Details for the file agentguard_sdk-0.2.0.tar.gz.

File metadata

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

File hashes

Hashes for agentguard_sdk-0.2.0.tar.gz
Algorithm Hash digest
SHA256 36eb7d475ed03c97b980fb23219f3bde2bb655aef6192bafd1be8bd897259323
MD5 ad7663d81d68e8691d4a06a224ff06c1
BLAKE2b-256 8d1ac653fd067d66b51d71308e8b4058d6e3089af82774eb5801cdefc5f8976f

See more details on using hashes here.

File details

Details for the file agentguard_sdk-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: agentguard_sdk-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 20.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for agentguard_sdk-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 957192530d3bf3cee388d5aa138b4d688385c4e10cdc37c125f6f47cb2ddd6a2
MD5 d0e145db4d8c4f8ff47d0a96b999bd50
BLAKE2b-256 e5ccda73b2e81863529b9b29c5d9f071d85f91219b0923c327220c3d0e9f8a6d

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