Inferensys

Prompt

Correction vs New Topic Detection Prompt Template

A practical prompt playbook for using the Correction vs New Topic Detection Prompt Template in production AI workflows to route user turns that contradict prior context.
Operations team reviewing AI workflow automation on laptop, workflow builder visible, casual office setup.
PROMPT PLAYBOOK

When to Use This Prompt

Defines the routing job, the ideal user, required context, and the boundaries where this prompt should not be deployed.

This prompt is a dialogue router designed for a single, high-stakes classification task: distinguishing a user correction from a new topic. In multi-turn assistant and copilot systems, a user turn that contradicts prior context is ambiguous. It could be a correction to the current task ("No, use the Q3 report, not Q2") or a completely new, unrelated request ("Actually, let's switch gears and draft an email to legal"). Misclassifying a correction as a new topic causes the system to abandon in-progress work and lose user trust. Misclassifying a new topic as a correction pollutes the active task state with irrelevant constraints. This prompt is for AI engineers and dialogue system architects who need a reliable routing decision before downstream state updates, tool calls, or response generation occur.

The ideal user is integrating this prompt into a conversation state manager or dialogue orchestration layer. Required context includes the active task description, the last assistant response, and the current user turn. The prompt produces a structured routing decision with a contradiction analysis, not a conversational reply. It is designed to be called synchronously before any state mutation. Use this prompt when the cost of a routing error is high—for example, in customer support where a correction to an order must update the existing ticket rather than create a duplicate, or in a coding agent where a correction to a file path must revise the current patch rather than start a new task. The prompt includes explicit handling of ambiguous cases where correction and topic shift overlap, such as "Actually, I meant the other project" which could be a correction within the same domain or a full context switch.

Do not use this prompt when the user turn is a simple clarification question ("What do you mean by that?"), a confirmation ("Is that right?"), or a follow-up that extends rather than contradicts prior context. Those turns should be handled by separate clarification or continuation routers. This prompt is also not a replacement for a full intent classifier—it answers one binary question with an ambiguity escape hatch. For low-stakes chat where misrouting has minimal consequence, a simpler keyword-based heuristic may suffice. The prompt assumes the upstream system has already resolved coreference and anaphora; feeding it unresolved pronouns will degrade accuracy. Finally, this prompt is a classifier, not a response generator. Its output should be consumed by application logic that decides whether to update state, roll back claims, or reset context.

PRACTICAL GUARDRAILS

Use Case Fit

Where the Correction vs New Topic Detection prompt works reliably and where it introduces risk. Use these cards to decide if this prompt template fits your production dialogue router.

01

Good Fit: Multi-Turn Assistants with State

Use when: your assistant maintains session state, slot values, or pending actions that a user might correct mid-session. The prompt reliably distinguishes 'fix what you just said' from 'let's talk about something else.' Guardrail: pair with a state rollback prompt so detected corrections trigger downstream repair, not just classification.

02

Bad Fit: Single-Turn Stateless Interactions

Avoid when: each user turn is independent with no shared context or prior assistant output to contradict. The prompt will over-detect corrections where none exist because it relies on contradiction analysis against prior turns. Guardrail: skip this router entirely for stateless systems; route all inputs directly to intent classification instead.

03

Required Input: Prior Assistant Turn Context

Risk: without the assistant's last response and any pending state, the prompt cannot determine whether a contradiction exists. Guardrail: always include the last N assistant turns and active state snapshot in the prompt context. If context budget is tight, include at minimum the most recent assistant claim and any unconfirmed slot values.

04

Operational Risk: Ambiguous Contradiction Cases

Risk: users often phrase corrections as new questions ('Actually, what about X instead?'), creating overlap between correction and topic shift. The prompt may route these to the wrong handler. Guardrail: implement a confidence threshold below which the router escalates to a clarification prompt rather than guessing. Log all low-confidence decisions for review.

05

