OKF v0.2:让智能体生成的知识具备可追溯、可验证的信任信号

2026-07-25 20 预计阅读时间: 1 分钟
来源: cloud.google.com AI 摘要 Original link

Disclaimer: This article is an AI-assisted summary. Read it together with the original source when precision matters. The summary may omit context, version differences, or edge cases and is not official documentation.

预计阅读时间:9 分钟

当智能体开始批量编写表结构、指标定义和运维手册,知识库面对的问题就不再只是“内容是否完整”,而是“消费者凭什么相信它”。OKF v0.2 在保持 Markdown 与 YAML frontmatter 这一轻量结构的同时,加入来源、验证、新鲜度、生命周期和计算证明等可机器读取的信号,让另一个智能体在读取正文、执行查询或展示数字之前先做判断。

从描述知识转向筛选知识

OKF v0.1 的 typetitledescriptionresourcetags 主要描述概念是什么。v0.2 新增的字段则帮助消费者决定是否采用这个概念:

  • sources:内容从哪些材料推导而来,并可记录作者、使用次数和最后修改时间。
  • generated:当前内容由谁生成,以及何时发生了最近一次实质变更。
  • verified:哪些人或自动化流程独立核对过内容。
  • status:概念处于 draftstable 还是 deprecated;缺省时视为 stable
  • stale_after:超过哪个绝对日期后需要重新核验。

这些字段放在 frontmatter 中很关键。搜索器可以只解析文件头,就排除已弃用、已过期或缺少人工复核的定义,无须先把整篇正文送进模型。这既减少 token 消耗,也让信任策略能够由普通程序确定性执行。

一个指标文件可以这样组织:

---
type: Metric
title: Revenue
description: Recognized revenue in USD.
generated:
  by: reference_agent/model-v1
  at: 2026-06-30T14:00:00Z
verified:
  - by: human:finance-owner@example.com
    at: 2026-07-01T09:00:00Z
status: stable
stale_after: 2026-12-31
sources:
  - id: revenue-policy
    resource: policies/revenue-recognition.md
    title: Revenue Recognition Policy
    author: human:finance-owner@example.com
    last_modified: 2026-06-15
---

# Revenue

Only delivered orders beyond the return window are recognized. [^revenue-policy]

这里没有一个由 OKF 预先计算的“可信度分数”。格式只保存客观信号,最终策略由消费者决定。例如,高管看板可以要求人工复核,而测试环境可以接受仅由机器确认的内容。

缺失字段也成为有意义的信号

v0.2 仍然只强制要求 type。新字段全部可选,自定义键也会被保留,因此 v0.1 bundle 仍然有效。不过,可选不等于没有语义:缺少 verified 表示尚未验证,而不是解析失败。

消费者可以从 verified 推导三个实用层级:

  • 没有 verifiedunverified
  • 只有机器主体确认:machine-confirmed
  • 至少存在一个 human:<id> 主体:human-reviewed

stale_after 使用绝对日期而不是相对 TTL,也让判定更稳定。到了 2027-01-01,stale_after: 2026-12-31 的概念无论由谁、在什么环境读取,都得到同样的过期结论。deprecated 则解决另一个问题:旧定义可以继续留在 bundle 中复现历史结果,但不再进入新任务的候选集合。

可以这样实践:在 CI 中扫描 bundle

下面是一个可直接运行的最小消费者。它读取目录下所有 Markdown 文件,推导信任层级,并在文件过期、弃用或未达到要求时返回非零退出码。

先安装依赖:

python -m pip install PyYAML

将下面内容保存为 check_okf.py,运行时把 ./knowledge 替换为实际 bundle 目录:

#!/usr/bin/env python3
import argparse
import datetime as dt
from pathlib import Path

import yaml


def frontmatter(path: Path) -> dict:
    text = path.read_text(encoding="utf-8")
    if not text.startswith("---\n"):
        return {}
    try:
        header, _body = text[4:].split("\n---\n", 1)
    except ValueError:
        raise ValueError(f"{path}: frontmatter is not closed")
    return yaml.safe_load(header) or {}


