AgentGuard Python SDK
Policy engine for securing AI agent tool calls. | AI Agent 工具调用安全策略引擎。
Installation | 安装
pip install agent-guard
Requires Python >= 3.10. | 需要 Python >= 3.10。
From source | 源码安装:
cd python
pip install -e ".[dev]"
Quick Start | 快速开始
import asyncio
from agent_guard import PolicyEngine, guard
engine = PolicyEngine("policy.yaml")
@guard(engine, session_id="demo")
async def shell_execute(command: str) -> str:
return f"执行结果: {command}"
async def main():
result = await shell_execute("echo hello")
print(result)
asyncio.run(main())
API
PolicyEngine(config_path: str = "policy.example.yaml")
Load policies from a YAML file. | 从 YAML 文件加载策略。
execute_pre(tool_name, args, session_id)— Run pre-execution policies | 执行前置策略检查execute_post(tool_name, result, session_id)— Run post-execution policies | 执行后置策略处理
@guard(engine, session_id="default")
Decorator that wraps an async function with policy enforcement. | 装饰器,为异步函数添加策略防护。
SuspensionManager
create_request()— Create a suspension request | 创建挂起请求wait_for_approval()— Wait for human approval (asyncio.Event) | 等待人工审批approve(request_id)/reject(request_id, reason)— External wake-up | 外部唤醒接口list_pending()— List all pending requests | 列出待审批请求
Development | 开发
cd python
pip install -e ".[dev]"
pytest --cov=agent_guard --cov-report=term-missing
License | 开源许可证
MIT License — Copyright (c) 2026 guorui999
Metadata
Release files for agenttoolguard 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| agenttoolguard-0.1.1.tar.gz | 8.2 kB | Without provenance | Details for agenttoolguard-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| agenttoolguard-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for agenttoolguard-0.1.1-py3-none-any.whl |
Total release size: 15.7 kB
Release files / agenttoolguard-0.1.1.tar.gz
| Download URL | agenttoolguard-0.1.1.tar.gz |
|---|---|
| Size | 8.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b5999ad04708a5903cd94d97117b81fa581f479208b19f990a32033b4679f122
|
|
BLAKE2b-256 checksum How to use checksums |
fbd455ca8a741a205d85e6d71442c343e43422280c2a23fff6ff00d9b9258942
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.10
|
Release files / agenttoolguard-0.1.1-py3-none-any.whl
| Download URL | agenttoolguard-0.1.1-py3-none-any.whl |
|---|---|
| Size | 7.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
502a25778d7469351f0bd7d4eb4207976a1a68f41d6e573a50fdd42321490abd
|
|
BLAKE2b-256 checksum How to use checksums |
4828caa159d73d0cc1eb61448c0ac83d27479b63246c5995f93fe6850beebf36
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.10
|
Security for agenttoolguard 0.1.1
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.