Skip to main content

AgentSec Python SDK

Security infrastructure for autonomous AI agents.

Installation

pip install agentsec

Quick Start

from agentsec import AgentSecClient, policy

# Initialize client
client = AgentSecClient(agent_id="my-agent")

# Capture events manually
client.capture_prompt("What files are in /etc?")
client.capture_response("I'll list the files in /etc for you.")
client.capture_tool_call("list_directory", {"path": "/etc"})

# Or use the guard decorator for automatic capture + policy enforcement
@policy.guard
def execute_command(cmd: str) -> str:
    # Your implementation
    pass

Policy Enforcement

from agentsec import policy

# Load policies
policy.load("policies/")

# Policies are automatically enforced on guarded functions
@policy.guard
def read_file(path: str) -> str:
    with open(path) as f:
        return f.read()

# This will raise PermissionError if policy denies
read_file("/etc/passwd")

Event Storage

Events are stored locally by default in .agentsec/events/. Each run creates a JSONL file.

# View events
cat .agentsec/events/*.jsonl | jq .

Documentation

Metadata

Release files for agentsec 0.3.0

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

Source distribution (sdist)

Source distribution for agentsec 0.3.0
File Size Uploaded
agentsec-0.3.0.tar.gz 31.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for agentsec 0.3.0
File Interpreter ABI Platform
agentsec-0.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 64.4 kB

Release files / agentsec-0.3.0.tar.gz

Download URL agentsec-0.3.0.tar.gz
Size 31.9 kB
Tags Source
SHA-256 checksum
How to use checksums
08e0bef99108a78d58e31931b03841cfa70c5ad51ca21e941ecd8fdab05b0d83
BLAKE2b-256 checksum
How to use checksums
c1390d238afa0a454002fa4b6e803f879d07876a3bd28b04dd1f8a8bfe4f6964
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.2

Release files / agentsec-0.3.0-py3-none-any.whl

Download URL agentsec-0.3.0-py3-none-any.whl
Size 32.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4952a1127fba8fcd52eb4e4cf99de2287fe9b61db5b827c37fffe4af1383ba37
BLAKE2b-256 checksum
How to use checksums
578d271a6deef594afc3e92bed231dd014454f9c4cad8f2609374218aaf9764c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.2

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.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