Skip to main content

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.

Release files for agentguard-aegis 1.2.2

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

Source distribution (sdist)

Source distribution for agentguard-aegis 1.2.2
File Size Uploaded
agentguard_aegis-1.2.2.tar.gz 40.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for agentguard-aegis 1.2.2
File Interpreter ABI Platform
agentguard_aegis-1.2.2-py3-none-any.whl Python 3 none any Details

Total release size: 86.3 kB

Release files / agentguard_aegis-1.2.2.tar.gz

Download URL agentguard_aegis-1.2.2.tar.gz
Size 40.6 kB
Tags Source
SHA-256 checksum
How to use checksums
e6186ceda94f9a7fd8ad15b2fe4a1ea1531625616ae105061ab4f710ad103353
BLAKE2b-256 checksum
How to use checksums
8d8761fbef3ac54ca54682b50457b09c9dbc285de9db1c545299586b547a02cd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.14

Release files / agentguard_aegis-1.2.2-py3-none-any.whl

Download URL agentguard_aegis-1.2.2-py3-none-any.whl
Size 45.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
78805815f92ab84fbfa3a25756a06ad57074743586a6775a59ee2f4f290c3f49
BLAKE2b-256 checksum
How to use checksums
b522ae6a5a2fdc54ec5965dacb582a329994e7839208eb546ef6bf0cb2f67cb5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.14

Release history Release notifications | RSS feed

This release

1.2.2 This release

2 release files

1.2.1

2 release files

1.2.0

2 release files

1.1.8

2 release files

1.1.7

2 release files

1.1.6

2 release files

1.1.4

2 release files

1.1.2

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.0

2 release files

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