Claude Architect · 课时

冲突的数据与日期

标注冲突;使用日期解决表面上的矛盾。

第 2 / 4 课13 个步骤

冲突的数据与日期 是 CoddyKit 上的免费 Claude Architect 课时。 这是第 2 节课,共 4 节。 你可以在下方免费阅读本课时的完整内容 — 然后在浏览器中使用内置代码编辑器和全天候 AI 导师进行实践。 这是 Claude Architect 学习路径的一部分,你的进度在网页和 CoddyKit 应用中同步。 Claude Architect 课程共包含 4 节课。

本课时的部分内容尚未翻译,以英文显示。

When Sources Disagree

In a multi-agent research system, two subagents can return facts that flatly contradict each other. One source says a company has 8,000 employees; another says 12,000. The naive move is to silently pick one and report it as truth.

That is an anti-pattern. The architect-grade answer is to annotate the conflict and preserve both claims with their provenance, so a human (or a downstream model) can adjudicate. This lesson teaches how conflicting data is surfaced, and how dates often resolve apparent contradictions that look irreconcilable at first glance.

Provenance Is the Foundation

You cannot annotate a conflict you cannot trace. Provenance means keeping a claim → source mapping for every fact: the URL or document name, the exact quote, and crucially the publication date.

Without this mapping, a contradiction is just noise. With it, you can show the user precisely where each number came from and when it was published — the raw material for resolving disagreement.

claim = {
    "statement": "Headcount is 12,000",
    "source_name": "Q4 2025 Annual Report",
    "url": "https://example.com/ar-2025.pdf",
    "quote": "As of Dec 31, 2025, we employed 12,000 people.",
    "published": "2026-02-15",
}

Annotate, Don't Arbitrate

The core rule: annotate conflicting stats rather than arbitrarily picking one. When sources disagree, the system should NOT collapse them into a single "winner" by coin-flip, recency-bias, or whichever subagent answered last.

Instead, render both claims side by side, each tagged with its source and date, and explicitly flag that they conflict. The model's job is to surface the disagreement with enough context that a human can decide — not to hide it.

Dates Resolve Apparent Contradictions

Here is the key insight of this lesson: many "contradictions" are not contradictions at all — they are two correct snapshots from different points in time.

"Revenue is $4.2B" (FY2023) and "Revenue is $5.1B" (FY2025) do not conflict. They are both true, on their own dates. Once you attach publication and as-of dates to each claim, the apparent contradiction dissolves into a timeline. This is why the publication date is a first-class field in provenance.

Structured Output for Conflict Records

To make conflict annotation reliable, force the model into a JSON Schema via tool_use. This eliminates syntax errors and enforces required fields. A conflict record should carry every claim with its value, source, and date — plus a resolution note.

Set tool_choice: "any" when you must guarantee structured output (the model must call some tool rather than reply with free text).

tools = [{
    "name": "record_conflict",
    "description": "Record two or more conflicting claims with provenance and a date-based resolution.",
    "input_schema": {
        "type": "object",
        "properties": {
            "metric": {"type": "string"},
            "claims": {"type": "array", "items": {"type": "object"}},
            "resolution": {"type": "string"},
        },
        "required": ["metric", "claims"],
    },
}]
# Force structured output
resp = client.messages.create(
    model="claude-sonnet-4-5",
    max_tokens=1024,
    tools=tools,
    tool_choice={"type": "any"},
    messages=messages,
)

Never Require a Possibly-Absent Field

A subtle but exam-critical schema rule: mark a field required only if it is always present. If a source genuinely lacks a publication date, do NOT make published required — a required-but-absent field pushes the model to fabricate one, which silently destroys your date-based resolution.

In the conflict schema above, metric and claims are required; resolution and each claim's published date are optional. Better an honest null than a hallucinated date.

"properties": {
    "value": {"type": "string"},
    "source_name": {"type": "string"},
    "published": {"type": "string", "description": "ISO date if stated; omit if absent"},
},
"required": ["value", "source_name"]  # published intentionally NOT required

Explicit Criteria Beat Vague Instructions

How you instruct the model matters. "Be careful with conflicting data" is vague and inconsistent. An explicit criterion is far stronger:

  • "Flag two values as conflicting only when they describe the same metric for the same entity."
  • "Before flagging, compare their as-of dates; if the dates differ, treat them as a time series, not a contradiction."

Explicit, testable criteria produce repeatable conflict detection. Vague adjectives do not.

Few-Shot the Date Distinction

Conflict-vs-timeline is exactly the kind of ambiguity where 2–4 targeted few-shot examples shine. The model generalizes from them — it doesn't just memorize the specific numbers.

Give one example of a genuine conflict (same date, different values → flag it) and one example of a date-resolved non-conflict (different dates → report as a timeline). The model learns the decision boundary and applies it to unseen metrics.

