返回顶部
g

governed-agents受控代理验证

Deterministic verification + reputation scoring for AI sub-agents. Prevents hallucinated success via 4 code gates (files, tests, lint, AST) and a 3-layer pipeline (Structural → Grounding → LLM Council) for open-ended tasks.

作者: admin | 来源: ClawHub
源自
ClawHub
版本
V 0.1.11
安全检测
已通过
324
下载量
免费
免费
1
收藏
概述
安装方式
版本历史

governed-agents

受控代理

为AI子代理提供确定性验证+信誉评分。通过在更新代理评分前独立验证其声明,防止幻觉式成功(我完成了!)。

纯Python标准库——零外部依赖。

能力

可生成外部CLI(codex、openclaw、git、pytest)并发送HTTP HEAD请求。

适用场景

在以下情况下使用此技能:

  • - 生成子代理并自动验证其输出
  • 跨任务评分代理可靠性(基于EMA的信誉)
  • 检测幻觉式成功——代理声称完成但文件缺失或测试失败
  • 通过LLM委员会验证开放式任务(研究、分析、策略)
  • 基于代理历史记录强制执行监督级别

快速入门

编码任务(确定性验证)

python
from governed_agents.contract import TaskContract
from governed_agents.orchestrator import GovernedOrchestrator

contract = TaskContract(
objective=添加JWT认证端点,
acceptance_criteria=[POST /api/auth 返回JWT, 测试通过],
requiredfiles=[api/auth.py, tests/testauth.py],
runtests=pytest tests/testauth.py -v,
)

g = GovernedOrchestrator(contract, model=openai/gpt-5.2-codex)

代理完成后:


result = g.record_success() # 运行关卡,更新信誉

开放式任务(三层流水线 + LLM委员会)

python
contract = TaskContract(
objective=编写认证模块的架构决策记录,
acceptance_criteria=[记录了权衡, 陈述了决策],
verification_mode=council,
task_type=analysis,
council_size=3,
)

g = GovernedOrchestrator(contract, model=openai/gpt-5.2-codex)
prompts = g.generatecounciltasks(worker_output)
result = g.recordcouncilverdict(rawrevieweroutputs)

→ 委员会:2/3 批准(评分=0.67,通过 ✅)

CLI生成(Codex / OpenClaw)

python
from governedagents.openclawwrapper import spawn_governed

contract = TaskContract(
objective=构建待办事项REST API,
acceptance_criteria=[CRUD端点正常工作, 测试通过],
requiredfiles=[api.py, tests/testapi.py],
)

默认使用Codex 5.3 CLI

result = spawn_governed(contract, engine=codex53)

或通过OpenClaw代理CLI:

result = spawn_governed(contract, engine=openclaw)

验证模式

确定性验证(编码任务)

自动运行4道关卡——必须全部通过:

关卡检查项信号
文件必需文件存在且非空硬性失败
测试
测试命令退出码为0 | 硬性失败 |
| 代码检查 | 无代码检查错误 | 硬性失败 |
| AST | Python文件解析无SyntaxError | 硬性失败 |

如果代理声称成功但任何关卡失败 → 评分覆盖为 -1.0(幻觉惩罚)。

委员会验证(开放式任务)

三层流水线,带短路机制:

  1. 1. 结构关卡(<1秒)——字数、必需章节、无空章节
  2. 基础关卡(5–30秒)——URL可达性、引用检查
  3. LLM委员会(30–120秒)——N个独立评审员,多数投票

如果第1层失败 → 不调用LLM,即时结果,零成本。

信誉系统

R(t+1) = (1 − α) · R(t) + α · s(t), α = 0.3

评分含义
+1.0验证成功(首次尝试)
+0.7
验证成功(重试后) | | +0.5 | 诚实报告障碍 | | 0.0 | 失败但尝试过 | | −1.0 | 幻觉式成功 |

监督级别

信誉级别效果
> 0.8自主完全信任
> 0.6
标准 | 正常监督 | | > 0.4 | 受监督 | 需要检查点 | | > 0.2 | 严格 | 模型覆盖为Opus | | ≤ 0.2 | 暂停 | 任务被阻止 |

任务类型配置

预配置的关卡组合:

task_type第1层第2层最少字数
research字数、来源列表URL可达性、引用200
analysis
字数、必需章节 | 数字一致性 | 150 |
| strategy | 必需章节、字数 | 交叉引用解析 | 100 |
| writing | 字数 | — | 50 |
| planning | 必需章节、包含步骤 | 日期有效性 | 50 |

安装

bash
bash install.sh

→ 将 governedagents/ 复制到 $OPENCLAWWORKSPACE/governed_agents/


→ 运行验证套件(37个测试)

测试

bash
python3 -m pytest governedagents/testverification.py \
governedagents/testcouncil.py \
governedagents/testprofiles.py -v

37 通过

标签

skill ai

通过对话安装

该技能支持在以下平台通过对话安装:

OpenClaw WorkBuddy QClaw Kimi Claude

方式一:安装 SkillHub 和技能

帮我安装 SkillHub 和 governed-agents-1776120612 技能

方式二:设置 SkillHub 为优先技能安装源

设置 SkillHub 为我的优先技能安装源,然后帮我安装 governed-agents-1776120612 技能

通过命令行安装

skillhub install governed-agents-1776120612

下载

⬇ 下载 governed-agents v0.1.11(免费)

文件大小: 55.58 KB | 发布时间: 2026-4-15 12:57

v0.1.11 最新 2026-4-15 12:57
- Improved error handling and messaging in verification logic.
- Minor code refactoring in `verification.py` and `verifier.py` for clarity and maintainability.

Archiver·手机版·闲社网·闲社论坛·羊毛社区· 多链控股集团有限公司 · 苏ICP备2025199260号-1

Powered by Discuz! X5.0   © 2024-2025 闲社网·线报更新论坛·羊毛分享社区·http://xianshe.com

p2p_official_large
返回顶部