This prompt is designed for a single, high-stakes job: comparing a fact retrieved from a static knowledge base against a fresh result from a live data source to detect discrepancies. The ideal user is an AI engineer or backend developer building a Retrieval-Augmented Generation (RAG) pipeline for a copilot or agent where information changes faster than the indexing cycle. You need this when your system caches or indexes facts from a primary source (like a database, API, or document store) and must later verify if that fact is still true at query time. The core value is preventing confident, wrong answers that erode user trust—a common failure mode when a knowledge base drifts from reality.
Prompt
Retrieved Fact vs Live Fact Comparison Prompt

When to Use This Prompt
Define the job, reader, and constraints for the Retrieved Fact vs Live Fact Comparison Prompt.
Use this prompt when you have both a previously retrieved fact and a fresh, live query result available in the same turn. The prompt requires two explicit inputs: [RETRIEVED_FACT] (the claim, its source, and retrieval timestamp) and [LIVE_FACT] (the fresh query result, its source, and query timestamp). It is not a general fact-checker, a hallucination detector, or a retrieval query generator. Do not use it when you lack a live source to query, when the fact is subjective, or when the cost of a live query outweighs the risk of staleness. For high-risk domains like healthcare, finance, or legal, the output must be treated as a signal for human review, not an automated override.
The prompt outputs a structured comparison with a match status, the conflicting values, and a resolution recommendation. This output is designed to be machine-readable so your application can route it: a 'match' can skip refresh logic, a 'conflict' can trigger a context update or user warning, and an 'uncertain' result can escalate for human review. Before deploying, you must evaluate this prompt on a golden dataset of known-changed facts to measure detection recall and on known-stable facts to measure false-positive rate. The next section provides the copy-ready template and explains how to adapt the placeholders for your specific data contracts.
Use Case Fit
Where the Retrieved Fact vs Live Fact Comparison Prompt delivers value and where it introduces risk.
Good Fit: Time-Sensitive RAG Pipelines
Use when: your RAG system retrieves facts that can expire (pricing, stock, status, schedules). The prompt compares a cached retrieval against a live API call to detect drift before the model answers. Guardrail: Only trigger comparison when the retrieved fact has a known time-to-live or the user's question implies recency requirements.
Bad Fit: Stable Reference Knowledge
Avoid when: the knowledge base contains encyclopedic, historical, or slowly-changing reference material. Running live comparisons on stable facts wastes API calls and adds latency without improving accuracy. Guardrail: Maintain a domain volatility registry that classifies fact types by expected change frequency and skip comparison for low-volatility categories.
Required Input: Retrieval Provenance Metadata
What to watch: the prompt needs the original retrieval timestamp, source identifier, and the exact retrieved value to compare against live data. Missing provenance makes comparison unreliable. Guardrail: Instrument your RAG pipeline to attach retrieval metadata to every fact passed into the comparison prompt, and validate metadata completeness before invoking comparison.
Operational Risk: Live Source Unavailability
What to watch: the live data source may be down, rate-limited, or returning degraded responses. The prompt must handle comparison failures without blocking the user's answer. Guardrail: Design a fallback path that surfaces the retrieved fact with a staleness caveat when live comparison fails, rather than refusing to answer or retrying indefinitely.
Operational Risk: False-Positive Discrepancy Flags
What to watch: formatting differences, unit conversions, or equivalent representations can trigger discrepancy flags when the underlying fact is unchanged. This erodes operator trust in the detection system. Guardrail: Include normalization rules in the prompt (e.g., date formats, currency codes, unit standardization) and test against known-equivalent value pairs to measure false-positive rate.
Operational Risk: Comparison Latency Budget
What to watch: live API calls add latency to the response path. If comparison takes too long, the user experience degrades even when detection works correctly. Guardrail: Set a comparison timeout and a latency budget per query. If the live call exceeds the budget, fall back to the retrieved fact with a recency caveat and log the timeout for monitoring.
Copy-Ready Prompt Template
A reusable prompt template for comparing a previously retrieved fact against a fresh live query result to detect discrepancies.
This prompt template is the core of the Retrieved Fact vs Live Fact Comparison workflow. It is designed to be dropped into a RAG pipeline where a static knowledge base fact and a fresh live data source result are available. The prompt forces a structured comparison, outputting a match status, the conflicting values, and a resolution recommendation. Use this template when you have a specific fact from a prior retrieval that you suspect may be stale and a corresponding live query result to check it against.
codeYou are a fact verification specialist. Your task is to compare a previously retrieved fact against a fresh result from a live data source. Determine if they match, conflict, or if the comparison is indeterminate. [RETRIEVED_FACT]: The fact retrieved from the static knowledge base. [LIVE_FACT]: The corresponding result from a live query. [FACT_CONTEXT]: A brief description of what this fact represents (e.g., 'customer subscription status', 'current software version'). [COMPARISON_RULES]: Specific rules for comparison, such as 'numeric values must match exactly' or 'dates within 24 hours are considered a match'. Analyze the two facts and output a JSON object with the following schema: { "match_status": "match" | "conflict" | "indeterminate", "retrieved_value": "The value from [RETRIEVED_FACT]", "live_value": "The value from [LIVE_FACT]", "conflict_detail": "A concise explanation of the discrepancy, if any. Null if status is 'match'.", "resolution_recommendation": "use_live" | "use_retrieved" | "flag_for_review" | "re_query", "resolution_reasoning": "A brief justification for the recommendation.", "confidence": 0.0-1.0 } [OUTPUT_SCHEMA]: You must output only the JSON object. Do not include any other text. [CONSTRAINTS]: If the live fact is unavailable or an error was returned, set match_status to 'indeterminate' and recommend 're_query'. If the facts are semantically identical but formatted differently, they are a 'match'.
To adapt this template, replace the square-bracket placeholders with your application's specific data and logic. The [COMPARISON_RULES] placeholder is critical for tuning precision; for example, you might define that a version string like 'v2.1.0' and '2.1' are a match. The [FACT_CONTEXT] helps the model disambiguate values. After generating the output, always validate the JSON structure and the match_status enum before allowing the result to influence downstream logic. For high-risk decisions, such as financial or healthcare data, the flag_for_review recommendation must trigger a human-in-the-loop step, not an automated overwrite.
Prompt Variables
Required inputs for the Retrieved Fact vs Live Fact Comparison Prompt. Each placeholder must be populated before the prompt is assembled and sent. Validation notes describe how to check that the input is well-formed and safe before execution.
| Placeholder | Purpose | Example | Validation Notes |
|---|---|---|---|
[RETRIEVED_FACT] | The fact previously retrieved from a static knowledge base, including its source citation and retrieval timestamp. | Claim: 'Our SOC 2 Type II report covers 2023.' Source: kb://compliance/soc2-overview.md Retrieved: 2024-11-15T10:00:00Z | Must be a non-empty string. Parse for source pointer and timestamp. Reject if timestamp is missing or source is unverifiable. |
[LIVE_QUERY_RESULT] | The fresh result from querying a live data source, including the raw response, query timestamp, and source identifier. | Query: 'Get latest SOC 2 report year' Result: '2024' Source: live://compliance-api/soc2/current Timestamp: 2025-06-20T14:05:00Z | Must be a non-empty string. Validate that the live query timestamp is more recent than the retrieved fact timestamp. Reject if live source is unavailable and flag for retry. |
[COMPARISON_DIMENSIONS] | A list of specific attributes to compare between the retrieved fact and the live result, such as value, date range, status, or numeric threshold. | ['report_year', 'certification_status', 'expiry_date'] | Must be a non-empty array of strings. Each dimension must map to a field present in both the retrieved fact and live result. Reject if dimensions are ambiguous or cannot be extracted from both inputs. |
[STALENESS_THRESHOLD_DAYS] | The maximum age in days a retrieved fact can have before it is automatically flagged as potentially stale, regardless of content match. | 30 | Must be a positive integer. Default to 30 if not provided. Values over 365 should trigger a warning that the threshold may be too permissive for fast-changing domains. |
[CONFIDENCE_THRESHOLD] | The minimum confidence score required to accept a match or mismatch determination without escalating for human review. | 0.85 | Must be a float between 0.0 and 1.0. Default to 0.85. Values below 0.7 should trigger a warning about high escalation rates. Reject if outside valid range. |
[OUTPUT_SCHEMA] | The expected JSON schema for the comparison output, including match status, conflicting values, resolution recommendation, and confidence. | See output-contract table for full schema definition. | Must be a valid JSON Schema object. Validate that required fields include match_status, conflicts, resolution, and confidence. Reject if schema allows ambiguous match_status values. |
[DOMAIN_CONTEXT] | Optional domain-specific context that affects how discrepancies are interpreted, such as regulatory requirements, data volatility expectations, or business impact of staleness. | Domain: healthcare-compliance. Stale lab results require immediate re-verification. Tolerance for mismatch: zero. | Optional string. If provided, must not exceed 500 tokens. Validate that domain context does not contradict the comparison dimensions or staleness threshold. Null allowed. |
[ESCALATION_POLICY] | Instructions for when the comparison result should be escalated for human review rather than returned automatically. | Escalate if: confidence < 0.85, or conflicts involve regulatory data, or live source is unavailable after 2 retries. | Must be a non-empty string. Validate that escalation conditions are specific and testable. Reject if policy says 'always escalate' or 'never escalate' without conditional logic. |
Implementation Harness Notes
How to wire the Retrieved Fact vs Live Fact Comparison Prompt into a production RAG pipeline with validation, retries, and logging.
The Retrieved Fact vs Live Fact Comparison Prompt is designed to sit at a critical junction in your RAG pipeline: the point where a previously retrieved fact must be reconciled with a fresh live query. This is not a standalone prompt but a verification gate that should be called after a live data fetch returns a result that may conflict with cached or previously retrieved context. The harness must treat this prompt as a structured comparison function—it takes two known inputs (the retrieved fact and the live fact) and produces a structured discrepancy report. Do not use this prompt to perform the live query itself; that belongs to your application's tool-calling or API layer. The prompt's job is comparison, arbitration, and resolution recommendation, not data retrieval.
Wiring the prompt into your application requires a clear contract between your retrieval system and the comparison step. First, extract the specific claim or fact from your RAG context that needs verification—this becomes the [RETRIEVED_FACT] input. Structure it as a single, self-contained assertion with its source citation and retrieval timestamp. Second, execute your live data query through your application's existing tool or API infrastructure and format the result as the [LIVE_FACT] input, including the query timestamp and data source. The prompt's [COMPARISON_CRITERIA] field should specify what constitutes a match versus a discrepancy for your domain—numeric tolerance for financial data, semantic equivalence for text, or exact match for identifiers. Validation layer: Before the prompt output reaches any downstream system, validate that the match_status field is one of your expected enum values (match, discrepancy, uncertain, live_unavailable), that conflicting values are populated when status is discrepancy, and that the resolution_recommendation field contains an actionable next step. Reject and retry any output that fails schema validation.
Model choice and retry strategy matter here because false negatives (flagging a discrepancy where none exists) erode trust and trigger unnecessary re-verification loops, while false positives (missing a real discrepancy) allow stale facts to propagate. Use a model with strong instruction-following and structured output capabilities—GPT-4o, Claude 3.5 Sonnet, or equivalent. Set temperature=0 to maximize deterministic comparison behavior. Implement a retry budget of 2 attempts for schema validation failures, but do not retry on uncertain status outputs—those should be escalated to a human review queue or logged for offline analysis. For high-stakes domains (finance, healthcare, compliance), always route discrepancy and uncertain results through a human approval step before updating the assistant's active context. Log every comparison result with the retrieved fact, live fact, match status, timestamp delta, and resolution recommendation to build an audit trail and to measure detection recall against known-changed facts over time.
Testing and evaluation must be built into the harness before deployment. Maintain a golden dataset of known-changed facts where you control both the stale retrieved version and the correct live version. Measure detection recall: what percentage of known discrepancies does the prompt correctly flag? Measure precision: what percentage of flagged discrepancies are real? Pay special attention to boundary cases—facts that changed within seconds of the comparison, facts where only a subordinate clause changed, and facts where the live source is temporarily unavailable. Your harness should also track latency from live query to comparison output, as this prompt adds a sequential step to your RAG pipeline. If latency exceeds your SLA, consider batching multiple fact comparisons into a single prompt call or implementing a fast-path that skips comparison for facts with retrieval timestamps under a freshness threshold. Finally, expose the match_status and resolution_recommendation fields to your observability stack so you can alert on sudden increases in discrepancy rates, which may indicate a broken live data source rather than actual fact changes.
Expected Output Contract
Defines the shape, types, and validation rules for the output of the Retrieved Fact vs Live Fact Comparison Prompt. Use this contract to build a parser, validator, and retry handler in your application harness.
| Field or Element | Type or Format | Required | Validation Rule |
|---|---|---|---|
match_status | enum: match | mismatch | indeterminate | error | Must be one of the four enum values. Reject any other string. | |
retrieved_fact | object | Must contain the keys 'source', 'value', and 'retrieved_at'. 'source' must be a non-empty string. 'value' can be any valid JSON type. 'retrieved_at' must be an ISO 8601 datetime string. | |
live_fact | object | Must contain the keys 'source', 'value', and 'queried_at'. 'source' must be a non-empty string. 'value' can be any valid JSON type. 'queried_at' must be an ISO 8601 datetime string. | |
discrepancy_detail | string | null | If match_status is 'mismatch', this field is required and must be a non-empty string explaining the difference. If match_status is 'match', this field must be null or absent. For 'indeterminate' or 'error', it is optional but recommended. | |
resolution_recommendation | enum: use_retrieved | use_live | flag_for_review | retry_live_query | Must be one of the four enum values. If match_status is 'error', only 'retry_live_query' or 'flag_for_review' are valid. Reject any other combination. | |
confidence_score | number | Must be a float between 0.0 and 1.0 inclusive. A score below 0.5 should correlate with 'indeterminate' or 'error' statuses. Reject values outside this range. | |
live_query_used | string | The exact query string sent to the live data source. Must be a non-empty string. Used for auditability and debugging. | |
comparison_timestamp | string (ISO 8601) | The UTC timestamp when the comparison was executed. Must parse to a valid datetime. Reject unparseable strings. |
Common Failure Modes
What breaks first when comparing retrieved facts against live data, and how to guard against it.
Schema Mismatch Between Sources
What to watch: The retrieved fact and the live query result use different field names, units, or data types, causing the comparison to fail or produce false mismatches. A price stored as total: 49.99 in the knowledge base may appear as amount_cents: 4999 from the live API. Guardrail: Normalize both values to a canonical schema before comparison. Define explicit mapping rules for unit conversion, field renaming, and type coercion in the prompt's [OUTPUT_SCHEMA].
Temporal False Positives
What to watch: The prompt flags a mismatch because the retrieved fact and the live fact were captured at different timestamps, even though both were correct at their respective times. A stock price from 10:00 AM will always differ from the 10:01 AM price. Guardrail: Include a tolerance_window parameter in the prompt that defines acceptable staleness. Instruct the model to classify differences within the tolerance window as match_status: current rather than conflict.
Live Query Failure Cascades
What to watch: The live data source is unavailable, returns an error, or times out. Without explicit handling, the prompt may hallucinate a live value, incorrectly flag a mismatch, or fail silently. Guardrail: Add a live_query_status field to the input. When the status is not success, instruct the model to output match_status: indeterminate and resolution: retry_live_query rather than fabricating a comparison. Never let the model invent live data.
Semantic Equivalence Misclassified as Conflict
What to watch: The retrieved fact and the live fact express the same information differently. "The meeting is scheduled for 3 PM EST" vs "Start time: 15:00 UTC-5" are semantically identical but textually distinct. A naive comparison flags a false conflict. Guardrail: Instruct the model to perform semantic comparison, not string matching. Provide few-shot examples of semantically equivalent pairs that should be classified as match_status: equivalent. Include a semantic_diff field in the output to capture the nature of any real discrepancy.
Over-Confidence in Partial Matches
What to watch: The live query returns a record that partially matches the retrieved fact but differs on a critical sub-field. The model reports match_status: match because most fields align, missing the one field that matters. A customer record matching on name and email but differing on account_status: active vs account_status: suspended is a critical mismatch. Guardrail: Define critical fields in the prompt's [CONSTRAINTS] section. Instruct the model to treat any discrepancy in a critical field as a hard mismatch regardless of other field alignment. Output a critical_field_conflict flag.
Resolution Hallucination Without Evidence
What to watch: When a mismatch is detected, the model invents a resolution reason without evidence. "The retrieved value is likely outdated due to a system migration" is plausible-sounding but fabricated. Guardrail: Constrain the resolution_recommendation field to a fixed enum: trust_live, trust_retrieved, flag_for_review, retry_with_filters. Require the model to cite the specific conflicting fields as evidence for its recommendation. For any recommendation other than trust_live, require human review before automated action.
Evaluation Rubric
Use this rubric to evaluate the Retrieved Fact vs Live Fact Comparison Prompt before deployment. Each criterion targets a specific failure mode in staleness detection. Run these tests against a golden dataset of known-changed and known-unchanged facts to measure detection recall and precision.
| Criterion | Pass Standard | Failure Signal | Test Method |
|---|---|---|---|
Stale Fact Detection Recall | All known-changed facts in the test set are flagged with match_status 'MISMATCH' or 'STALE' | A known-changed fact returns match_status 'MATCH' or 'UNKNOWN' | Run against a golden dataset of 50+ facts where ground-truth change status is known; measure recall as true positives / (true positives + false negatives) |
Fresh Fact Precision | No known-unchanged facts are incorrectly flagged as stale | A known-unchanged fact returns match_status 'MISMATCH' or 'STALE' | Run against a golden dataset of 50+ facts where ground-truth freshness is confirmed; measure precision as true positives / (true positives + false positives) |
Conflict Value Extraction Accuracy | The conflicting_values field contains the exact retrieved value and the exact live value for every true mismatch | conflicting_values is empty, null, or contains truncated or hallucinated values on a true mismatch | Parse the output JSON for each true-positive mismatch; assert that conflicting_values.retrieved_value and conflicting_values.live_value are non-null and match the source data |
Resolution Recommendation Correctness | resolution_recommendation is 'USE_LIVE' when live data is fresher, 'RETAIN_RETRIEVED' when live query fails, and 'ESCALATE' when conflict cannot be resolved automatically | resolution_recommendation is 'USE_LIVE' when the live source is known to be unavailable or 'RETAIN_RETRIEVED' when live data is confirmed fresher | For each test case, compare the output resolution_recommendation against a pre-labeled expected action; flag any mismatch for review |
Source Grounding Preservation | Output includes the original retrieved source citation and the live query source identifier for every comparison | source_citations field is missing, null, or contains only one of the two required sources | Schema-validate the output; assert that source_citations.retrieved_source and source_citations.live_source are both non-null strings |
Confidence Score Calibration | confidence_score is >= 0.8 for clear matches and <= 0.4 for clear mismatches with unambiguous evidence | confidence_score is >= 0.7 on a false positive or false negative; confidence is uniformly high regardless of evidence quality | Bin outputs by confidence_score ranges; measure Brier score or expected calibration error against ground-truth correctness |
Live Query Failure Handling | When the live query returns an error or empty result, match_status is 'LIVE_UNAVAILABLE' and resolution_recommendation is 'RETAIN_RETRIEVED' or 'ESCALATE' | Live query failure causes match_status 'MISMATCH' with hallucinated live values or causes the prompt to crash without output | Inject simulated live query failures into the test harness; assert that the output schema is still valid and match_status reflects unavailability |
Ambiguous Conflict Escalation | When retrieved and live facts conflict but neither source is clearly authoritative, resolution_recommendation is 'ESCALATE' and escalation_reason is populated | Ambiguous conflicts are resolved with 'USE_LIVE' or 'RETAIN_RETRIEVED' without acknowledging uncertainty | Use test cases where both sources are equally credible but contradictory; assert that escalation_reason is a non-empty string and resolution_recommendation is 'ESCALATE' |
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Adapt This Prompt
How to adapt
Start with the base prompt and a small set of known-changed fact pairs. Strip schema enforcement to a simple JSON block request. Use a single model call with no retry logic.
codeCompare the [RETRIEVED_FACT] from the knowledge base with the [LIVE_FACT] from the live query. Return JSON with match_status, conflicts, and resolution.
Watch for
- Missing schema checks let malformed JSON through
- Overly broad instructions produce narrative instead of structured output
- No confidence calibration on borderline matches

About the author
Prasad Kumkar
CEO & MD, Inference Systems
Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.
His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us