Operational Risk: Correction Cascades

Risk: a single correction detection can trigger state rollbacks, re-retrieval, and re-execution of dependent steps. If the router misclassifies a topic shift as a correction, it causes unnecessary work and user confusion. Guardrail: add a confirmation gate for high-impact corrections (those affecting confirmed orders, payments, or external system state) before executing rollback.

06

Required Input: User Correction History

Risk: repeated corrections in a session change the baseline. A third correction in five turns may indicate user frustration or a broken workflow, not a routine routing decision. Guardrail: include recent correction count and pattern in the prompt context so the router can detect correction loops and recommend escalation rather than another repair attempt.

PROMPT PLAYBOOK

Copy-Ready Prompt Template

A reusable prompt for classifying whether a user turn that contradicts prior context is a correction or a new topic.

This template is designed to be the core classification step in a dialogue router. It forces the model to analyze the contradiction between the current user turn and the prior conversation context, then output a structured routing decision. The prompt is built for direct integration into an application harness that will parse the JSON output and trigger either a correction-handling workflow or a topic-shift workflow.

text
You are a dialogue router. Your job is to determine whether a user's latest message is a correction to the ongoing task or a completely new, unrelated request.

[CONTEXT]

Current task state: [TASK_STATE]
Last assistant response: [LAST_RESPONSE]

User's latest message: [USER_INPUT]

[CONSTRAINTS]
- A correction points out an error, misunderstanding, or bad assumption in the assistant's last response or the current task state. The user wants to fix the existing work.
- A new topic introduces a different subject, goal, or request that does not aim to repair the current task.
- If the user's message does both (e.g., "No, that's wrong. Anyway, what's the weather?"), classify it as a correction if the primary intent is to fix the current task before moving on. Otherwise, classify it as a new topic.
- Ambiguous cases where the user rejects the assistant's output but gives no clear fix should be classified as a correction with low confidence.

[OUTPUT_SCHEMA]
{
  "classification": "correction" | "new_topic",
  "confidence": 0.0-1.0,
  "rationale": "Brief explanation of the contradiction and why this classification was chosen.",
  "contradicted_element": "The specific claim, value, or assumption being challenged, or null if new_topic."
}

[EXAMPLES]
User: The report says Q3, but our fiscal year starts in July. It should be Q1.
Classification: correction
Rationale: User explicitly corrects a specific claim (Q3) with a replacement (Q1) while staying within the report task.

User: That's not what I asked. Can you just book a flight to London?
Classification: new_topic
Rationale: User rejects the prior response but immediately pivots to an unrelated task (flight booking) with no attempt to repair the report.

User: I think you misunderstood the deadline.
Classification: correction
Rationale: User identifies a misunderstanding but doesn't provide the fix yet. Classified as correction to trigger a clarification workflow.

To adapt this template, replace the placeholders with your application's actual state representation. [TASK_STATE] should be a concise summary of the current goal, key slots, and progress. [LAST_RESPONSE] is the assistant's most recent full turn. If your system uses a different output schema, update [OUTPUT_SCHEMA] accordingly, but keep the classification and confidence fields as the minimum viable contract. The [EXAMPLES] block is critical for ambiguous cases; add 2-3 more examples that mirror your domain's specific failure patterns. For high-stakes domains like healthcare or finance, add a [RISK_LEVEL] placeholder and a rule that low-confidence corrections must escalate for human review.

IMPLEMENTATION TABLE

Prompt Variables

Placeholders required by the Correction vs New Topic Detection prompt. Each variable must be populated before the prompt is sent to the model. Validation notes describe how to check that the input is well-formed and safe before execution.

PlaceholderPurposeExampleValidation Notes

[CURRENT_USER_TURN]

The latest message from the user that must be classified.

Actually, I meant the Q3 report, not Q2.

Check that the string is non-empty and contains the user's raw text. Truncate to the last 2000 characters if the session is long to avoid context pollution.

