Inferensys

Prompt

Compliance Rule Violation Root-Cause Prompt

A practical prompt playbook for using Compliance Rule Violation Root-Cause Prompt in production AI workflows.
Compliance officer monitoring AI compliance agent on laptop, policy dashboards visible, modern WeWork desk setup.
PROMPT PLAYBOOK

When to Use This Prompt

Identify the exact pipeline step that introduced a compliance violation using a structured trace log, the violated rule, and the flagged model output.

This prompt is designed for compliance reviewers and AI reliability engineers who need to produce an audit-ready root-cause report after an automated compliance evaluation flags a production response. The job-to-be-done is forensic: you have a structured trace log that records every step of a request's lifecycle (retrieval, tool calls, context assembly, generation), the text of the specific regulatory or policy rule that was violated, and the final model output that triggered the eval failure. Your goal is not to fix the prompt or block the response in real time, but to trace the violation back to its origin—whether that is a retrieval step that pulled in a prohibited document, a tool call that returned non-compliant data, a context assembly step that dropped a required disclaimer, or the generation step itself that produced a violative claim. The prompt performs a rule-by-rule trace analysis, mapping each segment of the trace against the rule's requirements and identifying the first point of failure with preserved evidence for audit review.

To use this prompt effectively, you must have three inputs ready: [TRACE_LOG] containing step-level events with timestamps, inputs, outputs, and metadata; [VIOLATED_RULE] with the exact rule text, its regulatory or policy source, and any interpretive guidance; and [FLAGGED_OUTPUT] which is the final model response that failed the compliance eval. The prompt assumes the trace log is structured and complete—it will not fill gaps or infer missing steps. It also assumes you are operating in a post-hoc investigation context, not a real-time blocking pipeline. Do not use this prompt for initial policy design, for deciding whether to block a request in production, or when you lack a structured trace log. For high-risk regulated domains (finance, healthcare, legal), the output of this prompt should be treated as an investigative aid, not a final determination. Always require human review of the root-cause report before it becomes part of an audit record or regulatory submission.

The prompt's output is a structured root-cause report that identifies the violation point (the specific trace step where the rule was first breached), the evidence chain (the inputs and outputs at that step that demonstrate the violation), a severity classification (critical, major, minor), and a recommended remediation (e.g., add a retrieval filter, adjust a tool contract, insert a generation guardrail). The report is designed to be audit-ready: it preserves the exact trace evidence, rule text, and output that triggered the investigation, so a human reviewer can independently verify the finding. After receiving the report, your next step should be to validate the identified violation point against the raw trace data, then determine whether the remediation requires a prompt change, a pipeline change, or a policy update. Avoid using this prompt when the trace log is incomplete or when the rule text is ambiguous without interpretive guidance—in those cases, escalate to a human compliance expert before running the analysis.

PRACTICAL GUARDRAILS

Use Case Fit

Where this prompt works and where it does not. Use these cards to quickly assess whether the Compliance Rule Violation Root-Cause Prompt is the right tool for your investigation before investing time in a full trace review.

01

Good Fit: Regulatory Audit Trails

Use when: you need a rule-by-rule trace analysis for a known compliance violation with complete trace data available. Guardrail: the prompt requires structured trace logs with step-level attribution; do not run it on summarized or aggregated data.

02

Bad Fit: Real-Time Blocking Decisions

Avoid when: you need a sub-second decision on whether to block a transaction. Guardrail: this prompt is designed for post-hoc investigation, not inline enforcement. Use a classification router for real-time decisions and reserve this for audit review.

03

Required Input: Complete Trace Data

Risk: running the prompt on incomplete traces produces false negatives, missing the true root cause. Guardrail: validate that the trace includes system prompt, user input, tool calls, retrieved context, and final output before invoking the analysis. Reject traces with gaps.

04

Operational Risk: Evidence Preservation

Risk: the prompt's output becomes part of the audit record, so errors in the analysis can compound compliance exposure. Guardrail: always store the raw trace alongside the prompt output. Never let the analysis replace the original evidence. Human review is required before any regulatory submission.

05

Scope Boundary: Known Violations Only

Avoid when: you are scanning for unknown violations across a large dataset. Guardrail: this prompt requires a specific eval failure or known rule violation as input. For broad detection, use a separate compliance scanning prompt first, then route flagged cases here for root-cause analysis.

06

Model Fit: Strong Reasoning Required

