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.1.1.tar.gz (22.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.1.1-py3-none-any.whl (10.0 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for agentguard_sdk-0.1.1.tar.gz
Algorithm Hash digest
SHA256 489c6899d653a4473d4a9f7dc3efb87dc8a6aaf1f7662581c18ca23c5fe3fe62
MD5 285407b7d22586fca778f027ef2e857c
BLAKE2b-256 762bc786bbb1303de7a14d08495f678db399f86f34839a0019cc0c4190545678

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for agentguard_sdk-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b9f461da10f95cd936c2f5ff47013a5385d12d4bb0dc1273b8dd190b76c0b45e
MD5 25a0e8f274d550577cd38d58c7b9b4a6
BLAKE2b-256 6bed6f6e6b6124d0e0e7e70f5fe4e9a7d865e49b66b09bcefb231c065d9b5432

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