Skip to main content

superagent-build — 自研 Super Agent(治理内嵌 + Watchdog + 主动阈值)

定位:把 dsh-superagent-prototype(22k★)宣传了但没做的四件事真的做出来。 证据链:拆解报告见 ../superagent-dig/01-prototype-dissection.md(文章卖点兑现度表)。

与原型的差异(本项目核心增量)

能力 原型 本项目
跑偏检测 全库零实现 agent/watchdog.py:Mandate 对照 + 确定性规则层 + judge 一票否决
文件级冲突 只在 PR 层暴露 agent/governance.py:写前 claim/check,未声明即 BLOCK
长期记忆 只写不读半成品 agent/store.py 全量落库 + 判定留痕(ruling/watchdog 记录可审计)
主动性开口 无 agent/proactivity.py:p*(t) 临界确证度 + observe 模式攒标注

抄原型的(已验证扎实):两级准入、先存后做 outbox 三角、纯幂等 receipt、follow-up 语义、 bot 门、"Router 少说话"。

架构

Input → intake(幂等 receipt)
  → admission 两级:规则 gate(bot 门/白名单/显式指令/follow-up)
                    → 研判层(mention 时,硬校验:恰好一条规则+证据+防幻觉规则名)
  → accept → Decision → Ticket(订阅线程)→ Assignment → worker 会话
  → worker report → Watchdog 复核(规则层 → judge)→ 治理判决 → 回复出站(outbox 三角)
写前:pre_write → governance.check(未声明 scope 即 BLOCK,落 ruling)
开口:任务完成等事件 → proactivity.evaluate → speak/wait/drop(observe 模式只记录)

运行自检(RED→GREEN 纪律:先注入违规证明会红,再验证放行)

python3 -m pytest tests/ -q             # 新套件:i1_i4 / i2 / i3 / i5 / i6 / integration
python3 tests/test_store.py            # 老套件为自检脚本,逐个跑,末行 FAILURES: none 即过
python3 tests/test_admission_outbox.py # 持久层:先存后做/幂等/退避/崩溃恢复
python3 tests/test_e2e_m0.py           # 端到端:建票→派工→报告→回复→恢复
python3 tests/test_governance.py       # 写作用域治理(M1)
python3 tests/test_watchdog.py         # 跑偏检测(M2)
python3 tests/test_proactivity.py      # 开口阈值(M3)

里程碑状态

  • M0 骨架:准入/outbox/ticket/编排,端到端绿(test_e2e_m0)
  • M1 治理内嵌:governance.py 接进 engine.pre_write + intake 携带 mandate_rules(test_e2e_m1)
  • M2 Watchdog:接进 engine.on_worker_report(deviation → 判决留痕 + 票终止 + 不回复)(test_e2e_m2)
  • M3 主动性:接进 engine(observe 模式先行,判定留痕含 p*/u_eff/confidence 三数)(test_e2e_m3)
  • I1 状态回灌:崩溃恢复补上另一半——Tickets/Thread(含订阅)从 SQLite 重载 + seq 防撞号; 重启后同线程 follow_up 仍附加原票(test_i1_i4)
  • I2 研判接真:assessor.py——LLMAssessor(OpenAI 兼容端点,transport 可注入)+ 有界研判上下文(前5条+trigger+后5条,4000 字符封顶);解析失败/幻觉规则名一律 fail-closed(test_i2_assessor)
  • I3 真执行器:openai_executor.py——OpenAI 兼容 tool-loop worker + metrics.py 成本记账 (逐调用 CallRecord:tokens/延迟/成功率,JSONL 落盘);对接位 = Magpie 网关(test_i3_executor)
  • I4 复审环:deviation 不再一票终止——先给一轮修复机会(违规理由作为修复指令重投 worker, 复核转绿则照常回复),次数用尽才终止 + 落 governance ruling;max_repairs=0 保持 M2 旧契约(test_i1_i4)
  • I5 校准机制:calibration.py——ConfidenceEstimator(证据源合成,已接进 engine 替换硬编码 0.95)+ LabelStore(observe 判定旁路自动攒标注)+ calibrate(网格搜索开口 precision≥0.8)(test_i5_calibration)
  • I6 调度循环:scheduler.py——tick 驱动(max_workers 槽位/idle 超时回收/出站 pump), engine 交付后写 idle_at;无 sleep 无线程,clock 注入可测(test_i6_scheduler)
  • M4 成本对接:../superagent-dig/02-cost-experiment/framework.py 的 harness 适配器位 (metrics.py 的 CallRecord 已是同构对接面)

真实环境对接位(本仓库只含可测内核)

  • openai_executor.py 的 OpenAICompatExecutor:已实现 OpenAI 兼容 tool-loop worker(默认指向 Magpie 网关 http://127.0.0.1:3425),transport 可注入;换 endpoint/model 即换 worker;
  • assessor.py 的 LLMAssessor:已实现研判适配器(有界上下文 + fail-closed),接进 Engine(assessor=...) 即生效;
  • watchdog.py 的 Judge Protocol:接独立 LLM judge(语义层"答非所问"检测);
  • outbox.py 的 Deliverer:接 GitHub/飞书通道(channelGone/channelIgnored 唯二合法放弃);
  • scheduler.py 的 Scheduler.tick:外部主循环每轮调一次即可驱动全系统(无 sleep 无线程);
  • metrics.py 的 MetricsLedger:逐调用成本记账(tokens/延迟/成功率,JSONL 落盘), 与 ../superagent-dig/02-cost-experiment/framework.py 的 CallRecord 同构对接。

Metadata

Release files for superagent-build 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for superagent-build 0.1.0
File Size Uploaded Provenance Actions
superagent_build-0.1.0.tar.gz 59.9 kB Without provenance Details for superagent_build-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for superagent-build 0.1.0
File Interpreter ABI Platform Actions
superagent_build-0.1.0-py3-none-any.whl Python 3 none any Details for superagent_build-0.1.0-py3-none-any.whl

Total release size: 103.8 kB

Release files / superagent_build-0.1.0.tar.gz

Download URL superagent_build-0.1.0.tar.gz
Size 59.9 kB
Tags Source
SHA-256 checksum
How to use checksums
a44ba0e85a2f68a7c46b28e7386ba3099b4a4a3e2af60fcedbce4b4a1d4564dd
BLAKE2b-256 checksum
How to use checksums
974110cabdd6bd6258bad0abb5f713922985eef8458a39d3737feec953ced1b2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Release files / superagent_build-0.1.0-py3-none-any.whl

Download URL superagent_build-0.1.0-py3-none-any.whl
Size 43.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9146941e36447d2a2386f257ac9dc2fbdccfec921f6a03f6726158abb0dde3ef
BLAKE2b-256 checksum
How to use checksums
98978ad230ae1d1d57843d926f6ae626a3e48d4f9163bc2b0e0532c1bd745ed2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Security for superagent-build 0.1.0

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.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page