Risk: weaker models may hallucinate causal links between trace steps and the violation. Guardrail: use a model with strong reasoning capabilities and a large context window. For high-stakes audits, run the analysis with two independent models and compare outputs before finalizing findings.

PROMPT PLAYBOOK

Copy-Ready Prompt Template

Paste this template into your investigation notebook or automated analysis pipeline. Replace the square-bracket placeholders with data from your production trace and compliance system.

This template is designed to be the single executable prompt you use to investigate a compliance rule violation. It forces a structured, rule-by-rule analysis of the entire production trace, ensuring that no step in the pipeline is overlooked. The output is designed to be preservation-ready for audit review, linking every finding to a specific trace event and source document. Before using this prompt, ensure you have exported the full trace from your observability platform, including system prompts, retrieved context, tool calls, and the final output. This prompt is not a substitute for a human compliance reviewer; it is a diagnostic tool to accelerate their investigation and standardize evidence collection.

text
You are a senior compliance review analyst. Your task is to perform a root-cause analysis of a single production trace that violated one or more compliance rules.

## INPUT DATA
- **Trace ID:** [TRACE_ID]
- **Violated Rules:** [LIST_OF_VIOLATED_RULE_IDS_AND_DESCRIPTIONS]
- **Full Trace Log:** [FULL_TRACE_JSON]
- **Applicable Policy Documents:** [POLICY_DOCUMENT_TEXT_OR_REFERENCE]

## ANALYSIS INSTRUCTIONS
For each violated rule in [LIST_OF_VIOLATED_RULE_IDS_AND_DESCRIPTIONS], perform the following steps. Document your findings in the `rule_analyses` array of the output JSON.

1.  **Rule Definition:** Restate the specific compliance rule that was violated, quoting the relevant text from [POLICY_DOCUMENT_TEXT_OR_REFERENCE].
2.  **Violation Manifestation:** Quote the exact segment of the final model output or action that constitutes the violation.
3.  **Trace Event Attribution:** Identify the single most likely trace event (e.g., a specific tool call, a retrieved document chunk, a turn in the conversation) that introduced the violation. Provide the event's timestamp and a brief description.
4.  **Causal Chain:** Construct a step-by-step causal chain from the attributed trace event to the violation manifestation. Explain *how* the event led to the violation.
5.  **Evidence Preservation:** List all trace event IDs, document chunk IDs, and timestamps that serve as evidence for this causal chain. This is critical for audit review.
6.  **Severity Assessment:** Classify the violation's severity as `CRITICAL`, `HIGH`, `MEDIUM`, or `LOW` based on the policy's definitions and the potential impact.

## CONSTRAINTS
- **Evidence Grounding:** Every claim in your analysis MUST be directly supported by a specific event in [FULL_TRACE_JSON]. Do not speculate about model intent or external factors not present in the trace.
- **No New Violations:** Your analysis must not introduce or discuss potential violations beyond those provided in [LIST_OF_VIOLATED_RULE_IDS_AND_DESCRIPTIONS].
- **Audit-Ready Language:** Use precise, objective language. Avoid marketing jargon, anthropomorphism, and vague terms like "the model hallucinated" without linking it to a specific trace event.
- **Structured Output Only:** Your entire response must be a single, valid JSON object conforming to the schema below. Do not include any text outside the JSON.

## OUTPUT_SCHEMA
{
  "trace_id": "string",
  "analysis_timestamp": "string (ISO 8601)",
  "rule_analyses": [
    {
      "rule_id": "string",
      "rule_definition": "string",
      "violation_manifestation": "string (exact quote from output)",
      "attributed_trace_event": {
        "event_id": "string",
        "timestamp": "string",
        "description": "string"
      },
      "causal_chain": "string (step-by-step explanation)",
      "evidence_event_ids": ["string"],
      "severity_assessment": "CRITICAL | HIGH | MEDIUM | LOW"
    }
  ],
  "overall_summary": "string (a brief, factual summary of the root cause(s) across all violations)"
}

To adapt this template, start by integrating it with your observability platform's API. The [FULL_TRACE_JSON] placeholder should be populated programmatically with a structured trace object, not a raw log dump. Ensure your trace export includes all necessary spans: system prompt rendering, retrieval calls with scores, LLM calls with token usage, and any tool or API requests. The [POLICY_DOCUMENT_TEXT_OR_REFERENCE] should contain the exact text of the rules that were violated, not just a link. This grounds the model's analysis in the specific policy language. For high-risk compliance environments, the output of this prompt should always be routed to a human review queue. The JSON output is designed to be parsed and displayed in a review tool, allowing a human to quickly validate the causal chain and evidence before accepting the analysis. Never automatically close a compliance incident based solely on this prompt's output.