[PRIOR_ASSISTANT_TURN]

The assistant's immediately preceding response, which the user may be correcting.

Based on the Q2 data, revenue increased by 12%.

Must be the exact text of the last assistant message. If null, the prompt should default to an empty string and the classification must return 'new_topic'.

[SESSION_CONTEXT_SUMMARY]

A compressed summary of the conversation's topic, goals, and key entities before the current turn.

User is analyzing quarterly financial reports for 2024. Current focus is revenue trends.

Validate that the summary is a string of no more than 500 words. If the session is new, use an empty string. Stale summaries cause false 'correction' classifications.

[CONTRADICTION_CLASSES]

A fixed list of valid output labels for the routing decision.

correction, new_topic, ambiguous

Must be a strict enum of exactly these three strings. Do not allow the model to invent new classes. Validate the output against this list.

[AMBIGUITY_THRESHOLD]

A numeric score between 0.0 and 1.0 that sets the boundary for classifying an input as 'ambiguous'.

0.65

Must be a float. If the model's confidence is below this threshold, the output label must be 'ambiguous'. Validate that the value is within the 0.0-1.0 range before injection.

[OUTPUT_SCHEMA]

The exact JSON schema the model must use for its structured response.

{ "label": "correction", "confidence": 0.92, "rationale": "User explicitly contradicts prior quarter." }

Validate that the schema is a valid JSON object with required fields: label (string), confidence (float), and rationale (string). The model's output must be parseable against this schema.

PROMPT PLAYBOOK

Implementation Harness Notes

How to wire the Correction vs New Topic Detection prompt into a production dialogue router.

This prompt is designed to sit inside a dialogue router—a lightweight classification layer that runs before the main assistant or agent logic. Every user turn that contradicts or appears to contradict prior context passes through this prompt. The output is a structured routing decision: correction, new_topic, or ambiguous. The router then branches: corrections flow to a state rollback and repair pipeline; new topics reset or branch the conversation context; ambiguous cases may trigger a lightweight clarification turn or escalate for human review. Do not use this prompt as a standalone classifier without wiring it into a stateful routing harness, because the classification alone does not update dialogue state, roll back incorrect claims, or re-ground the conversation.

Integration pattern: Place this prompt after turn ingestion and coreference resolution but before the main response generation or tool-use step. The input [PRIOR_CONTEXT] should be a structured summary of the last N turns, active slots, and pending actions—not raw transcript. The [CURRENT_USER_TURN] should be the resolved user utterance after coreference and ellipsis expansion. The [OUTPUT_SCHEMA] must enforce a strict JSON contract: {"decision": "correction|new_topic|ambiguous", "contradiction_analysis": "...", "confidence": 0.0-1.0, "affected_context_keys": [...]}. Validate this schema before routing. If the model returns invalid JSON or a decision outside the enum, retry once with a stricter format instruction. If it fails again, default to ambiguous and log the failure for review. For high-stakes domains (healthcare, legal, finance), route all ambiguous decisions to a human review queue with the contradiction analysis attached.

Model choice and latency budget: This is a classification task with moderate reasoning depth. A fast model (e.g., GPT-4o-mini, Claude Haiku, or a fine-tuned small classifier) is usually sufficient. Target sub-500ms latency. If you are already running a larger model for response generation, consider batching this classification as a separate lightweight call to avoid blocking the main generation path. Cache the classification result in the dialogue state so downstream repair or topic-switch handlers can reference it without re-running the prompt. Eval and monitoring: Build a golden test set of 50–100 turns covering explicit corrections, implicit corrections, topic shifts, and ambiguous overlaps. Measure precision and recall per class. Monitor production drift by sampling classified turns weekly and comparing against human labels. Set an alert if the ambiguous rate spikes above 20%, as this often indicates prompt degradation, context pollution, or a model version change that altered classification behavior.

