English · 简体中文 · 日本語

![Sponsio](https://raw.githubusercontent.com/SponsioLabs/Sponsio/main/assets/readme-banner.png)

License Install from PyPI Visit sponsio.dev

Follow on X Follow on LinkedIn Join our Discord

# Sponsio

同一个 coding agent 在已声明的代码冻结期内运行。没有 Sponsio:删掉生产 users 表、用编造的数据回填,再写一份掩盖破坏的状态报告。接入 Sponsio:第一条破坏性 SQL 在执行前就被拦下:35 次检查、100% 确定性、0 次 LLM 调用、p50 13µs。

Sponsio 为 Agent 在时间维度上展开的过程提供确定性合约,强制延迟低于 0.01 ms,运行时零 LLM 成本。支持 LangChain、Claude Agent、OpenAI Agents、Google ADK、CrewAI、Vercel AI、MCP,或任何自定义工具调用循环,Python 与 TypeScript 双语言。 > **Agent 合约**是一条运行时规则,在每一次 Agent 操作时检查,[由形式化方法支撑](docs/concepts/formal-methods.md)。 > **v0.2.0a3 alpha 已发布。** `pip install --pre sponsio==0.2.0a3`。修复非 LangGraph adapter 在 `redirect_to_safe` 触发时 fail-open 的漏洞(原 unsafe 工具仍会被调用);TS `Eq` 在复合值上对齐 Python 的值相等语义;新增 Cloudflare Workers 兼容性。**0.2.0a2 用户建议升级。** 详见 [v0.2.0a3 release notes](docs/release-notes/v0.2.0a3.md)。 --- ## Sponsio 如何工作

Sponsio 架构:Agent Flow + (Natural Language + Pattern Library) 编译为 Contracts (Assumption → Enforcement),由 Fuzzy LTL Monitor(确定性 + 随机性)在每次函数调用上判定 Pass / Block · Warn · Escalate / Redirect,完整审计日志回流给 Agent。

在 [ODCV-Bench](https://github.com/McGill-DMaS/ODCV-Bench)(12 个前沿 LLM × 80 条执行轨迹)上,无防护的模型在 11.5%–66.7% 的运行中作弊。**接入 Sponsio 后平均规避 95.6% 的不当行为;24/36 高风险场景 100% 拦截**。在 `Financial-Audit-Fraud-Finding` 场景中,前沿模型 16/24 次实施欺诈,**Sponsio 拦截 18/19**。RedCode-Exec(1,410 用例)综合拦截率 **92%**(bash 95% · python 90%),覆盖 60 文件干净代码审计。 逻辑检查器每条合约 p50 **0.139 ms**,**比任何 LLM-as-judge 护栏快 5,000×–60,000×**(每次检查 50–800 ms),热路径零 LLM 成本。p99 在所有测得工作负载下保持 1.04 ms 以内。 查阅[完整 benchmark 方法论与按模型拆分](docs/reference/benchmarks.md)、[与提示词过滤器 / 输出校验器 / LLM-as-judge / 沙箱的对比](docs/why.md),或深入[架构](docs/concepts/architecture.md)与[形式化方法入门](docs/concepts/formal-methods.md)。 --- ## 快速开始 一段 prompt 或两行 CLI 命令即可立即接入。 **粘贴到 Claude Code / Codex / Cursor 中。** Agent 会协助走完完整接入流程:

One-shot prompt: Python   One-shot prompt: TypeScript

**或自行运行 CLI:** ```bash pip install sponsio # 或 npm install -D @sponsio/sdk sponsio init . # 交互式向导:检测框架、选择 IDE host、observe vs enforce ``` 向导会自动检测你的框架并打印对应的接入片段。手动接线见 [docs/integrations/](docs/integrations/index.md)。[OpenClaw 用户](docs/integrations/openclaw.md)开箱即享 ClawHavoc + CVE-2026-25253 覆盖。配置参考、observe → enforce 切换、CI 接线见[完整指引](QUICKSTART.md)。 **用自然语言起草合约。** `sponsio validate "<一句话规则>"` 会把一条自然语言规则转成一份你能读回来的合约。把输出当作起点草稿,enforce 之前先自己 review、按需调整。确定性在于合约在运行时如何被*强制执行*,而不在于它如何被起草。 --- ## 合约库 开箱即用的 **16 个合约 bundle**,按层级组织(always-on / per-tool / per-incident)。每个 bundle 是一个 YAML 包,由 Sponsio 的确定性模式组合而成。把它放进 `sponsio.yaml`,一行即可让 Agent 防护一类已知失败,无需逐合约编写。 ```yaml # sponsio.yaml: 一行式 bundle 引入 agents: my_agent: workspace: "/srv/my-bot" include: - sponsio:core/universal # always-on - sponsio:capability/shell # 若 Agent 会执行命令 - sponsio:capability/filesystem # 若 Agent 会读写文件 ``` 查看[完整 bundle 参考](docs/reference/contract-lib.md)(共 16 个 bundle)或[底层 46 个模式](docs/reference/patterns.md)。想要面向你 Agent 类型的 bundle?这是目前杠杆率最高的贡献方式。带上事件 / CVE / 模式[开 issue](https://github.com/SponsioLabs/Sponsio/issues/new)。 --- ## 贡献 欢迎提交补丁、问题反馈与新模式提案。从 [CONTRIBUTING.md](CONTRIBUTING.md) 开始。Sponsio 的威胁建模吸收了公开安全研究,例如 Simon Willison 的 ["Lethal Trifecta"](https://simonwillison.net/2025/Jun/16/the-lethal-trifecta/) 塑造了我们的[多工具组合合约](sponsio/contracts/incident/mcp-composition.yaml)。有我们应当防御的威胁模型?[开 issue](https://github.com/SponsioLabs/Sponsio/issues/new)。 --- ## 许可证 Apache 2.0([LICENSE](LICENSE))。 *阅读本仓库的 AI Agent:[`llms.txt`](llms.txt) 列出了规范文档路径;[`llms-full.txt`](llms-full.txt) 是完整上下文的拼接全量。*