IMPLEMENTATION TABLE

Prompt Variables

Inputs the Compliance Rule Violation Root-Cause Prompt needs to produce a rule-by-rule trace analysis. Each placeholder must be populated with structured data extracted from the production trace and eval system before invoking the prompt.

PlaceholderPurposeExampleValidation Notes

[VIOLATION_SUMMARY]

Brief description of the compliance rule that was violated, as reported by the eval system

Rule FIN-04: Response provided investment advice without required disclaimer

Must be a non-empty string. Should match a known rule ID in the compliance registry. Null not allowed.

[RULE_TEXT]

The full text of the compliance rule or policy that was violated

Do not provide specific investment recommendations or predict future market movements without stating that past performance does not guarantee future results.

Must be a non-empty string. Should be the authoritative rule text from the policy document, not a paraphrase. Schema check: string, min length 20 chars.

[FULL_OUTPUT]

The complete model response that triggered the eval failure

Based on your portfolio, I recommend increasing your allocation to tech ETFs. The sector has shown 15% YoY growth and this trend should continue.

Must be a non-empty string. Should be the raw, unredacted output exactly as logged in the trace. Null not allowed. If output was truncated in trace, flag as incomplete evidence.

[TRACE_STEPS]

Ordered list of trace events with step-level detail: system prompt segment, retrieval results, tool calls, reasoning tokens, and generation steps

[{"step": 1, "type": "retrieval", "content": "...", "timestamp": "..."}, {"step": 2, "type": "generation", "content": "..."}]

Must be a valid JSON array of step objects. Each step requires type, content, and timestamp fields. Minimum 1 step. Schema validation required before prompt invocation. If trace is incomplete, flag as partial evidence.

[EVAL_RUBRIC_SNIPPET]

The specific eval criteria or rubric dimension that flagged the violation

response_contains_investment_advice: true if output recommends specific securities or predicts market direction without disclaimer

Must be a non-empty string. Should be the exact rubric text from the eval configuration. If rubric is unavailable, use 'RUBRIC_NOT_CAPTURED' and note that root-cause confidence will be reduced.

[CONTEXT_WINDOW_SNAPSHOT]

The full context window contents at the time of generation, including system prompt, retrieved documents, and conversation history

System: You are a financial assistant. Do not provide investment advice... User: Should I buy more tech stocks? Assistant: ...

Must be a non-empty string. Should capture the exact token sequence sent to the model. If context window exceeds capture limits, note truncation and flag missing prefix or suffix. Null allowed only if trace system does not capture context windows.

[HUMAN_REVIEW_FLAG]

Boolean indicating whether this violation requires mandatory human review before the root-cause analysis is considered final

Must be true or false. Set to true for regulated domains, high-severity violations, or when trace evidence is incomplete. If null, default to true for safety. This flag gates whether the analysis proceeds to automated remediation or awaits approval.

PROMPT PLAYBOOK

Implementation Harness Notes

How to wire the Compliance Rule Violation Root-Cause Prompt into a production observability pipeline with validation, retries, and audit-ready evidence preservation.

This prompt is designed to be invoked programmatically as part of an automated compliance review pipeline, not as a one-off chat interaction. The typical integration point is a post-eval hook: when a compliance eval flags a response as a violation, the system retrieves the full trace for that request and calls this prompt with the trace, the violated rule, and the eval output. The prompt's structured output—a rule-by-rule trace analysis—is then written to an audit log and surfaced in a compliance review queue. Do not use this prompt for real-time blocking decisions; it is a diagnostic and evidence-preservation tool, not a gate.

Input assembly requires three data sources wired together before the prompt is called: (1) the full production trace including system prompt, retrieved context, tool calls, intermediate reasoning steps, and final output; (2) the specific compliance rule definition that was violated, including its policy text and eval criteria; and (3) the eval result that triggered the investigation, including the score, the violating excerpt, and any judge rationale. These should be assembled into the [TRACE_DATA], [COMPLIANCE_RULE], and [EVAL_RESULT] placeholders respectively. For high-risk regulated domains, also include [EVIDENCE_SOURCES] with links to the original documents or knowledge base entries that the model was supposed to follow.

