Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

agenttoolguard-0.1.0.tar.gz (8.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

agenttoolguard-0.1.0-py3-none-any.whl (7.5 kB view details)

Uploaded Python 3

File details

Details for the file agenttoolguard-0.1.0.tar.gz.

File metadata

  • Download URL: agenttoolguard-0.1.0.tar.gz
  • Upload date:
  • Size: 8.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for agenttoolguard-0.1.0.tar.gz
Algorithm Hash digest
SHA256 229598932cde5d4ece76dbd4c7963f7b393a0e1333573db7efef9be1fef6513f
MD5 0c6a15a412c2c4bf1b6f003c8ea859f7
BLAKE2b-256 20bcbecd06e62aeba660843b8086b77f848b5c3aa497ae7b89e29c0a60a20cac

See more details on using hashes here.

File details

Details for the file agenttoolguard-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: agenttoolguard-0.1.0-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

Hashes for agenttoolguard-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 37463175af9381c90d95bd5174b3c3826075a7ac888a3f00e48c5a81be6be7e2
MD5 a88d1e4d92e16882081460f199746ee5
BLAKE2b-256 3ba29a97633647327b511aa334aef15ba5792789a27cce66541d6e79c429cddf

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page