This prompt is built for a specific production diagnosis: a conversational AI system using Retrieval-Augmented Generation (RAG) has produced a multi-turn session that looks correct turn-by-turn but may contain cross-turn factual contradictions. The job-to-be-done is a structured, trace-anchored audit that compares atomic factual claims across every turn, checks each claim against the retrieved context captured in the trace for that specific turn, and identifies three failure modes: contradictions with earlier grounded statements, new claims introduced without support in the current turn's retrieved context, and factual qualifications present in an earlier turn that were dropped in a later turn. The ideal user is an AI reliability engineer, a conversational AI developer, or a quality engineer who has access to a full trace export containing user messages, model responses, and per-turn retrieval payloads. Without per-turn retrieval data, the prompt cannot perform its core function of distinguishing a retrieval gap from a generation error.
Prompt
Factual Drift Detection in Multi-Turn RAG Traces Prompt

When to Use This Prompt
Learn when to deploy the factual drift detection prompt and when to choose a different tool for your multi-turn RAG audit.
Do not use this prompt for single-turn evaluations. A single turn has no cross-turn drift to detect, and a dedicated faithfulness or citation verification prompt will give you a more focused analysis with less token overhead. Do not use it for real-time guardrailing during generation; this prompt is designed for offline trace analysis and expects a complete session payload, not a streaming partial response. Do not use it when the trace does not include per-turn retrieval data—if you only have final answers without the context the model saw at each step, you cannot determine whether a new claim was unsupported by retrieval or was a contradiction of a prior grounded statement. For those cases, use a standalone hallucination detection prompt that operates on a single (context, output) pair. Also avoid this prompt when the session involves heavy tool-call sequences where factual claims are derived from tool outputs rather than retrieved passages; the prompt's grounding logic assumes retrieved context as the evidence source, and tool-call traces require a different audit structure.
Before running this prompt, verify that your trace format includes turn boundaries, user messages, model responses, and the retrieved context payload for each turn. If your tracing system captures these fields under different keys, adapt the [TRACE_JSON] placeholder schema before use. The prompt works best on sessions with three or more turns, where drift patterns become detectable. For sessions with only two turns, the analysis will still run but may produce a sparse drift timeline. After running the prompt, expect a structured drift timeline that references specific turn numbers and trace spans, which you can use to file bug reports, update retrieval pipelines, or adjust system instructions. If the output flags a contradiction, always verify it manually against the trace before treating it as a confirmed defect—the prompt is a diagnostic aid, not a final arbiter.
Use Case Fit
Where this prompt works, where it fails, and what you must provide before running it in production.
Good Fit: Multi-Turn RAG Debugging
Use when: you have a multi-turn RAG trace where the model appears to contradict earlier grounded statements or introduces new facts without citations. This prompt excels at comparing claims across turns and pinpointing the exact turn where drift began.
Bad Fit: Single-Turn Fact Checking
Avoid when: you only need to verify claims against retrieved context in a single response. Use the RAG Citation Verification Trace Prompt instead. This prompt is designed for cross-turn comparison and will produce noisy, low-signal output on isolated turns.
Required Input: Complete Trace with Turn Boundaries
What to watch: the prompt requires a full multi-turn trace with clear turn delimiters, retrieved context per turn, and generated outputs per turn. Guardrail: validate that your trace export includes turn_id, user_input, retrieved_context, and generated_output fields before running. Missing turn boundaries will cause false drift flags.
Required Input: Grounding Annotations or Citation Spans
What to watch: the prompt needs citation spans or grounding annotations in each turn's output to distinguish supported claims from unsupported ones. Guardrail: if your RAG system does not emit inline citations, pre-process traces with a claim extraction step or use the Unsupported Claim Detection from Retrieval Traces Prompt before drift analysis.
Operational Risk: Long Context Window Truncation
What to watch: multi-turn traces can exceed context window limits, causing the prompt to receive truncated turn history. Guardrail: implement a sliding window approach that loads the last N turns plus the target turn, and log a warning when turns are omitted. Pair with the Context Window Truncation and Hallucination Correlation Prompt for truncated-trace diagnosis.
Operational Risk: False Positives from Topic Shifts
What to watch: legitimate topic changes can be flagged as drift when the model introduces new facts appropriate to a new subject. Guardrail: add a pre-check that classifies whether the user's turn represents a topic shift, and suppress drift flags when the conversation domain has clearly changed. Include topic-shift metadata in the drift timeline output.
Copy-Ready Prompt Template
A copy-ready prompt template for detecting factual drift across multi-turn RAG traces, with placeholders for trace data and output schema.
This prompt template is designed to be dropped directly into your trace analysis pipeline. It instructs the model to extract atomic claims from each assistant turn, ground them against the retrieved context for that turn, and then compare claims across turns to identify contradictions, unsupported new facts, and qualifications that were silently dropped. The output is a structured drift timeline that references specific trace events, making it auditable and actionable for debugging conversational RAG systems.
textYou are an expert trace auditor analyzing a multi-turn RAG conversation for factual drift. Your task is to: 1. Extract every atomic factual claim from each assistant response in the trace. 2. For each claim, determine whether it is supported by the retrieved context for that turn. Mark it as GROUNDED, PARTIALLY_GROUNDED, or UNSUPPORTED. 3. Compare claims across all turns to detect: - Contradictions: A later claim that directly conflicts with an earlier grounded claim. - Unsupported new claims: A claim introduced in a later turn that has no support in that turn's retrieved context. - Dropped qualifications: An earlier claim that included a caveat, confidence qualifier, or limitation that was omitted in a later restatement. 4. Produce a drift timeline ordered by turn, with each event referencing the specific trace event IDs. ## INPUT Trace JSON: [TRACE_JSON] ## OUTPUT SCHEMA Return a JSON object with this exact structure: { "trace_id": "string", "total_turns": integer, "drift_events": [ { "event_id": "string", "turn_number": integer, "drift_type": "CONTRADICTION" | "UNSUPPORTED_NEW_CLAIM" | "DROPPED_QUALIFICATION", "earlier_claim": { "turn": integer, "claim_text": "string", "trace_event_ref": "string", "grounding_status": "GROUNDED" | "PARTIALLY_GROUNDED" | "UNSUPPORTED" }, "later_claim": { "turn": integer, "claim_text": "string", "trace_event_ref": "string", "grounding_status": "GROUNDED" | "PARTIALLY_GROUNDED" | "UNSUPPORTED" }, "description": "string explaining the drift", "severity": "CRITICAL" | "MAJOR" | "MINOR" } ], "summary": { "total_drift_events": integer, "by_type": { "CONTRADICTION": integer, "UNSUPPORTED_NEW_CLAIM": integer, "DROPPED_QUALIFICATION": integer }, "overall_assessment": "string" } } ## CONSTRAINTS - Only flag a claim as UNSUPPORTED if the retrieved context for that specific turn does not contain evidence for it. Do not use context from other turns. - A contradiction requires that the earlier claim was GROUNDED or PARTIALLY_GROUNDED. If both claims are unsupported, flag each as UNSUPPORTED_NEW_CLAIM separately rather than as a contradiction. - For DROPPED_QUALIFICATION, the earlier claim must include an explicit qualifier (e.g., "likely", "estimates suggest", "as of Q2") that is absent in the later restatement. - Severity: CRITICAL for safety, legal, or financial claims. MAJOR for factual errors with user impact. MINOR for imprecise but not misleading changes. - If no drift is detected, return an empty drift_events array and an overall_assessment indicating the trace is consistent.
To adapt this template, replace [TRACE_JSON] with your actual trace data. The trace should include, at minimum, the user query, retrieved context, and assistant response for each turn, along with unique event IDs. If your trace format differs, adjust the extraction logic in the prompt's instructions accordingly. For high-stakes domains such as healthcare or finance, always route CRITICAL severity findings to human review before taking action. Pair this prompt with a JSON schema validator in your pipeline to catch malformed outputs before they enter your drift monitoring dashboard.
Prompt Variables
Required inputs for the Factual Drift Detection prompt. Each variable must be populated from the multi-turn RAG trace before execution. Missing or malformed inputs will cause false negatives in drift detection.
| Placeholder | Purpose | Example | Validation Notes |
|---|---|---|---|
[TURN_HISTORY] | Ordered list of user-assistant turn pairs with timestamps and generated outputs | Turn 1 User: 'What is the return policy?' Turn 1 Assistant: 'Returns accepted within 30 days.' Turn 2 User: 'Does that include electronics?' Turn 2 Assistant: 'All items qualify for 30-day returns.' | Must contain at least 2 turns. Each turn requires a user message and assistant response. Empty or single-turn traces should be rejected before prompt execution. |
[RETRIEVED_CONTEXT_PER_TURN] | Retrieved passages or source documents used for each assistant response, keyed by turn index | Turn 1: [doc_1: 'Standard returns: 30 days for most items.'] Turn 2: [doc_2: 'Electronics: 14-day return window.'] | Each turn must have at least one retrieved context entry. Null context for any turn indicates a retrieval gap and must be flagged before drift analysis. Validate that context spans are non-empty strings. |
[FACTUAL_CLAIMS_OUTPUT] | Atomic factual claims extracted from each assistant turn, with turn-level trace references | Turn 1 Claim 1: 'Returns accepted within 30 days' (source: doc_1). Turn 2 Claim 1: 'All items qualify for 30-day returns' (source: doc_2). | Claims must be structured as an array of objects with turn_id, claim_text, and source_document_id fields. Schema validation required. Claims without source grounding should be flagged as unsupported before drift comparison. |
[DRIFT_DETECTION_THRESHOLD] | Confidence threshold for flagging a contradiction as a factual drift event | 0.75 | Must be a float between 0.0 and 1.0. Lower values increase sensitivity but may produce false positives. Recommended default: 0.70. Validate as numeric and in-range before use. |
[SESSION_METADATA] | Session-level identifiers for traceability and reporting | session_id: 'sess_abc123', model_version: 'gpt-4o-2024-08-06', prompt_version: 'v2.3.1' | Must include session_id for trace correlation. model_version and prompt_version are strongly recommended for root-cause analysis. Validate that session_id is a non-empty string. |
[OUTPUT_SCHEMA] | Expected structure for the drift timeline output | JSON schema with fields: drift_events (array), each containing earlier_turn_id, later_turn_id, earlier_claim, later_claim, contradiction_type, confidence_score, trace_references | Must be a valid JSON Schema object. Validate parseability before passing to the prompt. Reject schemas that lack required fields for traceability. |
[CONTRADICTION_TYPE_TAXONOMY] | Enum of contradiction categories the model should use for classification | direct_contradiction, temporal_scope_change, entity_scope_narrowing, entity_scope_widening, unsupported_new_claim, source_conflict_override | Must be a non-empty array of strings. Validate that all values are lowercase with underscores. Unknown types in model output should be flagged for human review rather than silently accepted. |
[MAX_DRIFT_EVENTS] | Upper limit on the number of drift events returned to prevent unbounded output | 20 | Must be a positive integer. Recommended range: 10-50. Validate as integer and enforce truncation in post-processing if model exceeds the limit. |
Implementation Harness Notes
How to wire the Factual Drift Detection prompt into an observability pipeline or manual review workflow.
This prompt is designed to be integrated into a post-hoc trace analysis pipeline, not a real-time chat flow. It expects a fully hydrated multi-turn trace containing user messages, assistant responses, and the retrieved context for each turn. The primary integration point is a batch job or a manual review tool that queries your trace store, assembles the required inputs, and invokes the LLM with this prompt. The output is a structured drift timeline that should be written back to your observability platform as annotations on the original trace, enabling search and alerting on drift_severity and contradiction_type fields.
To wire this into an application, build a thin service that performs the following steps: (1) Query your trace database for sessions exceeding a turn threshold or flagged by user reports. (2) For each session, extract the [CONVERSATION_HISTORY] and [RETRIEVED_CONTEXT_PER_TURN] arrays, ensuring each turn object includes a unique turn_id and timestamp. (3) Populate the prompt template, setting [DRIFT_CATEGORIES] to your organization's taxonomy (e.g., 'direct contradiction', 'unsupported new fact', 'tense or entity shift'). (4) Call a capable model (GPT-4o or Claude 3.5 Sonnet) with response_format set to a JSON schema matching the expected [OUTPUT_SCHEMA]. (5) Validate the response: confirm every drift_event references a valid turn_id from the input, that source_claim and contradicting_claim are non-empty strings, and that severity is within your enum. On validation failure, retry once with the validation error injected into the [CONSTRAINTS] field. Log all validation failures and retries for prompt debugging.
For high-stakes domains such as healthcare or legal applications, do not automate downstream actions based solely on the drift detection output. Instead, route traces with severity: critical to a human review queue. Store the full prompt payload and model response as an audit record. Implement a confidence threshold: if the model's self-reported detection_confidence is below 0.7, suppress automated alerts and flag for manual triage. Avoid wiring this prompt directly into a model response interceptor that blocks or rewrites the assistant's output in real time; the latency and cost profile of multi-turn analysis is better suited for asynchronous monitoring. Start with a daily batch over high-risk sessions before moving to near-real-time streaming.
Expected Output Contract
Defines the schema for the drift timeline output. Each field must be validated before the report is surfaced to a user or stored in an observability database.
| Field or Element | Type or Format | Required | Validation Rule |
|---|---|---|---|
drift_timeline | Array of objects | Must be a non-empty array if drift is detected; empty array only if no drift found. | |
drift_timeline[].turn_id | Integer | Must match a turn index present in the input trace. Must be monotonically non-decreasing in the array. | |
drift_timeline[].drift_type | Enum: CONTRADICTION | NEW_UNSUPPORTED_FACT | ATTRIBUTION_SHIFT | Must be one of the three enum values. CONTRADICTION requires a prior_turn_id reference. | |
drift_timeline[].claim | String | Must be a verbatim or near-verbatim extractable sentence from the generated output at that turn. Null or empty string is invalid. | |
drift_timeline[].prior_turn_id | Integer or null | Required if drift_type is CONTRADICTION. Must reference a valid prior turn_id. Must be null for NEW_UNSUPPORTED_FACT. | |
drift_timeline[].trace_evidence | Object | Must contain a source_trace_span_id (String) and a conflicting_trace_span_id (String or null). Span IDs must be resolvable in the input trace. | |
drift_timeline[].severity | Enum: CRITICAL | MAJOR | MINOR | CRITICAL if it violates a safety or compliance constraint. MAJOR if it introduces a core factual error. MINOR if it is an imprecise rephrasing. | |
drift_summary | Object | Must contain total_turns (Integer), drift_events_count (Integer), and highest_severity (Enum). highest_severity must be the max severity in drift_timeline or NONE. |
Common Failure Modes
Factual drift in multi-turn RAG traces often goes undetected until a user reports a contradiction. These failure modes cover what breaks first and how to build automated checks into your trace review pipeline.
Silent Contradiction Across Turns
What to watch: The model contradicts a fact it stated in an earlier turn without acknowledging the change. This often happens when retrieval results shift between turns and the model over-indexes on the latest context. Guardrail: Implement a turn-over-turn claim diff that extracts atomic facts from each assistant response and flags direct contradictions. Require the model to cite the specific turn when revising a prior statement.
Context Window Amnesia
What to watch: Earlier retrieved evidence falls out of the context window in long conversations, causing the model to fabricate details it previously had grounded support for. The output remains fluent but becomes unmoored from the original sources. Guardrail: Log context window occupancy per turn and trigger a re-retrieval or summarization step when source documents approach truncation. Flag any claim that references a document no longer present in the active context.
Overcorrection to New Retrieval
What to watch: A new retrieval batch introduces a slightly different source that causes the model to abandon a previously correct and well-grounded statement in favor of a less authoritative one. The drift appears as an unnecessary factual update. Guardrail: Before accepting a new fact that contradicts a prior grounded claim, require the model to compare source authority and recency explicitly. Log a drift event when the model switches positions without documenting the trade-off.
Unsupported Fact Accumulation
What to watch: Each turn introduces one or two small unsupported claims that individually pass a lenient faithfulness check. Over multiple turns, these accumulate into a materially inaccurate conversation summary. Guardrail: Maintain a running set of all claims made across the session and re-verify the full set against the cumulative retrieved context at a configurable interval. Escalate sessions where the unsupported claim ratio crosses a threshold.
Drift Timeline Misattribution
What to watch: The drift detection prompt itself misattributes the turn where a fact first appeared, leading engineers to investigate the wrong retrieval step. This happens when the prompt confuses a restatement with the original claim. Guardrail: Include turn-level trace event IDs in every extracted claim and require the detection prompt to reference those IDs when building the drift timeline. Validate that the claimed origin turn actually contains the fact before surfacing it to an engineer.
False Positive Drift from Paraphrasing
What to watch: The drift detector flags semantically equivalent statements as contradictions because surface-level wording differs. This floods the review queue with noise and erodes trust in the detection pipeline. Guardrail: Add a semantic equivalence check before flagging a contradiction. Require the prompt to distinguish between genuine factual conflict and reformulation. Use a high-precision threshold and route ambiguous cases to a human review queue rather than auto-escalating.
Evaluation Rubric
Use this rubric to evaluate the quality of the Factual Drift Detection prompt's output before integrating it into a production monitoring pipeline. Each criterion should be tested with real or simulated multi-turn RAG traces.
| Criterion | Pass Standard | Failure Signal | Test Method |
|---|---|---|---|
Drift Claim Completeness | Every factual contradiction or unsupported new claim across turns is captured in the timeline. | A known contradiction from the test trace is missing from the output. | Compare output claims against a pre-annotated golden trace with injected contradictions. |
Trace Reference Accuracy | Each drift event includes a correct [TURN_ID] and [TRACE_SPAN_ID] pointing to the exact source. | A trace reference points to a turn or span that does not contain the cited claim. | Automated validation: parse output references and check if the cited span text contains the claim. |
False Positive Rate | No non-contradictory clarifications or acceptable elaborations are flagged as drift. | A benign follow-up like 'To clarify my last point...' is marked as a contradiction. | Review output against a test set of normal conversational turns with no factual drift. |
Severity Classification | Each drift event is correctly classified as 'contradiction', 'unsupported_addition', or 'topic_shift' with consistent logic. | An unsupported new fact is misclassified as a contradiction, or vice versa. | Run the prompt on a labeled severity test set and measure classification F1 score. |
Output Schema Validity | The output is valid JSON matching the [OUTPUT_SCHEMA] with all required fields present and correctly typed. | JSON parsing fails, or required fields like 'drift_timeline' or 'overall_drift_score' are missing. | Validate output against the JSON Schema using a programmatic validator in the test harness. |
Overall Drift Score Calibration | The 'overall_drift_score' correlates with the number and severity of drift events in the trace. | A trace with multiple critical contradictions receives a low drift score, or vice versa. | Calculate the Pearson correlation between the output score and a human-labeled severity score across 50 traces. |
Abstention on Insufficient Data | Returns a null or empty drift_timeline with a clear reason when no drift is present or the trace is too short. | The prompt hallucinates a drift event for a single-turn trace or a trace with no factual changes. | Provide a set of clean, single-turn, and consistent multi-turn traces and assert an empty timeline output. |
Multi-Turn Context Tracking | Correctly identifies drift that spans more than two turns, linking a later contradiction back to the originating turn. | A contradiction introduced in turn 4 against turn 1 is only flagged against turn 3. | Use a 5+ turn trace where a fact is established early and contradicted late; verify the 'established_in_turn' field. |
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 single-turn trace. Replace multi-turn logic with a simpler instruction: "Compare the final answer against the retrieved context in [TRACE_JSON]. List any factual claims not supported by the retrieved passages." Use a lightweight JSON output schema with only claim, supported, and closest_evidence fields. Run on 5-10 hand-picked traces before adding turn-level tracking.
Watch for
- The model conflating stylistic differences with factual drift
- Missing turn-level attribution when you later add multi-turn support
- Overly permissive support judgments that treat vague relevance as grounding

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