Skip to content
Agent Field Notes
Practice topicsFilter practice questions by topic.All practice →
knowledge unit 52IntermediateSystem designAbout 15 minutes

Understand → Implement → Debug → Design

Stage-local evidence loss determines the repair

Hold query, scope and effective time fixed; compare candidates, selected material and exact serialized context.

RAGRetrievalRerankingReview

Knowledge content check2026-10-11 · Check the source of the original question2026-10-11

Which step do you want to learn from this knowledge point?

Select the starting point based on the current basis, or you can go deeper one by one. When you encounter an unfamiliar concept, go back to the core principles first; use the knowledge exercises to check your understanding when you are finished.

Understand first

New to this knowledge point

Complete the prerequisite concepts, read the principles and counterexamples, and then explain why in your own words.

Start with core principles →

Implement next

Prepare to write the principles into code

Understand implementation steps and boundaries, complete small tasks, and check results against acceptance requirements.

View the code example →

Debug failures

Need to handle failures and changes in conditions

Follow the continuous questioning to locate the failure premise, and then compare the migration cases to explain how the plan should be adjusted.

Continue to delve deeper into the problem →

Compare designs

Need to design or review plans

Combine engineering deductions and senior self-evaluation standards to explain the applicable conditions, costs and alternatives of the plan.

Analyze engineering scenarios →
Knowledge unit directory

LEARN · PRACTICE · REFLECT

Knowledge learning and personal records

My notes and review ↗

First read along the principles, Q&A and migration cases. When you need to check your understanding, switch to reinforcement exercises or start personal recording.

Answers and personal notes

Each modified commit will be kept as an independent history. Your level of mastery is up to you to evaluate yourself against the standards.

Core concept · Stage-local evidence loss determines the repair

Understand the core principles first

Preparatory concepts:Chunk provenance and valid time, Candidate rankings and context budgets, Claim-to-source support

Inspect the first missing required condition in the evidence flow before changing an earlier or unrelated mechanism.

Visual guide · Find the first stage that loses required evidence

Find the first stage that loses required evidence

Trace the required clause by ID through every stage. If complete evidence reaches context, investigate generation instead of only raising top-k. Select the figure to open it at full size.

A candidate list can contain the right material while the actual model context does not. Each pipeline stage therefore needs observable IDs and enough protected provenance to reproduce applicability and assembly. Once full evidence is in context, a wrong claim has a different cause and needs generation/support review.

The complete base-plus-exception bundle reverses the opened-battery conclusion. This causal counterexample makes the stage boundary visible and avoids equating a citation link with support. See the RAG evidence course and the existing RAG pipeline.

Evidence trace: applicability through actual context to supported claims
  1. 1
    Corpus

    Attach tenant, group, version and valid interval to base and exception clauses.

  2. 2
    Trusted query context

    Filter applicable authorized IDs before rank fusion.

  3. 3
    Ranking

    Fuse two authored rank lists; retain stage IDs.

  4. 4
    Assembly

    Expand authorized same-version clauses and preserve the complete bundle or abstain.

  5. 5
    Verifier

    Check context membership and bounded claim conditions; arbitrary prose remains not_scored.

This deep-dive uses authored rankings. The linked existing RAG pipeline retains its separately recorded real local embedding provenance.

Check understanding with a question

How do you locate the first lost evidence stage in a wrong RAG answer?

Compare with the reference answer

Trace evidence IDs from applicable authorized corpus through candidate rankings, selection, expansion and actual context to each claim. Diagnose the first stage that loses the required clause. If complete applicable evidence reaches the model but the claim contradicts it, investigate generation/support checking. Increasing top-k cannot repair every later loss.

Implementation and trade-offs

The authored opened-battery question requires the current base and battery exception. At time150, authorized IDs are returns-v2-base and returns-v2-exception. In the broken assembly both are in fused_ids, but include_exception=False leaves only the base in assembled_ids. The wrong eligible=True candidate receives missing_required_evidence.

Walk from corpus existence/applicability to candidates, rankings, selection, expansion and exact context. The earliest absence here is assembly after seed selection. Repair same-policy/same-version authorized expansion and preserve the complete 163-character bundle. At budget300 the complete context supports eligible=False; at budget100 the lab abstains. With both citations but eligible=True, the verifier returns claim_contradicted, a different failure.

The ranking lists are authored fixtures. The code applies RRF to positions and records each stage; it does not infer real embedding quality. The existing RAG pipeline course retains actual local embedding provenance. Do not add lexical and vector raw scores without a justified calibration; RRF also does not produce an answer-correctness probability.

