mirror of
https://github.com/ThearchyHelios/AgentLab.git
synced 2026-11-24 21:32:18 +00:00
可点击证据第四期:结论句由模型裁判;只引单元格的问数据图能发成受管
一、结论句裁判
- 报告节点新增 claims: judge:写完、核对完之后,把结论句和它引用的证据摘录交给裁判模型,
判为支持 / 部分支持 / 不支持 / 不是结论,附一句理由;判定只标注,不改写正文
- 送裁判的句子按固定规则预筛:带引用的、含方向词或因果词的送去判,短句、过渡句不送
- 证据摘录:指标写名称、值和原式;查询给 SQL 前 300 字和被引用的行,被引用的列一定给到;遮罩列一律不给;
规则里写明「数字已经由系统核对过,不要复算」
- 一份报告合并成一次调用,超出句数就分批;结构化输出失败时退回 JSON 解析,再失败记为未裁判
- 裁判模型的优先级:节点上写的 > 设置里的「证据裁判模型」> Copilot 的模型;思考关闭;
和写作模型相同时给警告(等于自己审自己)
- rewrite_once(默认关):把不支持的句子和理由交回写作者只改这几句,再裁一次;
改写稿冒出原稿没有的问题就不采用,保留原稿和原来的判定
二、成本上限
- 每份报告的句数、金额、时长,探索运行每次点击的金额,全局每日金额,每一项都可以自定义,也都可以设成不限;
默认 40 句、$0.05、30 秒,每次点击 $0.01,每天 $2
- 调用前先估算,超出上限按优先级截断:先判带引用的,再判含方向词、因果词的,其余记为未裁判并写明「已到上限」;
不报错,也不让报告失败
- 每日花费按本地日期计数,持久化在设置表里;重跑同一次运行不重复计费;价格目录里没有的模型只计次数,并写明估不出金额
三、正式运行与探索运行
- 正式运行在报告节点内裁判,判定写进报告文档、随文档封存;不支持的按 on_unsupported(degrade / withhold)降档或不予出具,
裁判没跑成记缺口,不能判完整出具
- 探索运行按需裁判:POST /api/runs/{id}/evidence/judge,点开哪句判哪句;判定作为 evidence.judged 事件追加在封存之后,
标「封存后追加」,封存核对仍然一致;只读封存范围内的工件;同一句不重复判;运行在裁判期间被接着跑时不记录
- 正式运行调这个接口返回 409,写明「正式运行的裁判在节点内完成」
四、治理与自动修复
- G3 放开 judge:受管级别写 judge 必须写预算(judge.max_cost_usd,或显式写 null 表示不限)
- 发布前自动修复:缺预算时给选项(默认金额 / 不限),不替人选;
从 require_citation 改成 judge 不算降低要求,judge 改回 off、withhold 放宽成 degrade 算降低要求
- Copilot 手册:受管模板可以写 judge 并带预算;问数据按需裁判,不替人打开结论句策略
五、界面
- 结论句句末放徽标:支持 ◆、部分支持 ◇、不支持 ! 整句浅底、未裁判 ?;不用表示「已核对」的绿色;n / N 也跳到不支持的句子
- 证据面板里「模型的解释」:带「模型判断 · 模型名 · 非确定」,封存后追加的另外标出;
「请模型判断这句」只在探索运行、还没判过时出现,触顶时写明已到上限和怎么调
- 出具横幅多一段结论句计数;设置页新增「证据裁判」一组(裁判模型、各项上限、今日花费),设成不限时写明费用受什么约束;
报告节点可以配 judge;运行轨迹里裁判相关的事件都有中文标题
六、门禁修正
- 引用模式下,图里没有口径卡(只引查询单元格)的,出具契约不再要求 metrics_from,受管门禁也不再要求 required:
strict 加 cells 已经保证每个数都点得开、对不上就不予出具;有口径卡的照旧要求。
以前问数据的图怎么都发不成受管,Copilot 补上契约也会被判「冒出新的问题」作废
This commit is contained in:
@@ -326,3 +326,74 @@ async def test_the_report_node_and_the_exit_check_agree_when_the_status_changes_
|
||||
assert seen == [True, True], seen
|
||||
issuance = row.output["_issuance"]
|
||||
assert issuance["tier"] == "withheld" and CELLS_REASON in issuance["unresolved"][0]["message"], issuance
|
||||
|
||||
|
||||
# --------------------------------------------------------------------------
|
||||
# 只引单元格、没有口径卡:契约不用写 metrics_from
|
||||
#
|
||||
# 问数据的典型图是 input → 取数 → 报告 → 出口,报告直接引用查过的单元格。受管级别在契约里
|
||||
# 写 cells: true 就够了(用户拍板的第 5 条),以前校验和门禁无条件要 metrics_from,
|
||||
# 这张图怎么都发不成受管,Copilot 补上契约也会被判「冒出新的问题」作废
|
||||
# --------------------------------------------------------------------------
|
||||
|
||||
|
||||
def cells_only(**contract):
|
||||
contract = {"report_from": "write", "strict": True, "cells": True, **contract}
|
||||
nodes = [
|
||||
node("start", "input"),
|
||||
node("fetch", "tool", tool="db_query__shop",
|
||||
args={"sql": "SELECT SUM(amount) AS gmv, COUNT(*) AS orders FROM orders"}),
|
||||
node("write", "report", instructions="写周报", numbers="strict", on_violation="fail",
|
||||
claims="require_citation"),
|
||||
node("out", "output", fields=[{"name": "周报", "value": "{{ nodes.write.text }}"}], contract=contract),
|
||||
]
|
||||
return {"nodes": nodes, "edges": [{"source": a["id"], "target": b["id"]} for a, b in zip(nodes, nodes[1:])]}
|
||||
|
||||
|
||||
def contract_codes(graph: dict, level: str = "governed") -> tuple[list[str], list[str]]:
|
||||
from app.engine.governance import lint_for_publish
|
||||
from app.engine.schema import GraphSpec, validate_graph
|
||||
|
||||
spec = GraphSpec.model_validate(graph)
|
||||
return ([i.code for i in validate_graph(spec).issues if i.level == "error"],
|
||||
[i.code for i in lint_for_publish(spec, level=level).issues if i.level == "error"])
|
||||
|
||||
|
||||
def test_a_cells_only_contract_needs_no_metrics_from():
|
||||
validate, gate = contract_codes(cells_only())
|
||||
assert validate == [], validate
|
||||
assert gate == [], gate # 受管门禁整张图一条 error 都没有
|
||||
|
||||
|
||||
def test_a_cited_contract_that_lists_required_metrics_still_needs_metrics_from():
|
||||
validate, gate = contract_codes(cells_only(required=["gmv"]))
|
||||
assert "contract.metrics_from_missing" in validate and "contract.metrics_from_missing" in gate
|
||||
validate, gate = contract_codes(cells_only(expected=["gmv"]))
|
||||
assert "contract.metrics_from_missing" in validate and "contract.metrics_from_missing" in gate
|
||||
|
||||
|
||||
def test_a_narrative_contract_still_needs_metrics_from():
|
||||
graph = cells_only(report_from=None, narrative="{{ nodes.write.text }}")
|
||||
graph["nodes"][-1]["data"]["config"]["contract"].pop("report_from")
|
||||
validate, _ = contract_codes(graph, level="published") # 受管级别不收 narrative,只看校验
|
||||
assert "contract.metrics_from_missing" in validate
|
||||
|
||||
|
||||
async def test_a_governed_formal_run_over_cells_only_issues_formally(client, monkeypatch):
|
||||
Writer(monkeypatch, text="本周销售额 [[v:Q1.r0.gmv]]。")
|
||||
row = await formal(client, cells_only(), status="governed")
|
||||
assert row.status == "succeeded", row.error
|
||||
issuance = row.output["_issuance"]
|
||||
assert issuance["mode"] == "citations" and issuance["tier"] == "formal", issuance
|
||||
assert issuance["unresolved"] == [] and issuance["gaps"] == [], issuance
|
||||
[cell] = [m for m in issuance["matched"] if m.get("cell")]
|
||||
assert cell["cell"] == "Q1.r0.gmv" and cell["token"] == "300.5"
|
||||
|
||||
|
||||
def test_a_graph_with_a_caliber_card_still_needs_required_even_without_metrics_from():
|
||||
graph = weekly(cells=True)
|
||||
contract = graph["nodes"][-1]["data"]["config"]["contract"]
|
||||
contract.pop("metrics_from"), contract.pop("required")
|
||||
validate, gate = contract_codes(graph)
|
||||
assert "contract.required_missing" in gate, gate # 不写 metrics_from 绕不过必需指标
|
||||
assert validate == [], validate
|
||||
|
||||
Reference in New Issue
Block a user