---
title: "Sub-agent 模式参考：spellguard - Sub-agent 模式 | 思行致远"
canonical: "https://siyuanailab.com/knowledge/workflows/agent-building/sub-agent-patterns/agent-building-subagents-spellguard/"
dateModified: "2026-06-30"
datePublished: "2026-06-30"
---

打开 AI·外脑目录  

 

AI·外脑

 [返回专栏首页](https://siyuanailab.com/knowledge/)

 ×

 

站内搜索 

⌕

   

主要栏目

 

- [AI 核心概念](https://siyuanailab.com/knowledge/ai-core/)

- [工作流](https://siyuanailab.com/knowledge/workflows/)

- [工具配置与选型](https://siyuanailab.com/knowledge/toolkits/)

- [信源与标准](https://siyuanailab.com/knowledge/sources/)

- [场景案例 待开发](https://siyuanailab.com/knowledge/scenarios/)

- [职业与能力](https://siyuanailab.com/knowledge/career/)

 

专题

 

- [从这里开始](https://siyuanailab.com/knowledge/start/)

- [获取与安装](https://siyuanailab.com/knowledge/install/)

- [建设日志](https://siyuanailab.com/knowledge/ops/)

  

[工作流子目录](https://siyuanailab.com/knowledge/workflows/) 

基础设施层

 

- [浏览器自动化 **5**](https://siyuanailab.com/knowledge/workflows/infrastructure/browser-automation/)

- [MCP 工具 **5**](https://siyuanailab.com/knowledge/workflows/infrastructure/mcp-tools/)

- [文件系统与本地执行 **5**](https://siyuanailab.com/knowledge/workflows/infrastructure/filesystem-local/)

- [API 网关与工具路由 **5**](https://siyuanailab.com/knowledge/workflows/infrastructure/api-tool-routing/)

Skill 生产线

 

- [目标明确 **5**](https://siyuanailab.com/knowledge/workflows/skill-forge/goal-definition/)

- [Skill 设计 **5**](https://siyuanailab.com/knowledge/workflows/skill-forge/skill-design/)

- [代码实现 **5**](https://siyuanailab.com/knowledge/workflows/skill-forge/implementation/)

- [测试评估 **5**](https://siyuanailab.com/knowledge/workflows/skill-forge/testing-evaluation/)

Skill 参考库

 

- [写作与内容 **5**](https://siyuanailab.com/knowledge/workflows/skill-library/writing-content/)

- [研究与知识 **5**](https://siyuanailab.com/knowledge/workflows/skill-library/research-knowledge/)

- [沟通与协作 **5**](https://siyuanailab.com/knowledge/workflows/skill-library/communication-collaboration/)

- [产品与项目 **5**](https://siyuanailab.com/knowledge/workflows/skill-library/product-project/)

- [数据与分析 **5**](https://siyuanailab.com/knowledge/workflows/skill-library/data-analysis/)

- [创意与设计 **5**](https://siyuanailab.com/knowledge/workflows/skill-library/creative-design/)

- [商业与营销 **5**](https://siyuanailab.com/knowledge/workflows/skill-library/business-marketing/)

Agent Building

 

只收录有多步工作流、工作标准、Loop、Harness、工具链或通信机制的真 Agent；不收纯 persona、profile、curated list 或只有 system prompt 的仓库。

 

- [多 Agent 框架 **5**](https://siyuanailab.com/knowledge/workflows/agent-building/multi-agent-frameworks/)

- [工作流编排 **5**](https://siyuanailab.com/knowledge/workflows/agent-building/workflow-orchestration/)

- [Sub-agent 模式 **5**](https://siyuanailab.com/knowledge/workflows/agent-building/sub-agent-patterns/) 

- [WF-086 Sub-agent 模式参考：claude rlm](https://siyuanailab.com/knowledge/workflows/agent-building/sub-agent-patterns/agent-building-subagents-claude-rlm/)

- [WF-087 Sub-agent 模式参考：dart agent core](https://siyuanailab.com/knowledge/workflows/agent-building/sub-agent-patterns/agent-building-subagents-dart-agent-core/)

- [WF-088 Sub-agent 模式参考：fable mode](https://siyuanailab.com/knowledge/workflows/agent-building/sub-agent-patterns/agent-building-subagents-fable-mode/)

- [WF-089 Sub-agent 模式参考：sagents](https://siyuanailab.com/knowledge/workflows/agent-building/sub-agent-patterns/agent-building-subagents-sagents/)

- [WF-090 Sub-agent 模式参考：spellguard](https://siyuanailab.com/knowledge/workflows/agent-building/sub-agent-patterns/agent-building-subagents-spellguard/)

- [Harness 与评估 **5**](https://siyuanailab.com/knowledge/workflows/agent-building/harness-evaluation/)

  

Agent Building · Sub-agent 模式 · Agent Building 参考 · WF-090

 

# Sub-agent 模式参考：spellguard

 

思行致远 · 2026/6/30 · 置信度：高

 

Sub-agent任务委派专家AgentAgent通信

 

一个面向 Agent-to-Agent 通信的安全与审计框架，用 Verifier、加密消息、策略执行和审计日志约束 Agent 间交互。

 

# spellguard

 

> 一个面向 Agent-to-Agent 通信的安全与审计框架，用 Verifier、加密消息、策略执行和审计日志约束 Agent 间交互。

 

## 这个能力解决什么问题

 

Spellguard 解决的是 Agent 之间互相通信时缺少可审计、安全和策略控制的问题。多 Agent 系统一旦可以互发消息、转交任务或调用 MCP，就会出现 MITM、被攻陷 Agent、敏感信息泄漏和事后无法追责的问题。Spellguard 把通信通过 Verifier 中转，记录交互，做策略判断，并支持加密存档与透明日志。

 

## 核心逻辑

 

输入是 Agent 发出的消息、目标 Agent、policy bindings 和通信配置。Client middleware 负责 discovery、attestation、A2A routing；消息经过 cTLS/AMP 等协议加密与承诺记录后进入 Verifier。Verifier 根据 bindings 调用本地或外部 policy engine，例如 prompt-injection flag、regex/keyword block、toxicity BERT sidecar；决策可以 flag、block、redact 等。输出是路由后的 Agent 消息、审计事件、透明日志承诺、S3/加密存档或 policy 决策。

 

## 技术结构

 

- 关键模块：`@spellguard/client` 提供客户端中间件；`@spellguard/verifier` 是代理和策略执行核心；`ctls` 做双向证明与临时密钥；`amp` 做加密消息和承诺日志；LangChain/OpenAI/CrewAI/MCP guard 提供集成；policy-sdk/catalog 支持外部策略。
 
- 调用链路：Agent SDK 被 Spellguard 包裹 → outbound/inbound 消息进入 Verifier → policy evaluator 读取 bindings → 外部 policy server 可参与判断 → 审计事件写 ring/log/archive → 消息允许、阻断或改写。
 
- 输入输出：输入是 Agent 消息、policy config、agent identity、OpenRouter/API 配置；输出是加密存档、audit events、policy verdict、Agent 响应。
 
- 核心依赖：TypeScript monorepo、Python 3.13 包、pnpm、Verifier 服务；demo Agent 需要 OpenRouter key。

 

## 为什么值得参考

 

Spellguard 的参考价值在于它把 Agent 间通信当成安全协议，而不是“两个 Agent 互相发 prompt”。Verifier 是一个很好的中间层模式：所有消息都经过同一处做策略、审计、加密和追责。对企业 Agent 来说，A2A 安全很可能比单 Agent 智能更重要。

 

## 为什么不建议直接套用

 

它是安全基础设施，不是普通多 Agent 编排器。直接跑 demo 需要 Verifier、多个 agent `.env`、OpenRouter key、TS/Python 工作区和可能的外部 policy sidecar。默认示例 policy 只是演示，不能替代企业规则。加密、审计和策略一旦接入生产，还会涉及密钥管理、日志留存、事故响应和合规。

 

## 如何改造成自己的版本

 

- 先实现一个轻量 Verifier：所有子 Agent 消息必须经过中间层记录。
 
- 审计事件至少包含 sender、receiver、message hash、policy verdict、reason、timestamp。
 
- 从三类 policy 开始：敏感信息、越权工具、外部发送。
 
- 对低风险内部消息只 log，对高风险消息 block/redact/require approval。
 
- 等协议稳定后，再考虑加密存档、透明日志和 A2A/MCP 标准集成。

 

## 适用场景

 

- 企业多 Agent、跨服务 Agent、A2A/MCP 通信需要审计和策略控制。
 
- 需要调查 post-mortem：谁给谁发了什么、为什么被允许。
 
- 想学习 Agent 安全中间层和 policy-as-service。

 

## 不适用场景

 

- 单机个人 Agent 或没有 Agent-to-Agent 通信的流程。
 
- 没有密钥/日志/合规治理能力的小项目。
 
- 只想做角色协作，不关心安全审计的 demo。

 

## Agent Building 判断

 

- 多步工作流：Agent outbound → client middleware → Verifier → policy evaluation → audit/archive → route/block/redact。
 
- 工作标准：message routing、policyType/effect/config、audit events、attestation 和 encrypted archive 都有明确角色。
 
- Loop 标准：每次通信都进入策略循环，policy 可 flag/block/redact，并写入可复核记录。
 
- Harness 标准：unit/integration tests、policy examples、audit endpoint 和 demo agents 构成验证面。
 
- 工具调用链路或 Agent 间通信：核心就是 A2A 通信中间层，并扩展到 LangChain/OpenAI/CrewAI/MCP。
 
- 为什么不是 persona / profile / system prompt only：它处理真实消息路由、安全协议、策略和审计，不是角色模板。

 

## 参考信息

 

- 原项目：[spellguard](https://github.com/Spellguard/spellguard)
 
- 作者：Spellguard
 
- 相关概念：[[Sub-agent模式]]、[[Agent安全]]
 
- 相关卡片：[workflow-read-093](https://siyuanailab.com/knowledge/workflows/agent-building/harness-evaluation/agent-building-harness-evaluation-halo/)

 

## 参考对象信息

 

**名称：**spellguard

 

**作者：**Spellguard

 

**链接：**[https://github.com/Spellguard/spellguard](https://github.com/Spellguard/spellguard)

 

## 适用场景与行动

 

**场景：**Agent Building / Sub-agent 模式

 

**适合谁：**关注 AI 工作流、Skill 生产和 Agent Building 的读者

 

**下一步：**先阅读边界说明，再判断它是否适合改造成自己的Sub-agent 模式流程。

 

当前内容按公开来源和已审核草稿整理，只作为工作流理解与方法论参考。

 

涉及客户数据、外部平台、会议记录和业务系统的场景，必须保留人工确认与授权边界。

  

[上一张：Sub-agent 模式参考：sagents](https://siyuanailab.com/knowledge/workflows/agent-building/sub-agent-patterns/agent-building-subagents-sagents/)

 

[返回当前分类](https://siyuanailab.com/knowledge/workflows/agent-building/sub-agent-patterns/) [返回工作流专栏](https://siyuanailab.com/knowledge/workflows/)