def trust_tier(meta: dict) -> str:
    verifiers = [str(item.get("by", "")) for item in meta.get("verified", [])]
    if any(actor.startswith("human:") for actor in verifiers):
        return "human-reviewed"
    if verifiers:
        return "machine-confirmed"
    return "unverified"


def main() -> int:
    parser = argparse.ArgumentParser()
    parser.add_argument("bundle", type=Path)
    parser.add_argument(
        "--minimum-trust",
        choices=["unverified", "machine-confirmed", "human-reviewed"],
        default="human-reviewed",
    )
    args = parser.parse_args()

    rank = {"unverified": 0, "machine-confirmed": 1, "human-reviewed": 2}
    today = dt.date.today()
    failed = False

    for path in sorted(args.bundle.rglob("*.md")):
        meta = frontmatter(path)
        if not meta:
            continue
        tier = trust_tier(meta)
        status = meta.get("status", "stable")
        stale_after = meta.get("stale_after")
        stale = bool(stale_after and dt.date.fromisoformat(str(stale_after)) < today)
        accepted = (
            status != "deprecated"
            and not stale
            and rank[tier] >= rank[args.minimum_trust]
        )
        print(f"{'OK' if accepted else 'REJECT'} {path}: {tier}, {status}, stale={stale}")
        failed |= not accepted

    return int(failed)


if __name__ == "__main__":
    raise SystemExit(main())

执行检查:

python check_okf.py ./knowledge --minimum-trust human-reviewed

实际接入时,通常还应验证 generated.atverified.at 的时间格式、检查 sources[].resource 是否可解析,并为不同发布目标配置不同的最低信任等级。不要把 human-reviewed 误当成访问控制;它只是内容治理信号,权限仍应由独立的身份与授权系统处理。

Attested Computation 约束每一次计算

来源证明“定义从哪里来”,却不能证明智能体展示的数字确实由批准的 SQL 算出。v0.2 因此引入 Attested Computation:文件声明固定计算、允许填写的参数、执行器以及验证执行回执的 attester。

---
type: Attested Computation
title: Revenue for a fiscal year
runtime: bigquery
parameters:
  - name: year
    type: integer
    required: true
executor:
  resource: skills/run-on-bq.md
  receipt: [job_id, executed_sql, result]
attester:
  resource: attesters/sql_equality.py
status: stable
stale_after: 2026-12-31
---

# Computation

SELECT SUM(net_amount) AS revenue_usd
FROM `acme.sales.orders`
WHERE order_status = 'delivered'
  AND EXTRACT(YEAR FROM order_ts) = @year

在这个模型中,智能体只能绑定已声明参数,不能临时改写 SQL。执行器返回 job_id、实际 SQL 和结果;确定性的 attester 再比较批准的计算与实际执行内容,并核对展示值。换表、增删过滤条件或修改依赖都应使证明失败。

需要特别区分验证与证明:verified 表示定义与政策一致,是较慢、文档级的治理动作;attestation 针对单次运行,必须在运行时执行,也不应写回 bundle。一个过期定义仍可能通过 SQL 一致性检查,而刚由财务人员复核的定义也不能免除逐次 attestation。

采用时的边界与顺序

OKF v0.2 是增量且向后兼容的:旧 timestamp 可回退映射到 generated.at,旧正文中的 Citations 列表可回退为 sources。团队没有必要一次填满全部字段。

更稳妥的落地顺序是:先让生产者写入 generatedsources,再由 CI 检查 statusstale_after 与最低验证等级;涉及财务、计费或合规数字时,再引入 Attested Computation。与此同时,应明确验证者身份格式、重新核验责任人和过期后的处理方式。

OKF 的价值不在于替团队决定什么可信,而在于把判断所需的证据放进一个开放、可移植、便于程序过滤的格式中。对于由智能体持续生产、再由其他智能体消费的知识库,这正是从“能够读取”走向“能够负责地采用”的关键一步。


相关推荐