← [ BACK_TO_NOTES ]

Agent Evidence Consistency Contract

定义 Agent 输出从“结构合法”升级到“证据一致”的运行时契约:每个可进入业务状态的 claim/observation 必须引用真实、可采纳且与语义类型兼容的当前证据。

#concept #growing #ai #architecture #agent

[!info] related notes

Agent Evidence Consistency Contract

一句话定义

Evidence Consistency Contract 要求:一个结构上合法的 Agent 输出,只有在它声明的业务语义能被本轮权威证据集合支持时,才有资格继续进入 Domain、Persistence 或 Side Effect。

它解决的是 Structured Output / JSON Schema 没有解决的问题:

schema valid
≠ evidence exists
≠ evidence admissible
≠ evidence supports this kind of claim
≠ claim may become durable truth

为什么只做 Schema Validation 不够

假设模型返回:

{
  "kind": "posture_asymmetry",
  "label": "高低肩",
  "description": "右肩高于左肩"
}

它完全可以满足:

kind      非空 ✅
label     非空 ✅
description 非空 ✅
JSON      合法 ✅

但如果本轮实际上:

images = []
posture_analysis = {}
report_indicators = []

那么这个输出仍然是业务非法的。

因此必须新增另一层问题:

这个 observation 到底由哪一条本轮可用 evidence 支持?

最小不变量

最小形式可以写成:

observation O
→ exists evidence E
→ E belongs to authoritative catalog
→ E is admissible in this run
→ O.kind is compatible with E.source / E.kind

若系统允许自由文本 claim,还需要继续验证:

O.claim is entailed by E

否则即使 ref 是真的,文本也可能继续扩张出来源没有表达的含义。

Evidence Truth 必须由应用拥有

模型可以选择 evidence,但不能自己宣布 evidence 存在。

错误边界:

LLM:
"我引用 posture:shoulder:1,所以我有体态证据"

正确边界:

Application frozen input
→ build authoritative evidence catalog
→ model selects ref
→ runtime checks ref ∈ catalog

所以:

model-declared provenance
≠ evidence truth

真正的 evidence truth 应来自本轮冻结输入、工具 observation、受治理检索结果或 durable domain state。

Contract 通常要验证哪几件事

1. Ref 存在性

selected_ref ∈ authoritative_catalog

不存在的 ref 直接拒绝。

2. Ref 唯一性

如果业务规定一条 evidence 只能投影一个 observation:

same ref selected twice
→ reject

避免模型把同一来源拆成多个看似独立的“证据”。

3. Source Policy

例如:

posture_alignment
→ posture_analysis only

report_indicator
→ report only

不能因为“都有 evidence ref”就允许任意跨来源引用。

4. Kind Compatibility

同一个 source 内仍要区分语义类型。

例如:

exercise_pattern
→ BodyState lifestyle.exercise

lifestyle_pattern
→ BodyState lifestyle.* except exercise

否则“久坐”可以被错误包装成“运动模式”。

5. Evidence Lifecycle / Review State

在有长期状态的系统里:

unverified
rejected
inactive
excluded_from_reasoning

通常都不应自动成为新的推理证据。

否则系统会把尚未确认的 AI observation 反复自我强化。

Evidence Consistency 与 Evidence Admissibility 的区别

Evidence Admissibility 主要回答:

“这条 evidence 本身是否允许进入当前决策?”

Evidence Consistency 继续回答:

“当前输出所声称的 kind / claim,是否真的可以由这条 evidence 支持?”

因此:

Evidence exists
→ admissible?
→ compatible with output semantics?
→ only then can output pass

Evidence Consistency 与 Faithfulness 的区别

Faithfulness 常面对较自由的自然语言:

Evidence
→ model prose
→ semantic support check

Evidence Consistency 可以更靠前、更结构化:

kind + exact ref
→ deterministic source/kind policy

如果业务允许把模型权限进一步收缩为 selection-only,甚至可以直接消除大部分自由文本 entailment 问题,见 Selection-Only Agent Output 与 Deterministic Rendering。

为什么 Prompt 不能代替 Contract

Prompt 可以写:

只输出输入证据支持的观察
不要编造体态结论

但 Prompt obedience 是 probabilistic 的。

而 durable state 需要的是:

unsupported output
→ deterministic reject

所以正确分层是:

Prompt
→ 引导模型

Schema
→ 限制输出形状

Evidence Consistency Gate
→ 限制输出是否有资格进入业务系统

一个推荐的 Trust Boundary

Untrusted Model Output
        ↓
Typed Schema Validation
        ↓
Evidence Consistency Gate
        ↓
Domain / Authority Validation
        ↓
Durable Projection / Side Effect

越接近 durable write,系统越不能依赖“模型应该会听话”。

BodySense Assessment 示例

最终契约可以写成:

posture observation
⇒ completed posture evidence exists

进一步收紧:

posture_asymmetry
⇒ exactly one real posture_analysis ref
⇒ ref is in frozen catalog
⇒ ref has not been reused

所以当:

posture_analysis = {}

模型即使返回格式完全正确的:

posture_asymmetry

也必须 fail closed,不能进入 BodyState。

完整事故定位见 BodySense Assessment 无体态证据却生成高低肩的排查。

如何测试这条 Contract

至少应同时有正反例:

A. no posture evidence + posture output
→ reject

B. valid posture evidence + compatible posture output
→ accept

C. real ref + wrong source/kind pair
→ reject

D. nonexistent ref
→ reject

E. same ref selected twice
→ reject

F. unverified/inactive evidence
→ unavailable

这些属于 deterministic policy tests,不应依赖真实 LLM 的随机性。

常见误区

  • JSON 合法就代表输出可信:Schema 只验证形状。
  • 有 citation/ref 就代表 claim 被支持:Provenance 与 entailment 是两件事。
  • 模型写了 evidence 字段,所以 evidence 存在:Evidence truth 必须由应用重建。
  • 只在 Prompt 里要求 grounded 就够了:Prompt 不是 durable trust boundary。
  • 只校验 source 不校验 kind:同来源内部仍可能发生语义错配。
  • 只在 Python 校验一次就够了:如果 Go/Domain 是 durable truth owner,写入前仍值得独立 revalidation。

最短记忆

Schema asks:
“长得对不对?”

Evidence Consistency asks:
“凭什么这么说?”

Durable Authority asks:
“即使有依据,允许写进去吗?”

生产级 Agent 不能把这三个问题合并成一个“模型输出看起来不错”。

创建于 2026/9/1 更新于 2026/10/16
Digital Biome
Access

键盘导航

j / k / ↑ / ↓
选择对象
Enter / o
打开选择
/ 或 Ctrl+K
全站搜索
i / f / 1–4
筛选当前列表
g → h / l / p / t / a
首页 / 笔记 / 项目 / 工具 / About
r → 1–9
打开所选对象的关联
u
返回上一页
Esc
关闭浮层 / 取消命令;输入框内清空文本