Use this prompt when a user explicitly corrects a model's output in a conversational AI product and you need to diagnose the root cause. The ideal user is a conversational AI developer, support engineer, or AI SRE who has already captured a correction event and isolated the relevant trace spans. The job-to-be-done is not live inference or automated self-correction; it is a post-hoc diagnostic workflow that produces a structured analysis of what went wrong, backed by trace evidence. This prompt is the first step in closing the loop between a user-reported correction and a concrete fix recommendation.
Prompt
User Correction Event Analysis Prompt

When to Use This Prompt
Defines the diagnostic context, prerequisites, and boundaries for using the User Correction Event Analysis Prompt in a production conversational AI system.
This prompt requires a specific set of inputs to be effective. You must provide the original model response that the user corrected, the user's correction text, and the surrounding trace context, which includes prior turns, retrieved documents, tool calls, and system instructions active at the time of the error. The prompt assumes you have already extracted the correction turn from a larger session trace and formatted it into a single trace event payload. Do not use this prompt on raw, unprocessed trace logs or on correction events where the trace context is incomplete or missing. The output is a structured correction analysis containing the original response, the user correction, trace evidence of the error, a fault attribution (prompt defect, retrieval gap, tool failure, or model error), and a fix recommendation. This output requires human review before any fix is implemented, especially for high-severity faults or production prompt changes.
Avoid using this prompt in scenarios where the correction is ambiguous, the user's intent is unclear, or the trace data is too sparse to support a confident attribution. It is not designed for real-time correction handling during live conversations, for aggregating patterns across multiple correction events, or for automatically applying fixes without review. If you need to triage a user-reported issue before deep diagnosis, use the User-Reported Issue Triage Prompt instead. If you need to correlate feedback signals across many sessions, use the Feedback Signal Correlation Prompt. This prompt is the precise diagnostic instrument you reach for when you have one clear correction event and need to understand exactly what failed.
Use Case Fit
Where the User Correction Event Analysis Prompt delivers reliable diagnostic value and where it introduces unacceptable risk or noise.
Good Fit: Explicit User Corrections
Use when: The user provides a direct, unambiguous correction such as 'No, that's wrong, it should be X.' The trace contains a clear model output and a subsequent user message that contradicts or amends it. Guardrail: Filter sessions to only those containing explicit correction signals before invoking analysis to avoid analyzing vague dissatisfaction.
Bad Fit: Implicit Dissatisfaction
Avoid when: The user expresses frustration, abandons the session, or gives a thumbs-down without specifying what was wrong. The prompt cannot reliably infer the correction target from implicit signals. Guardrail: Route implicit feedback to a Feedback Signal Correlation Prompt first to determine if a traceable issue exists before attempting correction analysis.
Required Inputs: Complete Trace Span
Risk: Analyzing a correction without the full trace context—including the original model response, the user correction, and any intermediate tool calls or retrieval steps—produces a speculative and potentially incorrect diagnosis. Guardrail: Validate that the input trace contains all required spans before running the prompt. If spans are missing, flag the session for manual review instead of generating a partial analysis.
Operational Risk: Premature Fix Deployment
Risk: The prompt generates a fix recommendation that an operator might deploy directly to production without validation, potentially causing a regression for other users. Guardrail: The output must include a mandatory human-review gate. The fix recommendation should be treated as a hypothesis, not a deployable artifact, until reviewed against a regression test suite.
Operational Risk: Single-Session Overfitting
Risk: A fix derived from a single user correction may overfit to that specific case and degrade performance for the broader user base. Guardrail: Require correlation with other similar correction events before accepting a fix. The analysis output should include a recommendation to query for similar trace patterns before implementing changes.
Bad Fit: Multi-Turn Ambiguity
Avoid when: The correction occurs after many conversational turns, and it is ambiguous which prior model output the user is correcting. The prompt may misattribute the correction target. Guardrail: For sessions with more than 5 turns after the suspected error, flag for manual review or use a Multi-Turn Conversation Trace Replay Prompt first to establish the correct target turn.
Copy-Ready Prompt Template
A ready-to-use prompt for analyzing a user correction event from a production trace to determine the root cause and recommend a fix.
This prompt template is designed to be pasted directly into your trace analysis tool, LLM playground, or API call. It instructs the model to act as a diagnostic engineer, analyzing a specific trace event where a user corrected the assistant's output. The goal is to produce a structured analysis that identifies why the error occurred, not just what the error was. Before using this prompt, ensure you have extracted the relevant trace spans—including the original model response, the user's correction, the system prompt, any retrieved context, and tool-call logs—from your observability platform. The prompt uses square-bracket placeholders that you must replace with real trace data before execution.
textYou are a diagnostic engineer analyzing a production AI trace. Your task is to investigate a specific event where a user corrected the model's output. Use the provided trace data to determine the root cause of the error and recommend a concrete fix. ## INPUT DATA ### Trace Event Summary - **Event ID:** [TRACE_EVENT_ID] - **Timestamp:** [TIMESTAMP] - **Session ID:** [SESSION_ID] ### System Prompt (at time of event)
[SYSTEM_PROMPT]
code### Conversation History (last 3 turns before the correction)
[CONVERSATION_HISTORY]
code### Original Model Response (the one the user corrected)
[ORIGINAL_MODEL_RESPONSE]
code### User Correction
[USER_CORRECTION]
code### Retrieved Context (if RAG was used)
[RETRIEVED_CONTEXT]
code### Tool-Call Log (if tools were used)
[TOOL_CALL_LOG]
code## ANALYSIS INSTRUCTIONS 1. **Categorize the Error:** Classify the failure into one of these categories: - `prompt_defect`: The system prompt was ambiguous, contradictory, or missing a critical instruction. - `retrieval_gap`: Required information was missing from the retrieved context, or irrelevant context was included. - `tool_failure`: A tool was called incorrectly, returned an error, or the wrong tool was selected. - `model_error`: The model hallucinated, ignored a clear instruction, or reasoned incorrectly despite correct inputs. - `state_management_error`: The model lost track of the conversation history or user intent. 2. **Identify the Root Cause:** Pinpoint the exact moment in the trace where the failure originated. Quote the specific line from the system prompt, retrieved context, tool log, or model response that is the primary evidence. 3. **Assess Severity:** Rate the severity as `low`, `medium`, `high`, or `critical` based on the user impact. 4. **Recommend a Fix:** Propose a specific, actionable change. This could be a prompt rewrite, a retrieval pipeline adjustment, a tool schema change, or a model upgrade recommendation. Do not implement the fix; only recommend it. ## OUTPUT FORMAT Return your analysis as a single JSON object with the following schema. Do not include any text outside the JSON object. { "event_id": "[TRACE_EVENT_ID]", "error_category": "prompt_defect | retrieval_gap | tool_failure | model_error | state_management_error", "root_cause_evidence": "A direct quote from the input data that proves the root cause.", "severity": "low | medium | high | critical", "fix_recommendation": "A specific, actionable recommendation for the engineering team.", "requires_human_review": true } ## CONSTRAINTS - Base your analysis strictly on the provided trace data. Do not speculate beyond the evidence. - If the evidence is insufficient to determine a single root cause, state the most likely cause and set `requires_human_review` to `true`. - The `fix_recommendation` must be a concrete change, not a vague suggestion like "improve the prompt."
After pasting the template, your primary task is to replace the square-bracket placeholders with actual data from your tracing system (e.g., LangSmith, Arize, Weights & Biases, or a custom log). The quality of the analysis depends entirely on the completeness of this input data. A common failure mode is providing an incomplete trace—for example, omitting the RETRIEVED_CONTEXT in a RAG system—which will force the model to guess and produce an unreliable analysis. Always set requires_human_review to true in the output schema; this prompt is a diagnostic aid, not an auto-remediation tool. The recommended fix must be validated by a human engineer before it is deployed to production.
Prompt Variables
Inputs required before executing the User Correction Event Analysis Prompt. Validate each placeholder to prevent misattribution and ensure the trace evidence is complete.
| Placeholder | Purpose | Example | Validation Notes |
|---|---|---|---|
[TRACE_JSON] | Raw trace object containing the full event log for the session where the correction occurred. | {"trace_id": "abc-123", "spans": [...]} | Must be valid JSON. Parse check required. Must contain spans covering the original model response and the subsequent user turn. Fail if null or empty. |
[USER_CORRECTION_TEXT] | The exact text of the user's correction message. | No, the billing cycle starts on the 15th, not the 1st. | Must be a non-empty string. Confirm this text exists as a user message span in [TRACE_JSON]. Fail if null or whitespace only. |
[ORIGINAL_MODEL_RESPONSE_TEXT] | The model's output that immediately preceded the user correction. | Your billing cycle starts on the 1st of each month. | Must be a non-empty string. Extract from the assistant span immediately before the correction turn in [TRACE_JSON]. Fail if not found or if the span type is not 'assistant'. |
[RETRIEVED_CONTEXT_SNAPSHOT] | The list of documents or chunks provided to the model when it generated the original response. | [{"doc_id": "doc-1", "text": "Billing cycles begin on the 15th."}] | Must be an array. Extract from the trace span's input context. Can be empty if no retrieval occurred, but must not be null. Validate array type. |
[TOOL_CALL_LOG] | Log of all tool calls made by the model during the session up to the correction point. | [{"tool": "get_billing_info", "args": {...}, "result": "..."}] | Must be an array. Extract from trace spans with type 'tool_call'. Can be empty if no tools were used. Validate array type and ensure timestamps precede the correction event. |
[SYSTEM_PROMPT_VERSION] | The identifier or content of the system prompt active during the original response. | v2.3.1 | Must be a non-empty string. Extract from the trace metadata or the first system span. Fail if missing, as prompt defects cannot be ruled out without this. |
[SESSION_METADATA] | Key-value pairs for the session (user ID, session ID, timestamp, feature flags). | {"user_id": "u-456", "session_id": "sess-789"} | Must be a valid JSON object. Required for traceability and feedback correlation. Fail if null or missing required keys like 'session_id'. |
Implementation Harness Notes
How to wire the User Correction Event Analysis Prompt into a production trace-review application or support workflow.
This prompt is designed to be called programmatically, not used in a one-off chat interface. The primary integration point is a trace-analysis pipeline or an internal support tool that surfaces user-reported corrections. When a user flags an incorrect response, the application must fetch the full trace for that session, extract the relevant spans (user message, model response, tool calls, retrieved context), and inject them into the prompt's placeholders. The prompt is stateless: every call must receive the complete trace evidence it needs. Do not rely on the model remembering prior turns or session state.
Wire the prompt into a structured workflow with clear pre- and post-processing steps. Before calling the model, validate that the trace payload is complete: confirm that the [ORIGINAL_MODEL_RESPONSE] and [USER_CORRECTION] fields are non-empty, and that [TRACE_EVIDENCE] contains at least the generation span and any retrieval or tool-call spans that preceded it. If the trace is incomplete, abort and surface a data-gap error to the operator rather than asking the model to guess. After receiving the model's output, parse the JSON response and validate the schema: correction_category, root_cause, trace_evidence_for_error, and fix_recommendation must all be present and non-null. If validation fails, retry once with a stricter schema reminder appended to the prompt. Log every analysis result—including the trace ID, the model's output, and the validator result—to an audit table for later review.
This workflow is high-risk because the fix recommendation could be applied to a production prompt or retrieval config. Always route the output to a human review queue before any change is implemented. The fix_recommendation field is a suggestion, not an auto-apply instruction. Pair this prompt with an eval step: periodically run a set of known correction events with ground-truth root causes through the pipeline and measure whether the model's correction_category and root_cause match the expected labels. Track precision and recall per category (prompt defect, retrieval gap, tool failure, model error) to detect drift. Choose a model with strong instruction-following and JSON output discipline—GPT-4o, Claude 3.5 Sonnet, or Gemini 1.5 Pro are reasonable defaults. Avoid smaller or older models that may conflate categories or hallucinate trace evidence not present in the input.
For RAG-heavy applications, ensure the [TRACE_EVIDENCE] includes the retrieved chunks, their ranking scores, and any truncation markers. The model cannot diagnose a retrieval gap if it cannot see what was retrieved. If your trace system captures only the final context window, augment the input with a pre-retrieval summary showing what was available in the index. For tool-use failures, include the tool schema, the arguments passed, and any error codes or timeouts. The prompt's diagnostic accuracy depends entirely on the completeness of the trace evidence you provide. When integrating with a support ticket system, attach the analysis output as an internal note to the ticket and link back to the raw trace for auditors. Do not expose the raw analysis to end users without review—the model may produce plausible-sounding but incorrect attributions.
Finally, treat this prompt as a product component with its own versioning and change log. When you update the prompt template, run your eval suite against the new version before deployment. Monitor the human-review acceptance rate: if reviewers are frequently overriding the model's correction_category or root_cause, the prompt may need refinement or the trace evidence may be insufficient. Set an alert if the validation failure rate exceeds 5% of calls, as this indicates either a schema drift in the model's output or a systemic trace-data gap. The goal is a reliable diagnostic tool that reduces mean time to root cause for user-reported corrections, not a fully automated fix pipeline.
Expected Output Contract
Fields, format, and validation rules for the correction analysis output. Use this contract to build a parser, validator, or eval harness before integrating the prompt into a production pipeline.
| Field or Element | Type or Format | Required | Validation Rule |
|---|---|---|---|
correction_id | string (UUID v4) | Must parse as valid UUID v4. Reject if missing or malformed. | |
original_model_response | string | Must not be empty or whitespace-only. Must match the exact response from the trace span referenced by [TRACE_SPAN_ID]. | |
user_correction | string | Must not be empty. Must differ from original_model_response by at least one token. Reject if identical. | |
error_category | enum: prompt_defect | retrieval_gap | tool_failure | model_error | grounding_failure | state_corruption | Must be exactly one of the allowed enum values. Reject unknown categories. | |
trace_evidence | array of objects with span_id, event_type, excerpt, timestamp | Array must contain at least one entry. Each entry must have a span_id matching a real trace span. Excerpt must be a non-empty substring from the referenced span. | |
root_cause_statement | string (1-3 sentences) | Must be between 50 and 500 characters. Must reference at least one trace_evidence entry. Reject if purely speculative language without trace grounding. | |
fix_recommendation | object with action, target_component, suggested_change, risk_level | action must be one of: rewrite_prompt | reindex_knowledge_base | fix_tool_schema | retrain_model | add_guardrail | escalate. risk_level must be low, medium, or high. suggested_change must not be empty. | |
requires_human_review | boolean | Must be true if risk_level is high or error_category is tool_failure. Reject if false when conditions require approval. |
Common Failure Modes
Correction events are high-signal diagnostics, but the analysis prompt itself can fail in predictable ways. These cards cover what breaks first when analyzing user corrections from traces and how to guard against misdiagnosis.
False Attribution to the Wrong Component
What to watch: The prompt blames the model for a hallucination when the root cause was a retrieval gap, or blames a tool when the prompt instructions were ambiguous. Without explicit trace segmentation, the analysis conflates components. Guardrail: Require the prompt to output a structured fault_attribution field with exactly one value from a closed enum (prompt, retrieval, tool, model, infrastructure) and a separate evidence field citing specific trace spans.
Hallucinated Fix Recommendations
What to watch: The analysis prompt confidently suggests a prompt rewrite or retrieval change that introduces a new bug, removes a necessary constraint, or contradicts the system prompt architecture. The model is generating a fix from a single failure example. Guardrail: Append a hard constraint to the output schema: fix_recommendation must be accompanied by requires_human_approval: true and a risk_note explaining what else the change might break. Never auto-apply fixes from this analysis.
Ignoring Silent Failures in the Trace
What to watch: The user correction is treated as the only failure signal. The trace may contain earlier silent failures—a tool returning an empty list, a retrieval step with zero relevant chunks, a confidence score below threshold—that the model didn't surface to the user. Guardrail: Add an instruction to scan all trace spans for anomalies before analyzing the correction event. Require a preceding_anomalies array in the output, even if empty, to force the check.
Overfitting to a Single Correction Pattern
What to watch: The analysis prompt sees a user correcting a date and recommends a date-parsing fix, missing that the real issue is a broader context-window truncation problem affecting multiple entity types. Guardrail: Include a pattern_scope field that forces the model to assess whether the correction is an isolated instance or a symptom of a systemic issue. Require evidence from other trace spans to support the scope assessment.
Correction Misclassification
What to watch: The prompt classifies a user clarification as a model error, or treats a preference change as a factual correction. This leads to unnecessary 'fixes' for correct behavior. Guardrail: Add a correction_type enum to the output schema with values like factual_error, missing_information, preference_change, clarification, and user_mistake. Require a confidence score for the classification and flag low-confidence classifications for human review.
Trace Context Window Overflow
What to watch: The full trace with all spans, tool calls, and retrieved documents exceeds the analysis model's context window. The prompt silently truncates, dropping the very spans that contain the root cause. Guardrail: Pre-process traces to extract only spans relevant to the correction event before passing them to the analysis prompt. Add a trace_completeness_check instruction: if the input trace appears truncated, the model must output analysis_confidence: low and flag the truncation.
Evaluation Rubric
Criteria for testing the quality of a User Correction Event Analysis output before shipping it into a diagnostic pipeline. Each row defines a pass standard, a failure signal, and a concrete test method.
| Criterion | Pass Standard | Failure Signal | Test Method |
|---|---|---|---|
Trace Evidence Grounding | Every claim in the analysis is backed by a specific trace span ID or event timestamp. | Analysis contains speculative statements like 'the model probably' without a linked trace event. | Parse output for trace references; flag any sentence with a causal claim that lacks a span ID or timestamp. |
Correction Classification Accuracy | The correction type (e.g., factual error, refusal, formatting) matches a predefined taxonomy and is consistent with the user's correction text. | Correction type is missing, 'Other' is used when a specific category applies, or the type contradicts the user's stated correction. | Run a rule-based check against a closed taxonomy; spot-check 20 samples with a human reviewer for agreement. |
Root Cause Attribution | The analysis identifies a single primary root cause (prompt defect, retrieval gap, tool failure, model error) with supporting trace evidence. | Multiple root causes are listed without a primary, or the attribution is 'unknown' when trace evidence clearly points to one category. | Assert that exactly one primary root cause is present; validate that the evidence field references a trace span from the correct category. |
Fix Recommendation Actionability | The recommended fix is a specific, implementable change (e.g., 'add constraint X to system prompt at line Y', 're-index document Z'). | Recommendation is vague ('improve the prompt'), suggests retraining the model as a first resort, or proposes a fix unrelated to the root cause. | Check that the recommendation field contains a verb, a target component, and a specific change; flag for human review if the fix is 'retrain model' or 'try again'. |
Human Review Flag Accuracy | The output correctly flags the analysis for human review when the confidence score is below the threshold or the root cause is ambiguous. | Human review flag is set to false when confidence is below the threshold, or the flag is true but the confidence score is high with a clear root cause. | Assert that human_review_required is true when confidence_score < 0.7; assert it is false when confidence_score >= 0.9 and root cause is singular. |
Original Response Fidelity | The [ORIGINAL_MODEL_RESPONSE] in the output matches the response captured in the trace exactly, including formatting and truncation. | The original response is paraphrased, truncated without notation, or contains content not present in the trace. | Perform an exact string match between the output's original_response field and the trace's response payload; flag any mismatch. |
User Correction Preservation | The [USER_CORRECTION] is quoted verbatim from the trace, preserving typos, casing, and punctuation. | The user correction is cleaned, summarized, or altered from the raw trace input. | Perform an exact string match between the output's user_correction field and the trace's user input event; flag any deviation. |
Confidence Score Calibration | The confidence score is between 0.0 and 1.0 and correlates with the amount and quality of trace evidence supporting the root cause. | Confidence score is 1.0 when evidence is thin, or 0.2 when the trace clearly isolates the failure. | Check that 0.0 <= confidence_score <= 1.0; run a distribution check across 100 samples to detect ceiling effects (all scores > 0.95) or random scoring. |
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
Use the base prompt with lighter validation. Remove strict schema requirements and focus on getting a readable correction analysis. Accept free-text output instead of enforcing JSON structure. Run on a small sample of 5-10 correction events to calibrate the prompt before adding constraints.
Watch for
- Missing schema checks that let the model drift into narrative prose instead of structured analysis
- Overly broad instructions that produce vague fix recommendations like "improve the prompt" without specifics
- No trace evidence citation, making it impossible to verify whether the diagnosis is grounded

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