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 Provenance Actions
agentsec-0.3.0.tar.gz 31.9 kB Without provenance Details for agentsec-0.3.0.tar.gz

Built distribution (wheel)

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

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

Security for agentsec 0.3.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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