Validation and retry logic must be applied to the prompt's output before it enters the audit record. Parse the JSON output and validate that every identified violation step includes a trace_event_id that matches an actual event in the input trace. If the output references trace events that don't exist, or if the evidence_preserved field is empty for a confirmed violation, reject the output and retry with a stronger instruction to ground every claim in trace event IDs. Set a maximum of two retries; if the prompt still produces ungrounded output, escalate to a human reviewer with the raw trace and eval result attached. Log every retry and escalation for observability into the compliance pipeline itself.

Model choice matters for this workflow. Use a model with strong instruction-following and long-context reasoning capabilities—GPT-4o, Claude 3.5 Sonnet, or Gemini 1.5 Pro are appropriate. The trace data can be long, so ensure the model's context window can accommodate the full trace plus the prompt. If traces exceed the context window, preprocess by extracting only the steps relevant to the violated rule's domain (e.g., for a data-handling violation, include retrieval steps, output generation, and any tool calls that touched user data; exclude unrelated planning steps). Do not summarise the trace before passing it—the prompt needs step-level detail to isolate root causes.

Audit trail integration is the final step. After validation passes, store the prompt's output alongside the original trace, eval result, and any human review decisions in an immutable audit log. The output's evidence_preserved field should contain direct quotes from the trace that a compliance auditor can verify without re-running the prompt. If the prompt identifies a root cause that requires remediation—such as a system prompt that contradicts a compliance rule—create a ticket in the prompt versioning system and link it to the audit record. Never auto-apply prompt changes based on this analysis; always require human approval for any change that affects compliance posture.

IMPLEMENTATION TABLE

Expected Output Contract

Defines the structured output schema for the compliance rule violation root-cause analysis. Use this contract to validate the model's response before presenting it to a reviewer or writing it to an audit log.

Field or ElementType or FormatRequiredValidation Rule

analysis_id

string (UUID v4)

Must be a valid UUID v4 generated for this specific analysis run. Reject if missing or not a valid UUID.

trace_id

string

Must match the [TRACE_ID] input exactly. Reject on mismatch or if null.

violation_summary

object

Must contain 'rule_id' (string), 'rule_description' (string), and 'severity' (enum: critical, high, medium, low). Reject if any sub-field is missing or if severity is not in the enum.

root_cause_step

object

Must contain 'step_type' (enum: system_prompt, retrieval, tool_call, llm_generation, user_input, post_processing), 'step_id' (string), and 'timestamp' (ISO 8601). Reject if step_type is not in the enum or timestamp is invalid.

causal_chain

array of objects

Each object must have 'sequence_order' (integer), 'step_description' (string), 'evidence_snippet' (string), and 'trace_reference' (string). Array must not be empty. Reject if sequence_order is not monotonically increasing from 1.

evidence_preservation

array of objects

Each object must have 'evidence_type' (enum: input_log, retrieved_document, tool_response, model_output, config_snapshot), 'content' (string), and 'preservation_note' (string). Reject if evidence_type is not in the enum or content is empty.

remediation_recommendation

string

Must be a non-empty string between 50 and 1000 characters. Reject if length is outside bounds or if it contains only whitespace.

human_review_required

boolean

Must be true or false. If severity is 'critical', this field must be true. Reject if boolean type mismatch or if critical severity has human_review_required set to false.

PRACTICAL GUARDRAILS

Common Failure Modes

When diagnosing compliance rule violations, the prompt often fails because the trace is incomplete, the rule definition is ambiguous, or the model confuses correlation with causation. These cards cover the most frequent failure patterns and how to prevent them.

01

Missing Trace Context

What to watch: The prompt receives a trace with missing steps—truncated tool outputs, absent retrieval calls, or dropped user turns. The model invents a plausible root cause instead of flagging the gap. Guardrail: Pre-process traces to inject [STEP_MISSING] markers for any gap. Add a hard constraint: 'If any step in the pipeline is missing from the trace, state that the root cause is indeterminate and list the missing steps.'

02

Ambiguous Rule Definitions

What to watch: The compliance rule is written in policy language ('ensure data is handled appropriately'), not in verifiable conditions. The model hallucinates a violation or misses a real one because the boundary is unclear. Guardrail: Require rules to be provided as a structured schema with rule_id, condition (verifiable predicate), and evidence_required fields. If a rule cannot be expressed this way, flag it for human clarification before analysis.

