Skip to main content

Python SDK for AI agent auditing and tracing

Project description

AgentGuard Python SDK

High-integrity auditing SDK for AI agents with automatic tracing, cryptographic signing, and safety validation.

Installation

pip install agentguard

Quick Start

from agentguard import agent_guard

# Simple usage with decorator
@agent_guard.trace()
def process_user_request(prompt: str):
    # Your agent logic here
    response = llm.complete(prompt)
    return response

# With custom configuration
from agentguard import AgentGuard, AgentGuardConfig

config = AgentGuardConfig(
    agent_id="my-agent-001",
    gateway_url="https://agentguard.mycompany.com",
    enable_signing=True,
    private_key_path="/path/to/private.key",
)

guard = AgentGuard(config)

@guard.trace(tool_name="data_processor")
def process_data(data):
    # Processing logic
    return processed_data

Features

Automatic Tracing

  • Captures function inputs, outputs, and execution time
  • Records stdout/stderr output
  • Intercepts LLM API calls (OpenAI, Anthropic)

Cryptographic Security

  • Ed25519 signing of all traces
  • SHA-256 hash chain for integrity
  • Secure key storage with password protection

Performance

  • Asynchronous trace delivery
  • Batching for efficiency
  • Local fallback storage
  • OpenTelemetry integration

Safety Features

  • Integration with MCP Gateway for policy validation
  • Support for high-risk operation approval workflows
  • Automatic kill-switch on repeated violations

Configuration

config = AgentGuardConfig(
    # Core settings
    agent_id="unique-agent-id",
    environment="production",  # development, staging, production
    gateway_url="http://localhost:8080",

    # Security
    enable_signing=True,
    private_key_path="/secure/path/private.key",
    private_key_password="optional-password",

    # Performance
    batch_size=100,
    flush_interval_seconds=5.0,
    enable_async=True,

    # Capture settings
    capture_stdout=True,
    capture_stderr=True,
    capture_llm_calls=True,
    capture_exceptions=True,

    # Telemetry
    enable_telemetry=True,
    otel_endpoint="http://localhost:4317",
)

Generating Keys

from agentguard.crypto import generate_and_save_keypair

# Generate new Ed25519 keypair
private_key, public_key_path = generate_and_save_keypair(
    path="/secure/location/agent.key",
    password="strong-password"  # Optional
)

Advanced Usage

Context Management

# Manually manage trace context
with guard._create_trace_context() as ctx:
    # Your code here
    pass

Custom Interceptors

# Add custom LLM provider
class CustomLLMInterceptor:
    def patch_custom_llm(self):
        # Your patching logic
        pass

# Register with AgentGuard
guard._llm_interceptor = CustomLLMInterceptor()

License

See LICENSE file in the root directory.

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_aegis-1.1.1.tar.gz (22.0 kB view details)

Uploaded Source

Built Distribution

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

agentguard_aegis-1.1.1-py3-none-any.whl (24.8 kB view details)

Uploaded Python 3

File details

Details for the file agentguard_aegis-1.1.1.tar.gz.

File metadata

  • Download URL: agentguard_aegis-1.1.1.tar.gz
  • Upload date:
  • Size: 22.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for agentguard_aegis-1.1.1.tar.gz
Algorithm Hash digest
SHA256 b8ff4d8528ac6c2f0b8bc53804b2bb1e86a140a3a7f82584757f94aaf14c348e
MD5 eb5b9fbfe88c088756fe3d663d317e45
BLAKE2b-256 aae7edce6a7ef11f4cfbf1ce222d5ebc6dc8332136ec7126301b6d2216f29ff5

See more details on using hashes here.

File details

Details for the file agentguard_aegis-1.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for agentguard_aegis-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3c0322ceb12d6d8112d11a5aa7c747f31c915496c3763c79cd52e3216bb5e3a2
MD5 60100dbe8e5df11d2adfe2e84d8fbae2
BLAKE2b-256 6924babaa097d23b99386f19d84550e29ef3f3ed0339b2621f0ae58a62006a10

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