Skip to main content

agent-guard-python

Python bindings for execution control at the agent side-effect boundary.

This package provides Python bindings for agent-guard, giving Python hosts a pre-execution decision layer before agent tool calls turn into shell commands or other side effects.


🚀 Quick Start (Python Adapters)

Status: The Python wrapper layer is a beta adapter surface. The clearest current proof point is still shell-first execution control, and Node remains the most mature integration path in the repository.

Integrate agent-guard into your existing LangChain tools with a policy gate in front of the original tool:

from agent_guard import Guard, wrap_langchain_tool

# 1. Initialize the Guard with your security policy
guard = Guard.from_yaml_file("policy.yaml")

# 2. Secure your existing tools
bash_tool = ShellTool() # Your original tool
secured_tool = wrap_langchain_tool(guard, bash_tool, agent_id="researcher")

# 3. Use the tool as normal - agent-guard handles the rest!
secured_tool.run("ls -la")

OpenAI-style handler wrapping is also available:

from agent_guard import Guard, wrap_openai_tool, AgentGuardDeniedError

guard = Guard.from_yaml_file("policy.yaml")

guarded_handler = wrap_openai_tool(
    guard,
    lambda input_data: {"ok": True, "query": input_data["query"]},
    tool="web_search",
    mode="check",
    trust_level="trusted",
)

try:
    print(guarded_handler({"query": "agent-guard"}))
except AgentGuardDeniedError as error:
    print("blocked", error.code)

✨ Features

  • 🛡️ Pre-execution policy decisions: Put allow/deny/ask checks in front of Python tool handlers.
  • 💻 Shell-first execution control: The strongest current execution path is still shell / Bash style tooling.
  • ⚠️ Typed adapter errors: Distinct deny, ask-required, and execution failure exceptions.
  • 📜 Signed receipts: Optional cryptographic proof of execution when you need deeper verification.
  • 🔏 Signed policy loading: Optional detached-signature verification for policy.yaml.
  • 📊 Auditing support: JSONL logs and metrics integration for operator-visible outcomes.

Current boundary note:

  • explicit check mode remains a policy-only gate; in auto mode, non-shell tools use Guard.run(). A Handoff closes its one-shot lifecycle before returning the original handler result, while Guard-owned WriteFile or mutating HTTP outcomes may execute without invoking that handler
  • the exact tool ID bash is the owned shell path; shell-like custom IDs such as shell, terminal, sh, cmd, or powershell fail closed in auto with UnsupportedShellAlias until explicitly mapped or assigned a mode
  • Python is an active adapter surface, but still below the current Node path in maturity
  • Guard.execute() / Guard.run() use the SDK default sandbox selection, or accept an explicit backend= keyword ("none", "linux-seccomp", "linux-landlock", "macos-seatbelt", "windows-job-object", "windows-appcontainer"); a backend that is not compiled into the module or not functional on the host resolves truthfully to "none", and an unknown name raises
  • to get real isolation through backend=, build the module with the matching feature forwarded, e.g. maturin develop --features extension-module,seccomp (requires libseccomp on Linux); the default build carries no sandbox feature
  • if the default sandbox diagnosis falls back to NoopSandbox, the policy gate still runs, but OS-level isolation is not equivalent
  • unknown, expired, or duplicate handoff report IDs raise GuardError; a successful host action whose report fails surfaces AgentGuardExecutionError with the host result, request ID, attempted handoff result, and an explicit do-not-retry marker rather than silently returning success

🔧 Installation

The latest published package is 0.2.9:

python -m pip install agent-guard-python==0.2.9

To test the current 0.2.10 source, install it from a repository checkout (requires Python and a Rust toolchain):

python -m pip install ./crates/agent-guard-python

The distribution name is agent-guard-python; the import name remains agent_guard:

from agent_guard import Guard

For local development in this repository:

cd crates/agent-guard-python
maturin develop --features extension-module
pytest tests -v

📺 Demos

Check the examples/ directory for full usage scenarios:

  • demo_langchain.py: Comprehensive 3-line integration demo.
  • provenance_receipt.py: Cryptographic verification example.

Metadata

Release files for agent-guard-python 0.2.10

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

Built distributions (wheels)

Table of built distributions (wheels) for agent-guard-python 0.2.10
File
agent_guard_python-0.2.10-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details
agent_guard_python-0.2.10-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.10 abi3 Linux glibc 2.17+ x86-64 Details
agent_guard_python-0.2.10-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.10 abi3 Linux glibc 2.17+ ARM64 Details
agent_guard_python-0.2.10-cp310-abi3-macosx_11_0_arm64.whl CPython 3.10 abi3 macOS 11.0+ ARM64 Details
agent_guard_python-0.2.10-cp310-abi3-macosx_10_12_x86_64.whl CPython 3.10 abi3 macOS 10.12+ x86-64 Details

Total release size: 24.8 MB

Release files / agent_guard_python-0.2.10-cp310-abi3-win_amd64.whl

Download URL agent_guard_python-0.2.10-cp310-abi3-win_amd64.whl
Size 4.4 MB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
71fb6e6068e36b4933313d319bac8cd9a15bc467a07ece8b9504067305ebc8e8
BLAKE2b-256 checksum
How to use checksums
ab39ba916663e0b27905fcbc7ea2c5d43d1aaab9c9849f21d21d7dc0aa55c4fc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 24, 2026.

Transparency log

Release files / agent_guard_python-0.2.10-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL agent_guard_python-0.2.10-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 5.3 MB
Tags CPython 3.10 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
e98488f1b95621b190e2a33ba11a30530e71cfa5db321b48c9a326d7139813f7
BLAKE2b-256 checksum
How to use checksums
ba3127c9a16592e98cfd2e13d8af7a3b15f6568b323abb49bf987a3364af4905
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 24, 2026.

Transparency log

Release files / agent_guard_python-0.2.10-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL agent_guard_python-0.2.10-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 5.3 MB
Tags CPython 3.10 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
f08a102a88ee643c6701c5f7a7c7644bda2f7473536ddfd65139447885691f6d
BLAKE2b-256 checksum
How to use checksums
cdaa04ee83a18e764ee6bf00a68eb566de0d1e34748c73801c3006141747df84
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 24, 2026.

Transparency log

Release files / agent_guard_python-0.2.10-cp310-abi3-macosx_11_0_arm64.whl

Download URL agent_guard_python-0.2.10-cp310-abi3-macosx_11_0_arm64.whl
Size 4.8 MB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
027922360a806293c99ee70e48c823155c894d402116e555c281b3da5b793178
BLAKE2b-256 checksum
How to use checksums
92440ddfbdfd4a94c78c643c61b96d6b4ad497b5c771c7bfe27eee98f830aa1c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 24, 2026.

Transparency log

Release files / agent_guard_python-0.2.10-cp310-abi3-macosx_10_12_x86_64.whl

Download URL agent_guard_python-0.2.10-cp310-abi3-macosx_10_12_x86_64.whl
Size 5.0 MB
Tags CPython 3.10 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
aa658ffd3288ad3b416385defed439c892314a5772434b9874b5631f926bba44
BLAKE2b-256 checksum
How to use checksums
fa03e5abf57e86fe668e6a2a021e871fa2c7ddd6c5a3446083caf7387cb36263
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 24, 2026.

Transparency log

Security for agent-guard-python 0.2.10

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.

Full provenance

All 5 files in this release have been uploaded with provenance metadata.

Select from 5 files

Attestation for agent_guard_python-0.2.10-cp310-abi3-win_amd64.whl

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 24, 2026.

Transparency log

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