AI Agent security guard - policy engine for LLM tool calls
Project description
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file agenttoolguard-0.1.1.tar.gz.
File metadata
- Download URL: agenttoolguard-0.1.1.tar.gz
- Upload date:
- Size: 8.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b5999ad04708a5903cd94d97117b81fa581f479208b19f990a32033b4679f122
|
|
| MD5 |
cdcb53b926c1c2807a94e8cd0989d626
|
|
| BLAKE2b-256 |
fbd455ca8a741a205d85e6d71442c343e43422280c2a23fff6ff00d9b9258942
|
File details
Details for the file agenttoolguard-0.1.1-py3-none-any.whl.
File metadata
- Download URL: agenttoolguard-0.1.1-py3-none-any.whl
- Upload date:
- Size: 7.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
502a25778d7469351f0bd7d4eb4207976a1a68f41d6e573a50fdd42321490abd
|
|
| MD5 |
1d834da988d75704b0fa06bf6590b1a6
|
|
| BLAKE2b-256 |
4828caa159d73d0cc1eb61448c0ac83d27479b63246c5995f93fe6850beebf36
|