Loading...
Loading...
Compare original and translation side by side
┌─────────────┐
│ GENERATOR │ Phase 1: Make a List
│ (Agent A) │ Produce the deliverable
└──────┬───────┘
│ output
▼
┌──────────────────────────────┐
│ DUAL INDEPENDENT REVIEW │ Phase 2: Check It Twice
│ │
│ ┌───────────┐ ┌───────────┐ │ Two agents, same rubric,
│ │ Reviewer B │ │ Reviewer C │ │ no shared context
│ └─────┬─────┘ └─────┬─────┘ │
│ │ │ │
└────────┼──────────────┼────────┘
│ │
▼ ▼
┌──────────────────────────────┐
│ VERDICT GATE │ Phase 3: Naughty or Nice
│ │
│ B passes AND C passes → NICE │ Both must pass.
│ Otherwise → NAUGHTY │ No exceptions.
└──────┬──────────────┬─────────┘
│ │
NICE NAUGHTY
│ │
▼ ▼
[ SHIP ] ┌─────────────┐
│ FIX CYCLE │ Phase 4: Fix Until Nice
│ │
│ iteration++ │ Collect all flags.
│ if i > MAX: │ Fix all issues.
│ escalate │ Re-run both reviewers.
│ else: │ Loop until convergence.
│ goto Ph.2 │
└──────────────┘┌─────────────┐
│ GENERATOR │ 阶段1:生成内容(列清单)
│ (Agent A) │ 产出交付物
└──────┬───────┘
│ 输出内容
▼
┌──────────────────────────────┐
│ 双重独立审核 │ 阶段2:双重审核
│ │
│ ┌───────────┐ ┌───────────┐ │ 两个Agent,同一审核标准,
│ │ 审核者B │ │ 审核者C │ │ 无共享上下文
│ └─────┬─────┘ └─────┬─────┘ │
│ │ │ │
└────────┼──────────────┼────────┘
│ │
▼ ▼
┌──────────────────────────────┐
│ verdict 关卡 │ 阶段3:是否符合要求
│ │
│ B通过 且 C通过 → 符合要求 │ 必须两者都通过,无例外。
│ 否则 → 存在问题 │
└──────┬──────────────┬─────────┘
│ │
符合要求 存在问题
│ │
▼ ▼
[ 发布 ] ┌─────────────┐
│ 修正循环 │ 阶段4:持续修正直至符合要求
│ │
│ iteration++ │ 收集所有标记问题
│ if i > MAX: │ 修复所有问题
│ 升级至人工审核 │ 重新运行两个审核者
│ else: │ 循环直至收敛
│ 回到阶段2 │
└──────────────┘undefinedundefinedundefinedundefinedREVIEWER_PROMPT = """
You are an independent quality reviewer. You have NOT seen any other review of this output.REVIEWER_PROMPT = """
你是一名独立质量审核者,未查看过该输出内容的任何其他审核结果。
```python
```pythonundefinedundefined| Criterion | Pass Condition | Failure Signal |
|---|---|---|
| Factual accuracy | All claims verifiable against source material or common knowledge | Invented statistics, wrong version numbers, nonexistent APIs |
| Hallucination-free | No fabricated entities, quotes, URLs, or references | Links to pages that don't exist, attributed quotes with no source |
| Completeness | Every requirement in the spec is addressed | Missing sections, skipped edge cases, incomplete coverage |
| Compliance | Passes all project-specific constraints | Banned terms used, tone violations, regulatory non-compliance |
| Internal consistency | No contradictions within the output | Section A says X, section B says not-X |
| Technical correctness | Code compiles/runs, algorithms are sound | Syntax errors, logic bugs, wrong complexity claims |
| 准则 | 通过条件 | 失败信号 |
|---|---|---|
| 事实准确性 | 所有声明均可通过源材料或常识验证 | 虚构统计数据、错误版本号、不存在的API |
| 无幻觉内容 | 无虚构实体、引用、URL或参考文献 | 指向不存在页面的链接、无来源的引用内容 |
| 完整性 | 任务说明中的所有需求均已覆盖 | 缺失章节、遗漏边缘情况、覆盖不完整 |
| 合规性 | 符合所有项目特定约束 | 使用禁用术语、违反语气要求、不符合监管规定 |
| 内部一致性 | 输出内容无自相矛盾 | A章节说明X,B章节说明非X |
| 技术正确性 | 代码可编译/运行、算法合理 | 语法错误、逻辑漏洞、错误的复杂度声明 |
anyanydef santa_verdict(review_b, review_c):
"""Both reviewers must pass. No partial credit."""
if review_b.verdict == "PASS" and review_c.verdict == "PASS":
return "NICE" # Ship it
# Merge flags from both reviewers, deduplicate
all_issues = dedupe(review_b.critical_issues + review_c.critical_issues)
all_suggestions = dedupe(review_b.suggestions + review_c.suggestions)
return "NAUGHTY", all_issues, all_suggestionsdef santa_verdict(review_b, review_c):
"""两个审核者必须全部通过,无部分通过情况。"""
if review_b.verdict == "PASS" and review_c.verdict == "PASS":
return "NICE" // 发布内容
// 合并两个审核者标记的问题并去重
all_issues = dedupe(review_b.critical_issues + review_c.critical_issues)
all_suggestions = dedupe(review_b.suggestions + review_c.suggestions)
return "NAUGHTY", all_issues, all_suggestionsMAX_ITERATIONS = 3
for iteration in range(MAX_ITERATIONS):
verdict, issues, suggestions = santa_verdict(review_b, review_c)
if verdict == "NICE":
log_santa_result(output, iteration, "passed")
return ship(output)
# Fix all critical issues (suggestions are optional)
output = fix_agent.execute(
output=output,
issues=issues,
instruction="Fix ONLY the flagged issues. Do not refactor or add unrequested changes."
)
# Re-run BOTH reviewers on fixed output (fresh agents, no memory of previous round)
review_b = Agent(prompt=REVIEWER_PROMPT.format(output=output, ...))
review_c = Agent(prompt=REVIEWER_PROMPT.format(output=output, ...))MAX_ITERATIONS = 3
for iteration in range(MAX_ITERATIONS):
verdict, issues, suggestions = santa_verdict(review_b, review_c)
if verdict == "NICE":
log_santa_result(output, iteration, "passed")
return ship(output)
// 修复所有阻塞性问题(优化建议为可选)
output = fix_agent.execute(
output=output,
issues=issues,
instruction="仅修复标记的问题。请勿重构或添加未要求的修改。"
)
// 在修正后的输出上重新运行两个审核者(使用全新Agent,无之前回合的记忆)
review_b = Agent(prompt=REVIEWER_PROMPT.format(output=output, ...))
review_c = Agent(prompt=REVIEWER_PROMPT.format(output=output, ...))
// 迭代次数用尽 → 升级至人工审核
log_santa_result(output, MAX_ITERATIONS, "escalated")
escalate_to_human(output, issues)
Critical: each review round uses **fresh agents**. Reviewers must not carry memory from previous rounds, as prior context creates anchoring bias.undefinedundefined
```python
```pythonundefinedundefinedimport random
def santa_batch(items, rubric, sample_rate=0.15):
sample = random.sample(items, max(5, int(len(items) * sample_rate)))
for item in sample:
result = santa_full(item, rubric)
if result.verdict == "NAUGHTY":
pattern = classify_failure(result.issues)
items = batch_fix(items, pattern) // 修复所有符合该问题模式的内容
return santa_batch(items, rubric) // 重新抽样
return items // 抽样内容全部通过 → 发布批量内容import random
def santa_batch(items, rubric, sample_rate=0.15):
sample = random.sample(items, max(5, int(len(items) * sample_rate)))
for item in sample:
result = santa_full(item, rubric)
if result.verdict == "NAUGHTY":
pattern = classify_failure(result.issues)
items = batch_fix(items, pattern) # Fix all items matching pattern
return santa_batch(items, rubric) # Re-sample
return items # Clean sample → ship batch| 失效模式 | 症状 | 缓解措施 |
|---|---|---|
| 无限循环 | 修复后审核者持续发现新问题 | 设置最大迭代次数(3次),升级至人工审核 |
| 橡皮图章式审核 | 两个审核者通过所有内容 | 使用对抗式提示:"你的职责是发现问题,而非通过审核。" |
| 主观偏差 | 审核者标记风格偏好而非错误 | 仅使用带有客观通过/不通过条件的严格审核标准 |
| 修复回归 | 修复问题A时引入问题B | 每轮审核使用全新Agent以发现回归问题 |
| 审核者共识偏差 | 两个审核者均遗漏同一问题 | 通过独立性缓解,但无法完全消除。对于关键内容,添加第三个审核者或人工抽样检查。 |
| 成本激增 | 大型输出内容的迭代次数过多 | 使用批量抽样模式。为每个验证周期设置预算上限。 |
| Failure Mode | Symptom | Mitigation |
|---|---|---|
| Infinite loop | Reviewers keep finding new issues after fixes | Max iteration cap (3). Escalate. |
| Rubber stamping | Both reviewers pass everything | Adversarial prompt: "Your job is to find problems, not approve." |
| Subjective drift | Reviewers flag style preferences, not errors | Tight rubric with objective pass/fail criteria only |
| Fix regression | Fixing issue A introduces issue B | Fresh reviewers each round catch regressions |
| Reviewer agreement bias | Both reviewers miss the same thing | Mitigated by independence, not eliminated. For critical output, add a third reviewer or human spot-check. |
| Cost explosion | Too many iterations on large outputs | Batch sampling pattern. Budget caps per verification cycle. |
| 机制 | 关系 |
|---|---|
| 验证循环 | 用于确定性检查(构建、代码检查、测试)。Santa Method用于语义检查(准确性、幻觉)。先运行验证循环,再运行Santa Method。 |
| 评估框架 | Santa Method结果可作为评估指标。跟踪Santa运行中的pass@k指标以衡量生成Agent的长期质量。 |
| 持续学习v2 | Santa发现的问题将成为生成Agent的经验。同一准则下的重复失败将转化为避免该模式的习得行为。 |
| 策略压缩 | 在压缩前运行Santa Method。验证过程中请勿丢失审核上下文。 |
| Skill | Relationship |
|---|---|
| Verification Loop | Use for deterministic checks (build, lint, test). Santa for semantic checks (accuracy, hallucinations). Run verification-loop first, Santa second. |
| Eval Harness | Santa Method results feed eval metrics. Track pass@k across Santa runs to measure generator quality over time. |
| Continuous Learning v2 | Santa findings become instincts. Repeated failures on the same criterion → learned behavior to avoid the pattern. |
| Strategic Compact | Run Santa BEFORE compacting. Don't lose review context mid-verification. |
Santa成本 = (生成内容token成本) + 2×(每轮审核token成本) ×(平均轮次)
不使用Santa的成本 = (声誉损失) + (修正工作量) + (信任流失)Cost of Santa = (generation tokens) + 2×(review tokens per round) × (avg rounds)
Cost of NOT Santa = (reputation damage) + (correction effort) + (trust erosion)