日志复盘:授权元数据与证据报告
App 提供获准证据源,复盘任务通过普通模型与工具合同生成有来源的报告。
source 对每次查询检查真实身份与可见范围。模型通过 history.query 读取证据,再提交 observed、hypothesis 或 recommendation;observed 必须引用本次实际读到的证据 ID。
报告保留不完整与缺失说明,默认 persisted=false。读取许可、交给模型处理与披露结果分别由 App 决定;元数据适配器不传原始日志正文。
由简到繁的同业务示例
绑定复盘模型、证据源和授权
入门 · Node.js
ts
import { defineReflection } from '@jangts/agent-core/kits/reflection';
import type { ReflectionSource } from '@jangts/agent-core/kits/reflection';
import type { ModelRunner, OperationContext } from '@jangts/agent-core';
export function review<App>(model: ModelRunner, source: ReflectionSource<App>,
authorize: (question: string, context: OperationContext<App>) => Promise<void>) {
return defineReflection({ model, source, authorize,
maxCalls: 4, reserveCalls: 1, maxPages: 4, maxEvents: 64, maxEvidenceChars: 12000 });
}js
import { defineReflection } from '@jangts/agent-core/kits/reflection';
export function review(model, source, authorize) {
return defineReflection({ model, source, authorize,
maxCalls: 4, reserveCalls: 1, maxPages: 4, maxEvents: 64, maxEvidenceChars: 12000 });
}从日志 reader 构造同一种证据源
配置 · Node.js
reader 的目录范围、关闭与保留期由 App 管理。适配后的 source 可传入同一个 defineReflection。
ts
import { defineReflectionLogSource } from '@jangts/agent-core/kits/reflection';
import type { ReflectionLogReader } from '@jangts/agent-core/kits/reflection';
import type { OperationContext } from '@jangts/agent-core';
export function logSource<App>(reader: ReflectionLogReader, traceId: string,
authorize: (context: OperationContext<App>) => Promise<void>) {
return defineReflectionLogSource({ reader, traceId, id: 'authorized-history', authorize });
}js
import { defineReflectionLogSource } from '@jangts/agent-core/kits/reflection';
export function logSource(reader, traceId, authorize) {
return defineReflectionLogSource({ reader, traceId, id: 'authorized-history', authorize });
}