examples = [
  {"a": "Rev $4.2B (FY2023)", "b": "Rev $5.1B (FY2025)",
   "verdict": "NOT a conflict — different fiscal years; report as timeline"},
  {"a": "Headcount 8,000 (as of 2026-01)", "b": "Headcount 12,000 (as of 2026-01)",
   "verdict": "CONFLICT — same date, same metric; annotate both with sources"},
]

Keep Dates Verbatim in Case Facts

Long research runs get summarized to fit the context window — and progressive summarization makes numbers, percentages, and dates vague. "Published in early 2026" is useless when the whole resolution hinges on Q1 vs Q3.

The fix: pull transactional facts — exact values, sources, and dates — into a separate "case facts" block kept verbatim outside the summary. Summarize the prose; never summarize the dates you need to resolve conflicts.

case_facts = (
    "VERBATIM — DO NOT SUMMARIZE:\n"
    "- Headcount 8,000 | src: 10-K | published 2025-03-01\n"
    "- Headcount 12,000 | src: Press release | published 2026-02-15\n"
)
# Keep separate from the rolling conversation summary

Self-Correction Detects Discrepancies

To catch conflicts mechanically, have the model extract competing values explicitly rather than emitting a single blended figure. In extraction this is the calculated_total vs stated_total pattern; in research it is value-from-source-A vs value-from-source-B.

Once both are surfaced as distinct fields, a Pydantic-style validator can compare them, detect the mismatch, and trigger the conflict-annotation path — no silent averaging.

from pydantic import BaseModel

class MetricClaim(BaseModel):
    source: str
    value: float
    published: str | None = None

def detect_conflict(a: MetricClaim, b: MetricClaim) -> bool:
    if a.published and b.published and a.published != b.published:
        return False  # date resolves it: timeline, not conflict
    return a.value != b.value

Render by Content Type

Once conflicts are annotated and dates reconciled, present the result so a human can adjudicate fast. Match the rendering to the content type:

  • Tables for financials and competing numeric claims — one row per source, columns for value, source, and date.
  • Prose for news and narrative context.
  • Lists for technical findings.

A side-by-side table makes a same-date conflict jump out, and a date-ordered table reveals a timeline instantly — turning raw provenance into an oversight-ready view.

Quick Check: Two Numbers, Two Dates

A research subagent returns: Source X says ARR is $40M (published Mar 2024); Source Y says ARR is $58M (published Feb 2026). Your aggregator must report this to the user. What is the correct architecture-grade behavior?

Recap: Conflicts & Dates

Key takeaways for conflicting data and provenance:

  • Annotate, don't arbitrate — surface conflicting claims with sources; never silently pick one.
  • Dates resolve apparent contradictions — different as-of dates mean a timeline, not a conflict.
  • Provenance is mandatory — keep claim → source mappings with URL, quote, and publication date.
  • Keep dates verbatim in a separate case-facts block; summarization makes dates vague.
  • Don't require absent fields — an optional null date beats a fabricated one.
  • Render by type — tables for numbers so conflicts and timelines are obvious to the human reviewer.
免费开始

用 AI 导师学习 Python — 免费

在浏览器中编写并运行真实代码,获得全天候 AI 导师的即时帮助,并在网页或应用中继续学习。

课程
26
课程
104

常见问题解答

「冲突的数据与日期」课时是免费的吗?

是的 — 「冲突的数据与日期」的完整文本可在网页上免费阅读。要进行交互式练习(内置代码编辑器和全天候 AI 导师)并解锁 Claude Architect 课程的其余内容,请升级到 CoddyKit PRO。 Claude Architect 课程共包含 4 节课。

「冲突的数据与日期」这节课中我会学到什么?

标注冲突;使用日期解决表面上的矛盾。 你通过在浏览器中直接运行的动手代码来练习 Claude Architect,全天候 AI 导师会在你学习这节课的过程中回答你的问题。

学习 Claude Architect 需要有经验吗?

无需任何先前经验。CoddyKit 上的 Claude Architect 课程适合初学者到高级学习者,你可以从这里开始或从头开始,按照自己的节奏学习。 这是第 2 节课,共 4 节。

「冲突的数据与日期」课时需要多长时间?

大多数 CoddyKit 课程大约需要 5–10 分钟。每节课都很精短且互动,所以你能稳步进步,并在网页和应用中从离开的地方继续。

我能在这节 Claude Architect 课中编写并运行代码吗?

能。每节 Claude Architect 课都包含内置代码编辑器,你可以在浏览器中直接编写并运行真实代码,并获得即时 AI 反馈 — 无需本地设置。

此课程中的所有课时

  1. 声明与来源的对应关系
  2. 冲突的数据与日期
  3. 汇总指标会掩盖失败
  4. 分层抽样与校准
← 返回 Claude Architect