Failure modes to instrument: The most common production failure is false correction classification—treating a genuine topic shift as a correction, which causes the router to incorrectly roll back state and frustrate the user. The second is false new-topic classification—missing a correction and letting the assistant continue with incorrect assumptions. Log both error types with the full context payload. If you observe correction cascades (multiple corrections in rapid succession), the router may be failing to detect that the user is correcting the correction response, not the original claim. In these cases, inject a correction_loop_count into the dialogue state and escalate after three consecutive corrections in the same topic cluster.

IMPLEMENTATION TABLE

Expected Output Contract

Fields, format, and validation rules for the Correction vs New Topic Detection prompt output. Use this contract to parse and validate the model response before routing.

Field or ElementType or FormatRequiredValidation Rule

decision

enum: correction | new_topic | ambiguous

Must be exactly one of the three allowed values. Reject any other string.

confidence

number (0.0-1.0)

Must be a float between 0 and 1 inclusive. If confidence < 0.5, decision must be ambiguous.

contradiction_summary

string

Must be non-empty when decision is correction or ambiguous. Must reference specific prior context. Max 500 chars.

prior_context_reference

string

Must quote or paraphrase the specific prior assistant claim or state being contradicted. Null allowed only if decision is new_topic.

user_intent_shift_indicator

string

If decision is new_topic, must describe the topic shift. If decision is correction, must be null or empty.

requires_clarification

boolean

Must be true if decision is ambiguous and confidence < 0.7. Must be false if decision is correction or new_topic with confidence >= 0.8.

affected_state_keys

array of strings

If decision is correction, list state keys that may need rollback. Empty array allowed. Null not allowed when decision is correction.

PRACTICAL GUARDRAILS

Common Failure Modes

What breaks first when distinguishing corrections from topic shifts, and how to guard against it.

01

False Positive: Topic Shift as Correction

