This prompt is designed for prompt engineers and AI reliability engineers who need to determine whether a piece of negative or corrective user feedback points to a defect in the system prompt itself. The job-to-be-done is isolating the root cause of a behavioral failure when the model's output was technically valid but violated user expectations, policy, or the intended assistant contract. The ideal user is someone who already has access to a production trace containing the user feedback signal, the full system instructions, and the model's final response. They are not guessing; they are performing a structured differential diagnosis to separate prompt ambiguity from retrieval gaps, tool-call errors, or model hallucinations.
Prompt
Feedback-to-Prompt-Defect Detection Prompt

When to Use This Prompt
Determine when to deploy the Feedback-to-Prompt-Defect Detection Prompt to isolate instruction-level root causes from user feedback traces.
You should use this prompt when user feedback is explicit (e.g., a thumbs-down, a correction like 'you shouldn't have done that,' or a complaint that the assistant ignored a rule) and the root cause is unclear from a surface reading of the trace. The prompt works by forcing the model to compare the system instructions against the assistant's behavior, identify the specific instruction that was violated, was ambiguous, or conflicted with another rule, and produce a defect report with a suggested rewrite. Do not use this prompt for failures where the model hallucinated facts not present in the prompt, where a tool call returned an error, or where the retrieval pipeline returned irrelevant documents. Those failures require their own diagnostic prompts. This prompt is strictly for instruction-level defects.
Before using this prompt, ensure you have the complete system prompt, the user's feedback signal, and the model's response captured in the trace. The output requires human review before any prompt change is deployed. A suggested rewrite from this prompt is a diagnostic artifact, not a deployable fix. You must validate that the rewrite does not introduce new conflicts, regress other behaviors, or violate the system's broader instruction hierarchy. Pair this prompt with a regression test run against your golden dataset before accepting any change.
Use Case Fit
Where the Feedback-to-Prompt-Defect Detection Prompt works, where it fails, and the operational preconditions required before you run it.
Good Fit: Trace-Linked User Reports
Use when: a user report (thumbs-down, correction, complaint) is already linked to a specific production trace. The prompt excels at comparing the model's observed behavior against the system prompt's explicit rules. Guardrail: Always verify the trace ID and session timestamp before analysis to prevent misattribution.
Bad Fit: Vague or Untriaged Feedback
Avoid when: the input is a raw NPS comment, a general satisfaction score, or a support ticket without a linked trace. The prompt requires concrete trace evidence to function. Guardrail: Route untriaged feedback to a User-Reported Issue Triage Prompt first to establish trace linkage and a preliminary failure category.
Required Inputs
Must have: the full system prompt version, the user's raw feedback signal, and the complete production trace (user messages, model responses, tool calls, and retrieved context). Guardrail: If the trace is incomplete or spans are missing, flag the analysis confidence as low and request a Session Replay Reconstruction Prompt to fill gaps before diagnosing a defect.
Operational Risk: False Attribution
Risk: the prompt may incorrectly attribute a retrieval gap or a tool failure to a prompt defect, leading to an unnecessary and potentially harmful prompt rewrite. Guardrail: Require the output to explicitly rule out retrieval, tool, and model routing failures before confirming a prompt defect. Cross-reference with Tool Failure Attribution and Retrieval Gap Identification prompts for high-severity issues.
Operational Risk: Unreviewed Rewrites
Risk: the suggested prompt rewrite may introduce new ambiguities, conflict with other system rules, or break edge cases not present in the single trace under review. Guardrail: the output must include a mandatory human review gate. The suggested rewrite must be tested against a regression suite before deployment, never applied directly from the analysis.
Bad Fit: Multi-Cause Failures
Avoid when: the trace shows a cascade of failures (e.g., a retrieval gap that caused a tool error, which then violated a prompt rule). The prompt is designed to isolate a single prompt defect, not untangle compound failures. Guardrail: for complex cascades, use a Customer Complaint Root-Cause Isolation Prompt first to establish the primary fault, then run this prompt only if the root cause is confirmed as a prompt defect.
Copy-Ready Prompt Template
A reusable prompt template for analyzing a user feedback report against a production trace to identify prompt-level defects.
This template is designed to be pasted directly into your trace analysis tool, evaluation harness, or LLM workbench. It instructs the model to act as a prompt forensics engineer, correlating a specific piece of user feedback with the raw trace data to isolate whether the root cause is a defect in the system prompt's instructions. The prompt forces the model to cite specific trace events as evidence and propose a concrete, minimal prompt rewrite, rather than offering vague suggestions.
textYou are a prompt forensics engineer. Your task is to analyze a user feedback report against a production trace to determine if the root cause is a defect in the system prompt. <USER_FEEDBACK> [USER_FEEDBACK] </USER_FEEDBACK> <PRODUCTION_TRACE> [PRODUCTION_TRACE] </PRODUCTION_TRACE> <SYSTEM_PROMPT> [SYSTEM_PROMPT] </SYSTEM_PROMPT> Follow these steps: 1. **Analyze the Feedback:** Paraphrase the user's core complaint and the expected behavior. 2. **Reconstruct the Failure:** Identify the exact point in the <PRODUCTION_TRACE> where the model's behavior diverged from the expected behavior. Cite the specific trace span ID, tool call, or log line. 3. **Diagnose the Root Cause:** Determine if the failure is a prompt defect, a retrieval gap, a tool failure, or a model reasoning error. If it is a prompt defect, identify the exact conflicting, ambiguous, or missing instruction in the <SYSTEM_PROMPT>. 4. **Propose a Prompt Rewrite:** If a prompt defect is found, output a minimal, targeted rewrite of the offending section. The rewrite must be a drop-in replacement that addresses the defect without changing other behavior. 5. **Assess Confidence:** Provide a confidence score (High/Medium/Low) for your diagnosis and rewrite. Your output must be a JSON object conforming to this schema: { "feedback_analysis": "string", "failure_reconstruction": { "divergence_point": "string (trace span ID or event)", "trace_evidence": "string (excerpt from the trace)" }, "root_cause_diagnosis": { "category": "PROMPT_DEFECT | RETRIEVAL_GAP | TOOL_FAILURE | MODEL_ERROR", "offending_prompt_section": "string | null (exact text from system prompt)", "defect_explanation": "string | null (explanation of the ambiguity, conflict, or omission)" }, "prompt_rewrite": { "original_text": "string | null", "rewritten_text": "string | null", "rewrite_rationale": "string | null" }, "confidence": "HIGH | MEDIUM | LOW" }
To adapt this template, replace the bracketed placeholders with your actual data. [USER_FEEDBACK] should contain the raw text of the user's complaint. [PRODUCTION_TRACE] should be the full, structured trace data (e.g., an OpenTelemetry JSON export or a LangSmith trace). [SYSTEM_PROMPT] is the exact version of the system prompt that was active when the trace was captured. The output schema is strict JSON, making it suitable for direct integration into an automated triage pipeline. For high-risk applications, always route the prompt_rewrite object to a human-in-the-loop review queue before deploying the change.
Prompt Variables
Required inputs for the Feedback-to-Prompt-Defect Detection Prompt. Each placeholder must be populated from trace data, user feedback records, and the active prompt registry before execution. Missing or malformed inputs are the most common cause of false-positive defect attributions.
| Placeholder | Purpose | Example | Validation Notes |
|---|---|---|---|
[USER_FEEDBACK_TEXT] | The raw user-reported complaint, correction, or negative signal that triggered the investigation. | The assistant told me I need to submit Form 12B, but my accountant says that form was deprecated in 2023. | Must be non-empty and contain a claim about model behavior. Reject if feedback is only a rating or emoji without text. |
[FULL_TRACE_JSON] | The complete production trace for the session, including all spans, tool calls, retrieved context, and model responses in structured JSON format. | { spans: [{ span_id: 'abc', operation: 'llm_call', input: {...}, output: {...} }] } | Must parse as valid JSON with a spans array. Each span must include span_id, operation, and timestamp. Reject if trace is truncated or missing the session where feedback occurred. |
[ACTIVE_SYSTEM_PROMPT] | The exact system prompt version that was active when the trace was generated, retrieved from the prompt registry. | You are a tax assistant. Always cite IRS publication numbers. Do not recommend deprecated forms. | Must match the prompt_version_id in the trace metadata. Reject if version mismatch is detected. Null allowed only if trace predates version tracking. |
[PROMPT_VERSION_ID] | The unique identifier for the prompt version under investigation, used to retrieve the correct prompt text and changelog. | v2.4.1-tax-assistant | Must be a non-empty string matching the registry format. Reject if version_id is not found in the prompt registry. |
[RETRIEVED_CONTEXT_SNAPSHOT] | The full text of all documents, chunks, or knowledge base entries that were retrieved and inserted into the context window for this session. | Document 1: IRS Publication 17 (2024) Section 5... Document 2: Form 12B instructions (deprecated 2022)... | Must include all chunks with their source identifiers and retrieval scores. Reject if context is empty when the trace shows a RAG step was executed. |
[TOOL_CALL_LOG] | The complete log of all tool calls made during the session, including function names, arguments, responses, and error codes. | [{ tool: 'search_kb', args: { query: 'Form 12B' }, response: {...}, error: null }] | Must parse as a JSON array. Each entry must include tool name, arguments, and response. Reject if tool calls are present in trace but missing from this input. |
[FEEDBACK_TIMESTAMP] | The exact timestamp when the user submitted the feedback, used to locate the relevant turn in the trace. | 2025-03-15T14:32:10Z | Must be ISO 8601 format. Must fall within the trace session time range. Reject if timestamp is outside the trace window or cannot be correlated to a specific turn. |
[PREVIOUS_DEFECT_REPORTS] | Optional array of prior defect reports for the same prompt version, used to detect recurring patterns and avoid duplicate findings. | [{ defect_id: 'DEF-142', finding: 'Ambiguous instruction on form eligibility', status: 'open' }] | Null allowed for first investigation. If provided, must be a valid JSON array. Each entry must include defect_id and status. Reject if status is 'resolved' without verification. |
Implementation Harness Notes
How to wire the Feedback-to-Prompt-Defect Detection Prompt into an observability pipeline or support workflow.
This prompt is designed to operate as a diagnostic step within a larger trace-analysis pipeline, not as a standalone chat interaction. The typical trigger is a user-reported issue or a negative feedback signal (thumbs-down, correction, abandonment) that has already been mapped to a specific production trace via a preceding 'User Feedback to Trace Mapping' step. The harness should fetch the full trace payload—including the system prompt version, user messages, retrieved context chunks, tool-call definitions, and the final model output—and inject it into the [TRACE_JSON] placeholder. The [FEEDBACK_SIGNAL] placeholder should receive a structured description of what the user reported, not raw free-text, to improve consistency.
Validation and retry logic is critical because this prompt produces a structured defect report that downstream systems may act on. After the model returns its output, validate the JSON schema strictly: the offending_prompt_section field must be a non-empty string that can be located in the original system prompt, the trace_evidence array must contain at least one span ID or timestamp from the input trace, and the suggested_rewrite must differ from the original text. If validation fails, retry once with the validation errors appended to the [CONSTRAINTS] field. If the second attempt also fails, escalate to a human reviewer rather than silently accepting a malformed report. For high-severity classifications (where defect_severity is 'critical' or 'high'), always require human approval before the suggested rewrite is deployed to production, regardless of validation success.
Model choice and tool use should favor models with strong instruction-following and structured output capabilities. GPT-4o, Claude 3.5 Sonnet, or equivalent models are appropriate. Enable structured output mode (JSON mode or function calling with a strict schema) to reduce parsing errors. This prompt does not require tool calls or retrieval during execution—the trace data is provided inline—but the harness should log the model's output, the validation result, and the human review decision to an audit table for governance. Avoid wiring this prompt directly to an automated prompt-deployment pipeline; the suggested rewrite is a recommendation, not a command. The final step should always be a human-in-the-loop review that considers the defect report, the suggested rewrite, and any regression test results before merging the change.
Expected Output Contract
Defines the structure, types, and validation rules for the defect report generated by the Feedback-to-Prompt-Defect Detection Prompt. Use this contract to parse, validate, and route the model's output before presenting it for human review.
| Field or Element | Type or Format | Required | Validation Rule |
|---|---|---|---|
defect_id | string (UUID v4) | Must match UUID v4 regex. Generate if null. | |
trace_id | string | Must match the [TRACE_ID] input exactly. Fail on mismatch. | |
feedback_signal | string | Must be one of: 'thumbs_down', 'correction', 'abandonment', 'escalation', 'other'. Reject unknown values. | |
defect_category | string | Must be one of: 'instruction_violation', 'ambiguity', 'conflicting_rules', 'missing_instruction', 'other'. Reject unknown values. | |
offending_prompt_section | string | Must be a non-empty substring found verbatim in the [SYSTEM_PROMPT] input. Fail if not found. | |
trace_evidence | array of objects | Each object must contain 'span_id' (string), 'event_type' (string), and 'excerpt' (string). Array must not be empty. | |
suggested_rewrite | string | Must differ from the offending_prompt_section. Null or identical string is a validation failure. | |
confidence_score | number (0.0-1.0) | Must be a float between 0.0 and 1.0 inclusive. Values below 0.7 should trigger a low-confidence flag for human review. |
Common Failure Modes
What breaks first when analyzing user feedback for prompt defects and how to guard against it.
False Attribution to Prompt Defect
What to watch: The analysis incorrectly blames the prompt when the real cause is a retrieval gap, tool timeout, or model hallucination. This happens when the trace shows a plausible instruction violation but misses upstream failures. Guardrail: Require the defect report to rule out retrieval, tool, and model errors before concluding a prompt defect. Include a mandatory differential diagnosis section in the output schema.
Overfitting to a Single Trace
What to watch: The analysis identifies a prompt defect based on one anomalous trace without checking whether the pattern repeats across sessions. A single bad response may be a model sampling issue, not a systematic prompt flaw. Guardrail: Require correlation with at least 3 similar feedback traces before recommending a prompt rewrite. Flag single-trace findings as 'candidate defects' requiring further evidence.
Ambiguous Instruction Detection Failure
What to watch: The prompt contains genuinely conflicting or vague instructions, but the analysis misses them because the trace evidence is subtle or the model compensated correctly in other cases. Guardrail: Include a pairwise instruction conflict check in the analysis. Compare every behavioral rule against every other rule and flag overlaps, contradictions, and undefined precedence.
Suggested Rewrite Introduces New Defects
What to watch: The recommended prompt rewrite fixes the reported issue but breaks other behaviors because the analysis didn't test the change against the full regression suite. Guardrail: Require the defect report to list which existing behaviors the rewrite might affect. Run the suggested prompt against golden test cases before deployment. Never auto-apply rewrites.
Trace Evidence Misalignment
What to watch: The analysis cites trace spans that don't actually support the defect claim, either because the wrong span was selected or the span content was misinterpreted. Guardrail: Require exact span IDs and quoted excerpts in the defect report. Add a verification step that checks whether the cited evidence directly demonstrates the claimed instruction violation.
Feedback Signal Misclassification
What to watch: The analysis treats all negative feedback as a prompt defect signal, but the user may have disliked the tone, wanted a different format, or had expectations the system isn't designed to meet. Guardrail: Classify feedback type before defect analysis. Separate 'prompt defect' from 'preference mismatch,' 'capability gap,' and 'user error.' Only route confirmed defect signals to the prompt analysis workflow.
Evaluation Rubric
Use this rubric to test the Feedback-to-Prompt-Defect Detection Prompt before integrating it into your trace analysis pipeline. Each criterion validates a specific output quality dimension. Run these checks against a golden set of annotated traces with known prompt defects and clean traces to calibrate pass/fail thresholds.
| Criterion | Pass Standard | Failure Signal | Test Method |
|---|---|---|---|
Defect Attribution Accuracy | The [DEFECT_SECTION] correctly identifies the exact system prompt paragraph, instruction line, or conflicting rule responsible for the observed behavior. | The output blames retrieval, tool failure, or model hallucination when the trace shows clear instruction violation or ambiguity in the system prompt. | Compare against a labeled dataset of 20 traces where the ground-truth defect location is known. Measure exact-match accuracy of the section identifier. |
Trace Evidence Grounding | Every defect claim includes a specific [TRACE_EVIDENCE] excerpt with span ID, timestamp, or log line that directly supports the finding. | The output makes defect claims without trace references, or cites trace spans that do not contain the claimed violation when manually inspected. | For each defect report, verify that every evidence excerpt exists in the source trace and supports the claim. Flag reports where evidence is missing or misattributed. |
Suggested Rewrite Actionability | The [SUGGESTED_REWRITE] is a concrete, drop-in replacement for the offending prompt section that resolves the identified ambiguity or conflict without introducing new issues. | The rewrite is vague, changes unrelated instructions, introduces new contradictions, or cannot be applied without additional engineering interpretation. | Have a second reviewer apply the rewrite to the original prompt and re-run the trace scenario. The defect should not reproduce. Measure rewrite-apply success rate. |
False Positive Rate on Clean Traces | When run against traces with no known prompt defects, the prompt returns a null or empty defect report with confidence below the reporting threshold. | The prompt fabricates a defect, misinterprets correct behavior as an instruction violation, or returns high-confidence false positives on clean traces. | Run against a set of 15 clean traces with verified correct behavior. Measure the false-positive rate. Target: less than 5% false-positive defect reports. |
Confidence Score Calibration | The [CONFIDENCE] score correlates with actual defect presence: high scores for clear violations, low scores for ambiguous cases, and scores below threshold for clean traces. | Confidence scores are uniformly high regardless of evidence strength, or low-confidence reports contain definitive defects that should have scored higher. | Plot confidence scores against ground-truth defect labels across 50 traces. Calculate expected calibration error. Scores should separate defect from non-defect traces with AUC above 0.85. |
Instruction Conflict Detection | When two prompt instructions contradict each other, the output identifies both conflicting sections and explains the contradiction in [CONFLICT_DESCRIPTION]. | The output identifies only one side of the conflict, misses the contradiction entirely, or attributes the failure to a single instruction without noting the conflict. | Seed test traces with known instruction conflicts. Verify that both conflicting sections appear in the report and the conflict description is accurate. Measure conflict recall rate. |
Ambiguity Identification | The output flags vague terms, undefined conditions, or missing decision boundaries in the prompt that could cause inconsistent model behavior. | The output misses documented ambiguities that caused the trace failure, or flags precise instructions as ambiguous without justification. | Use a set of prompts with injected ambiguities. Verify that the report identifies the ambiguous language and explains how it could produce the observed trace behavior. |
Human Review Flag Accuracy | The [REQUIRES_HUMAN_REVIEW] flag is true for all defect reports, and the [REVIEW_RATIONALE] explains what the reviewer should verify before deployment. | The flag is false on a valid defect report, or the rationale is generic and does not guide the reviewer to specific risks in the suggested rewrite. | Audit all defect reports for the human review flag. Verify that the rationale references specific risks, downstream impacts, or edge cases that require human judgment. |
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 a single trace and a single feedback signal. Remove the structured output schema and ask for a plain-text defect hypothesis. Focus on whether the model can correctly identify the offending prompt section.
codeAnalyze this trace and user feedback. Identify if a prompt defect caused the issue. [TRACE] [FEEDBACK] Return the likely prompt section and a one-sentence explanation.
Watch for
- Model hallucinating prompt sections that don't exist
- Conflating retrieval gaps with prompt defects
- Overly broad blame on "system prompt" without specifics

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