For an actual model integration, record exact authorized serialized context, prompt/model/index versions and the claim/source mapping. Keep labels and required evidence in the evaluator. Trace logs themselves are protected data and must not leak forbidden documents.

code example

Reproducible local boundary check

Python 3.9+, standard library. Extract /lab/deep-dive/agent-core-deep-dive-v1.zip and run this snippet beside rag_evidence_deep_dive.py; /lab/deep-dive/rag_evidence_deep_dive.py is also available. Authored fixtures only; not a live model or external service.

from rag_evidence_deep_dive import assemble, candidate, verify_claims
bad = assemble(include_exception=False)
assert 'returns-v2-exception' in bad['fused_ids']
assert verify_claims(candidate(True,['returns-v2-base']),bad)['reason'] == 'missing_required_evidence'
fixed = assemble()
assert verify_claims(candidate(),fixed)['accepted']
print(fixed['required_chars'],verify_claims(candidate(True),fixed)['reason'])

expected output

163 claim_contradicted

Engineering deduction

scene
Authored opened, non-defective battery at age20; base and exception both enter candidate rankings.
design decisions
Compare stage IDs, repair authorized same-version exception expansion and validate the final typed claim.
Verify target
Broken context returns missing_required_evidence; repaired full context accepts eligible=False and rejects eligible=True as contradicted.
applicable boundary
Authored rankings/facts/claims and a narrow rule verifier; no model generation, embedding inference or prose entailment measurement.

Continuous questions and answers

Continue reading along with the premises and constraints of the problem. Understand the reference answers first, then try to put away the answers and explain the cause and effect and trade-offs in your own words.

Draw inferences from one example: If the conditions change, how to deduce it?

First find out the conditions for change, and then determine which premises in the original plan still hold true. The following cases are teaching deductions to facilitate the transfer of principles to new problems.

A decision needs several clauses

Changing conditions:A single-clause query becomes a multi-document eligibility decision.

Extended question:What changes in retrieval and acceptance?

Derivation and reference solutions

Annotate a required evidence set and relationships, retain version/applicability coherence and inspect the assembled bundle. Top1 hit rate no longer captures sufficiency. Partial support can answer supported subclaims but must not approve an action whose material condition is missing.

The principles that remain unchanged:The delivered claim must preserve every necessary authorized condition.

A shrinking authorization set

Changing conditions:The same query has fewer allowed documents after permission change.

Extended question:Should the system widen globally to recover its previous recall?

Derivation and reference solutions

No. Restrict candidates and expansion to the current scope, invalidate affected caches and report missing support. The coverage denominator and authorization generation changed; comparison must record that context rather than leaking documents to recover a score.

The principles that remain unchanged:Recall improvement cannot override access policy or evidence applicability.

Easy to make mistakes

  • Calling every wrong answer a retrieval problem before inspecting actual context.
  • Increasing top-k while serialization or compression still removes the exception.
  • Expanding a parent without repeating tenant/version checks.
  • Treating the fixture rank order as measured embedding recall.

References

Official mechanisms were checked on 2026-10-11. Examples and schedules are authored; local Python/SQLite outputs are actually executed. No enterprise incident, live model accuracy or production reliability is asserted. New Q&A and migration cases are added for principle explanation, and source verification and case operation verification are recorded separately.

Check how far you understand

After reading, you can explain the principles, boundaries, and trade-offs against these standards. It is up to you to evaluate your mastery; if further verification is needed, complete the small tasks below.

Basic standards met
Names corpus/retrieval/ranking/context/generation stages and fixes scope/version for diagnosis.
Intermediate and advanced signals
Uses actual stage IDs to identify assembly loss and shows repaired-context plus wrong-claim reruns.
Senior criteria
Accounts for ACL/time/parent expansion, context budgets, label leakage and open-prose verifier limits under changed constraints.

View verification records for independent examples

Hands-on verificationComplete on demand · Suggestions35 minutes

Run rag_evidence_deep_dive.py and RagTests. Save the missing-exception, budget100 and cited-wrong-claim traces. Build a first-loss diagnosis and rerun the repaired assembly.

Expand acceptance requirements and checkpoints
  • The exception exists in eligible/fused IDs before the broken assembly drops it.
  • Repair retains both v2 IDs and accepts eligible=False.
  • Eligibility=True remains rejected even with both correct citations.
  • Budget and permission failures produce no unauthorized or partial evidence fallback.

Key inspections

  • Fixes query, tenant/group, effective time and corpus/index version.
  • Retains stage IDs and actual context rather than only top-k scores.
  • Separates missing exception in assembly from cited-but-contradicted generation.
  • Preserves authorization/version checks in expansion and abstains on insufficient context.