← 返回
未分类 中文

GuardRails

Build, run, and extend the Agent Policy & Guardrails Engine. Use when implementing policy formats, enforcement logic, decision conflict resolution, policy AP...
构建、运行并扩展代理策略与防护引擎。用于实现策略格式、强制逻辑、决策冲突解决、策略 API 等。
adad44 adad44 来源
未分类 clawhub v1.0.2 1 版本 100000 Key: 无需
★ 2
Stars
📥 150
下载
💾 0
安装
1
版本
#latest

概述

Agent Policy & Guardrails Engine

Use This Skill When

  • You need to add or change policy enforcement behavior.
  • You need to add policy types (financial, privacy, communication, operational, approval, time-based).
  • You need to extend decision outputs (ALLOW, DENY, MODIFY, REQUIRE_APPROVAL).
  • You need to update APIs, persistence, or audit logging.

Project Layout

  • app/main.py: FastAPI endpoints.
  • app/service.py: orchestration for policy CRUD + evaluation + audit writes.
  • app/engine.py: core policy evaluation and conflict resolution.
  • app/policy_parser.py: JSON/YAML/NL policy parsing into structured definitions.
  • app/schemas.py: request/response and policy schemas.
  • app/models.py: SQLAlchemy models (policies, audit_logs).
  • app/seed.py: baseline policies.
  • tests/test_api.py: API-level behavior.
  • tests/test_engine.py: decision logic behavior.

Standard Workflow

  1. Implement schema/model changes first if policy structure changes.
  2. Update parser and engine evaluation paths.
  3. Update API/service layer only as needed.
  4. Add or update tests for both engine and API.
  5. Run tests before finalizing.

Commands

Install and test:

python3 -m pip install -r requirements.txt
python3 -m pytest

Run locally:

python3 -m uvicorn app.main:app --reload

Enforcement Contract

All external agent/tool actions must be sent to POST /evaluate before execution.

Runtime handling expectations:

  • DENY: block execution.
  • REQUIRE_APPROVAL: pause and require explicit human approval.
  • MODIFY: apply returned modifications, then execute.
  • ALLOW: execute.

Conflict Resolution Rules

When multiple policies match the same action:

  1. Highest priority wins.
  2. If tied on priority, effect severity wins:

DENY > REQUIRE_APPROVAL > MODIFY > ALLOW.

Adding New Guardrails

  1. Add a structured policy in app/seed.py (optional baseline).
  2. Ensure action_types and conditions map to real runtime payload fields.
  3. Add API test coverage in tests/test_api.py using /evaluate.
  4. Add engine-level tests in tests/test_engine.py for edge/conflict cases.

Notes

  • Keep policy evaluation deterministic.
  • Prefer structured JSON/YAML policies for complex controls.
  • Natural-language rules should compile into the same structured policy schema.

版本历史

共 1 个版本

  • v1.0.2 当前
    2026-05-12 06:08 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

ai-agent

Skill Vetter

spclaudehome
AI智能体技能安全预审工具。安装ClawdHub、GitHub等来源技能前,检查风险信号、权限范围及可疑模式。
★ 1,243 📥 271,434
ai-agent

Self-Improving + Proactive Agent

ivangdavila
自我反思+自我批评+自我学习+自组织记忆。智能体评估自身工作、发现错误并持续改进。
★ 1,412 📥 325,303
ai-agent

Agent Browser

rez0
用于 AI 代理的浏览器自动化 CLI。当用户需要与网站交互(包括浏览页面、填写表单、点击按钮、截图等)时使用。
★ 844 📥 325,679