03

Correlation Mistaken for Causation

What to watch: The model observes that a violation appeared after a specific tool call or retrieval step and confidently labels that step as the root cause, ignoring earlier contributing events. Guardrail: Require a causal chain format: 'For each violation, list all contributing trace events in chronological order. Mark the earliest event that introduced the violation condition as the primary cause. If multiple events are necessary, list all.'

04

Evidence Drift in Audit Trail

What to watch: The model paraphrases or summarizes evidence instead of quoting it verbatim, introducing subtle meaning shifts that undermine audit defensibility. Guardrail: Constrain the output schema to require source_quote fields that contain exact strings from the trace. Add a post-processing check that each quote appears verbatim in the source trace before the analysis is accepted.

05

Over-Confident Single-Factor Attribution

What to watch: The model attributes a complex violation to a single step (e.g., 'the retrieval returned wrong documents') when the violation required multiple failures across retrieval, ranking, and generation. Guardrail: Require a contributing_factors array with a confidence score per factor. Add a validation rule: if only one factor is listed with high confidence, prompt the model to re-examine whether upstream or downstream steps also contributed.

06

Rule Siloing Across Pipeline Steps

What to watch: The model checks each pipeline step against the compliance rule in isolation, missing that a violation emerged from the interaction between steps (e.g., a PII redaction step passed, but a downstream summarization step re-exposed the data). Guardrail: Add a cross-step analysis requirement: 'After checking each step individually, re-examine the full trace for violations that span multiple steps. Flag any case where a downstream step undid or bypassed an upstream control.'

IMPLEMENTATION TABLE

Evaluation Rubric

Use this rubric to test the output of the Compliance Rule Violation Root-Cause Prompt before integrating it into an automated review pipeline. Each criterion maps to a specific quality dimension required for audit-grade trace analysis.

CriterionPass StandardFailure SignalTest Method

Rule-by-Rule Traceability

Each violated rule is mapped to a specific trace step ID with a timestamp.

Output lists violations without linking them to discrete trace events or step identifiers.

Parse output for a violation-to-step mapping structure. Confirm each mapping contains a valid step ID from the input trace.

Evidence Preservation

For every violation, the exact input, output, or tool-call payload that triggered the rule is quoted verbatim.

Violations are described in summary without quoting the offending content from the trace.

Extract quoted evidence blocks. Verify each block is a substring match against the provided trace data.

Pipeline Stage Attribution

The stage of introduction is correctly classified as one of: system prompt, retrieval, tool call, user input, or generation.

The stage is missing, ambiguous, or attributed to a stage not present in the trace.

Validate the stage field against a controlled vocabulary. Cross-reference the attributed stage with the trace event type at the linked step ID.

Compliance Rule Reference

Each finding references the specific compliance rule ID from [RULES] that was violated.

Findings describe a violation in natural language without citing the rule ID or misattribute a rule.

Check that every finding block contains a rule ID field and that the ID exists in the provided [RULES] schema.

Severity Classification Accuracy

Severity is assigned as Critical, High, Medium, or Low and aligns with the rule definition in [RULES].

Severity is missing, uses a non-standard label, or contradicts the severity defined in the rule's metadata.

Compare the output severity for each finding against the expected severity in the [RULES] input. Flag mismatches.

Audit-Ready Output Structure

Output is valid JSON conforming to [OUTPUT_SCHEMA] with no missing required fields.

Output is malformed JSON, missing required fields like violation_id or trace_step_id, or contains extra unvalidated commentary.

Validate output against the [OUTPUT_SCHEMA] using a JSON Schema validator. Reject on any schema violation.

No Speculation

If the trace evidence is insufficient to confirm a violation, the finding is flagged with confidence: low and requires_human_review: true.

The output asserts a violation with high confidence based on inference rather than explicit trace evidence.

Scan all findings for confidence: high or medium. For each, manually verify that the quoted evidence explicitly demonstrates the rule violation without requiring inference.

ADAPTATION OPTIONS

Adapt This Prompt

How to adapt

Use the base prompt with a single trace and a simplified rule set. Focus on getting the model to produce a structured violation timeline before adding strict schema enforcement. Replace [RULES] with 2-3 policy rules and [TRACE] with a single production trace log.

Watch for

  • The model summarizing instead of tracing step-by-step
  • Missing evidence citations for each rule violation claim
  • Overly broad instructions that produce vague root-cause statements
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.