Risk: The model classifies a legitimate topic change as a correction because the new topic contradicts a prior statement (e.g., 'Actually, let's talk about pricing' after discussing features). This causes the router to incorrectly update or roll back state for the previous topic. Guardrail: Include explicit few-shot examples where contradiction signals a topic shift, not a correction. Add a secondary check: if the new input introduces a new domain or intent label, it is likely a topic shift.

02

False Negative: Correction as New Topic

Risk: The model treats a direct correction ('No, the Q3 report was $2M, not $3M') as a new, unrelated request. This causes the system to fork state incorrectly, leaving the original error unaddressed and creating a parallel, conflicting context. Guardrail: Implement a contradiction analysis step that explicitly checks if the new input directly references or negates a recent assistant claim. Use a high-recall trigger for any user turn containing negation terms or contradictory numbers.

03

Ambiguous Overlap: Correction and Topic Shift Combined

Risk: A user says, 'That's wrong, and also I need the budget for next year.' The model must split the turn into a correction on the current topic and a new request. A single classification fails, leading to either a dropped correction or a missed new task. Guardrail: Decompose the user turn into multiple intents before routing. Classify each segment independently. If a turn contains both a correction marker and a new intent keyword, treat it as a multi-action request requiring both state repair and new task initiation.

04

Implicit Correction Miss

Risk: The user corrects the assistant indirectly ('Is $3M really the right number? I thought it was lower.') without explicit negation. The model classifies this as a clarifying question, failing to trigger state repair. Guardrail: Train the prompt to detect hedging, questioning of facts, and polite contradiction as potential corrections. Add a confidence scoring mechanism: if confidence in the original claim drops below a threshold due to user questioning, flag for re-verification even without explicit correction language.

05

Context Window Truncation

Risk: The assistant's original claim that the user is correcting has scrolled out of the context window. The model sees only the user's correction ('No, it's $2M') without the original statement ('It's $3M'), and misclassifies the turn as a new data point. Guardrail: Maintain a structured state object outside the prompt that holds the last N claims. Always inject the most recent assistant claims into the classification prompt as [PRIOR_CLAIMS] to ensure the model has the necessary context for contradiction analysis.

06

Over-Correction Cascade

Risk: A minor correction ('My name is spelled Jon, not John') is classified correctly, but the state rollback logic is too aggressive and invalidates all subsequent derived state, including completed tool calls and summaries. Guardrail: Implement granular state dependency tracking. The correction classifier should output a scope field (correction_scope: "specific_slot" vs "full_turn"). Only invalidate downstream state that has a direct dependency on the corrected value, preventing a single correction from resetting the entire session.

IMPLEMENTATION TABLE

Evaluation Rubric

Use this rubric to evaluate the Correction vs New Topic Detection prompt before shipping. Each criterion targets a specific failure mode observed in production dialogue routers. Run these tests against a golden dataset of ambiguous turns where correction and topic shift overlap.

CriterionPass StandardFailure SignalTest Method

Explicit Correction Detection

All turns containing direct contradiction language (e.g., 'no, that's wrong', 'actually it was') are classified as correction with confidence >= 0.9

Explicit corrections classified as new_topic or confidence < 0.7

Run against 50 labeled explicit correction turns; measure recall >= 0.98 and precision >= 0.95

Topic Shift with Contradiction

Turns that introduce a new domain while contradicting prior context are classified as new_topic, not correction

New domain introductions with incidental contradiction classified as correction

Test 20 turns where user says 'no, let's talk about X instead'; verify new_topic classification rate >= 0.90

Ambiguous Overlap Handling

For turns where correction and topic shift are genuinely ambiguous, confidence score is <= 0.75 and rationale field identifies both possibilities

High-confidence classification on ambiguous turns without acknowledging the alternative interpretation

Curate 15 expert-labeled ambiguous turns; verify confidence <= 0.75 and rationale mentions both correction and topic_shift

Implicit Correction Recognition

Turns that correct without explicit language (e.g., 'the report was for Q3' when assistant said Q2) are classified as correction

Implicit corrections missed entirely or classified as new_topic

Test 30 implicit correction turns; measure recall >= 0.85

Contradiction Analysis Accuracy

The contradiction_analysis field correctly identifies the specific prior claim being contradicted and the new claim

contradiction_analysis references wrong prior turn, hallucinates a prior claim, or is null when contradiction exists

Spot-check 25 outputs; verify contradiction_analysis matches human annotation in >= 90% of cases

Non-Correction Clarification Handling

Clarifying questions that reference prior output without contradicting it (e.g., 'did you mean X or Y?') are classified as neither correction nor new_topic

Clarifying questions misclassified as corrections

Test 20 clarification turns; verify correction classification rate <= 0.05

Routing Decision Consistency

Identical turns with identical prior context produce the same classification and confidence within 0.05 tolerance across 5 repeated runs

Classification flips between correction and new_topic on repeated identical inputs

Run 10 ambiguous turns 5 times each; measure classification consistency >= 0.95

Latency Budget Compliance

Prompt execution completes in under 2 seconds for turns with up to 10 prior messages in context

Response time exceeds 3 seconds in production-like conditions

Benchmark with 100-turn conversation history; measure p95 latency < 2000ms

ADAPTATION OPTIONS

Adapt This Prompt

How to adapt

Start with the base prompt and a single classification label (correction or new_topic). Use a lightweight JSON output with only decision and confidence fields. Skip contradiction analysis and evidence comparison. Run against 20-30 hand-labeled examples to establish baseline accuracy before adding complexity.

Add a simple override rule in your harness: if confidence is below 0.7, default to new_topic to avoid false correction routing.

Watch for

  • Ambiguous turns where the user both corrects and shifts topic in one message
  • Over-triggering on clarifying questions that sound like contradictions
  • Missing the distinction between correction and refinement (user adding detail vs. disputing a claim)
Prasad Kumkar

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.