Deep-Research Agents › Citation integrity in practice

Michael BrenndoerferDecember 1, 20263 min read
Language AI HandbookAll chapters
Part 49 of 67Long-Horizon Agents and Interoperability
Chapter 375Deep-Research Agents › Citation integrity in practice
Reading section 13 of 17 · Citation integrity in practice · 3 minSection 13 of 17 · 3 min

Section 13 of 17 · 3 min read

Reading settings

Definitions

Choose how many terms have tooltips.

Article links

Make inline references clickable

Notes & comments

We close the implementation by rendering the final answer with citations. In this fixture, the manual review records which quotation from which document supports each claim and retains the digest of that reviewed body. A quote approved for one document cannot transfer to another document. An edit to the approved body requires a new review, even when the quoted sentence survives. The renderer cites the approved snapshot and offsets and gives a reason for claims it withholds.

PythonIn [35]
CollapseExpand
def render_citation(claim: Claim) -> str:
    seen = set()
    markers = []
    for sp in claim.evidence:
        key = (sp.doc_id, sp.start, sp.end)
        if key in seen:
            continue
        seen.add(key)
        markers.append(f"[{CORPUS_VERSION}/{sp.doc_id}:{sp.start}-{sp.end}]")
    return " ".join(markers)


def render_answer(claims: list, uncertainties: pd.DataFrame) -> str:
    u_index = {row["claim_id"]: row for _, row in uncertainties.iterrows()}
    supported_lines = []
    hedged_lines = []
    abstained_lines = []
    for c in claims:
        if not c.evidence:
            abstained_lines.append(
                f"- {c.text} (no approved evidence available)"
            )
            continue
        if not check_existence(c)[0]:
            abstained_lines.append(
                f"- {c.text} (stored quote failed validation)"
            )
            continue
        u_row = u_index.get(c.claim_id)
        label = u_row["label"] if u_row is not None else "abstain"
        line = f"{c.text} {render_citation(c)}"
        if label == "assert":
            supported_lines.append(line)
        elif label == "hedge":
            hedged_lines.append(line)
        else:
            abstained_lines.append(f"- {c.text} (withheld for review)")
    out = []
    if supported_lines:
        out.append(
            "Supported claims:\n" + "\n".join(f"- {l}" for l in supported_lines)
        )
    if hedged_lines:
        out.append(
            "Hedged claims (weak evidence):\n"
            + "\n".join(f"- {l}" for l in hedged_lines)
        )
    if abstained_lines:
        out.append("Abstained on:\n" + "\n".join(abstained_lines))
    return "\n\n".join(out)


AUDITOR_NOTICE_QUOTE = (
    "The rules clarify that bias audits must be performed by an independent "
    "auditor and that audit results must be published."
)
AUDITOR_REPRINT_QUOTE = (
    "Bias audits must be performed by an independent auditor."
)
NOTICE_PERIOD_QUOTE = (
    "Employers must publish audit results and notify candidates residing in "
    "Cedar City at least ten business days before use."
)
APPROVED_FIXTURE_EVIDENCE = {
    claims_to_check[0]: {
        ("rule14-notice", AUDITOR_NOTICE_QUOTE),
        ("news-a", AUDITOR_REPRINT_QUOTE),
        ("blog-b", AUDITOR_REPRINT_QUOTE),
    },
    claims_to_check[1]: {
        ("rule14-text", NOTICE_PERIOD_QUOTE),
        ("rule14-notice", AUDITOR_NOTICE_QUOTE),
        (
            "news-a",
            "According to the Cedar City Audit Office, employers must publish audit results.",
        ),
        (
            "blog-b",
            "Reports from City Policy News confirm that audit results must be published.",
        ),
        (
            "filing-d",
            "The tribunal's opinion reasoned that publication of audit summaries "
            "is a core duty of the law and rejected arguments that the auditor "
            "independence provision is guidance rather than rule.",
        ),
    },
    claims_to_check[2]: {("rule14-text", NOTICE_PERIOD_QUOTE)},
}

# These are the body digests recorded when the fictional quotes were approved.
REVIEWED_BODY_DIGESTS = {
    "rule14-text": "b3fc80bd293b8fd24b1a6e90da5fe66d821cfc10ec5154cea4178a4f9108ee05",
    "rule14-notice": "5328d4ba106572665e7c1af5ff9eadaad54df3638481cbb9f3164532d40c22f3",
    "news-a": "1492459026abf3bbe8a77b3cd42d6f4aeb409f06f9169467e27e9e7c49c3127d",
    "blog-b": "971ca3be56c2345bc959c3249d5d9bd07ff08f3be351ece3218c32d824cab7eb",
    "filing-d": "66c3a50de411ae08c9a5de2c06a0ba8864d78fabbe7fe3ac1ff2e180042fd7ce",
}


def verified_fixture_claims(claims: list) -> list:
    verified = []
    for claim in claims:
        approved = APPROVED_FIXTURE_EVIDENCE.get(claim.text, set())
        evidence = [
            span
            for span in claim.evidence
            if (span.doc_id, span.span) in approved
            and span.source_sha256 == REVIEWED_BODY_DIGESTS.get(span.doc_id)
            and span_exists(span)
        ]
        count, _ = independent_count(evidence)
        verified.append(
            Claim(claim.claim_id, claim.text, evidence, bool(evidence), count)
        )
    return verified


verified_ledger = verified_fixture_claims(ledger)
verified_uncertainties = pd.DataFrame(
    [
        claim_uncertainty(
            claim, bool(detect_conflicts(claim.text, claim.evidence))
        )
        for claim in verified_ledger
    ]
)
final_answer = render_answer(verified_ledger, verified_uncertainties)
ConsoleOut [36]
CollapseExpand
Hedged claims (weak evidence):
- audits must be performed by an independent auditor [cedar_city_synthetic_v2/news-a:132-188] [cedar_city_synthetic_v2/rule14-notice:78-198] [cedar_city_synthetic_v2/blog-b:135-191]
- audit results must be published [cedar_city_synthetic_v2/rule14-notice:78-198]

Abstained on:
- candidates residing in Cedar City must be notified at least ten business days before use (no approved evidence available)
- civil penalties apply to all AI hiring tools (no approved evidence available)
- EU framework requires an equivalent audit obligation (no approved evidence available)

Each printed citation names the corpus version, document ID, and one half-open character range. In this closed fixture, the approved quote map filters candidate spans before the report recalculates uncertainty. In C2, the academic review praises the availability of summaries. The map excludes it from the final answer because it gives no rule requiring publication.

Comments

Add to the conversation

A question, a correction, or an example from your own work.

No comments yet. Be the first to share your thoughts!

Newsletter

Stay up to date

Get new articles, book updates, and notes on AI and technology.

Unsubscribe at any time. Privacy policy