This prompt is designed for data engineering, SRE, and operations teams who need an AI system to perform systematic, auditable anomaly investigations. The core job-to-be-done is transforming a raw anomaly alert and its surrounding context into a structured report that includes a ranked list of hypotheses, supporting evidence for each, and a clear chain of investigative reasoning. The ideal user is a developer or operator integrating this prompt into a diagnostic workflow where consistency and resistance to confirmation bias are more critical than sub-second latency. Required context includes the anomaly description, a baseline for normal behavior, and recent relevant telemetry or logs.
Prompt
Anomaly Investigation Chain-of-Thought Prompt

When to Use This Prompt
Learn when a few-shot anomaly investigation prompt is the right tool and when a different approach is required.
You should use this approach when you need every investigation to follow the same rigorous structure, making the outputs comparable and reviewable over time. The few-shot demonstration pattern is particularly effective here because it teaches the model how to think about the problem—generating investigation steps, ranking hypotheses by likelihood, and always comparing against a baseline—more reliably than verbose procedural instructions alone. This is a strong fit for offline or asynchronous investigation of batch-detected anomalies, where a 10-30 second response time is acceptable. It is also appropriate when the cost of a missed or misdiagnosed anomaly is high, justifying a thorough, evidence-based report that an on-call engineer can quickly validate.
Do not use this prompt for real-time alerting systems that require sub-second latency, as the chain-of-thought generation adds non-trivial processing time. It is also the wrong tool when the anomaly is already fully understood and only a notification needs to be sent; in that case, a simpler templated message is more efficient. Avoid this pattern if you cannot provide a reliable baseline for comparison, as the prompt's core instruction to 'compare against a baseline' will lead to hallucinated or meaningless baselines. Finally, while this prompt produces a report, it does not execute remediation steps. The next step after generating this report should be a human review or feeding the structured output into a separate automation runbook.
Use Case Fit
Where the Anomaly Investigation Chain-of-Thought Prompt works and where it introduces risk.
Good Fit: Structured Data Diagnostics
Use when: Investigating anomalies in structured datasets (time-series, SQL tables, CSVs) where statistical baselines exist. Why: The model can reason over explicit metrics, compare to historical norms, and rank hypotheses by likelihood.
Bad Fit: Real-Time Incident Response
Avoid when: The system requires sub-second decisions or is directly coupled to paging infrastructure. Risk: Chain-of-thought reasoning introduces latency and verbosity unsuitable for automated alerts. Guardrail: Use this prompt for post-hoc analysis or on-demand investigation, not as a live triage step.
Required Inputs: Data, Baseline, and Context Window
Risk: The model hallucinates plausible-sounding causes if it lacks raw data. Guardrail: You must provide the anomalous data point, a historical baseline (e.g., rolling average), and the schema definition. Without these, the investigation is speculative fiction.
Operational Risk: Confirmation Bias
Risk: The model latches onto the first plausible hypothesis and ignores contradictory evidence. Guardrail: Explicitly instruct the model to rank multiple hypotheses and provide evidence against the leading hypothesis. Validate with a separate evaluation step.
Operational Risk: Overlooking the Baseline
Risk: The model treats the anomaly as a discrete event without comparing it to seasonal trends or normal variance. Guardrail: The prompt must force a mandatory baseline comparison step before any hypothesis generation.
Domain Constraint: High-Cardinality Dimensions
Risk: The model struggles to isolate root causes in datasets with thousands of distinct entities (e.g., user IDs). Guardrail: Pre-aggregate data to a manageable dimension level before passing it into the prompt to prevent context-window exhaustion and shallow analysis.
Copy-Ready Prompt Template
A reusable prompt that teaches models to perform systematic anomaly investigation through few-shot demonstrations of chain-of-thought reasoning.
This prompt template uses worked examples to transfer a structured investigation pattern to the model. Instead of describing how to investigate anomalies, the examples demonstrate the full reasoning chain: observing the data, forming ranked hypotheses, gathering evidence for each, and delivering a final assessment. The square-bracket placeholders let you swap in your own data schema, risk level, and domain-specific examples without rewriting the reasoning structure. For high-stakes domains like finance, healthcare, or security operations, always route the final assessment through human review before taking action.
textYou are an anomaly investigation analyst. When presented with data, you will investigate systematically by following a reasoning pattern demonstrated in the examples below. Do not jump to conclusions. Work through investigation steps, form multiple hypotheses, rank them by likelihood, and cite specific evidence before delivering your final assessment. [EXAMPLES] --- Now apply the same systematic investigation pattern to the following data: [DATA] Data schema: [DATA_SCHEMA] Investigation constraints: [CONSTRAINTS] Risk level: [RISK_LEVEL] Output format: [OUTPUT_SCHEMA] Begin your investigation.
Adapting the template: Replace [EXAMPLES] with 2-4 worked demonstrations that show the full reasoning chain for your domain. Each example should include the raw data, the step-by-step investigation, multiple hypotheses with likelihood rankings, evidence for and against each hypothesis, and a final assessment. The [DATA_SCHEMA] placeholder should describe your data fields, units, and expected ranges so the model knows what normal looks like. Set [RISK_LEVEL] to low, medium, high, or critical to adjust the investigation depth and caution language. The [OUTPUT_SCHEMA] should specify the exact structure you need, such as JSON with fields for investigation_steps, hypotheses, evidence, ranked_findings, and final_assessment. For production use, validate the output against this schema before surfacing results to users or downstream systems. If the model skips investigation steps or produces only one hypothesis, treat that as a validation failure and retry with stronger constraint language or additional negative examples showing incomplete investigations.
Prompt Variables
Inputs the Anomaly Investigation Chain-of-Thought Prompt needs to work reliably. Each placeholder 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.
| Placeholder | Purpose | Example | Validation Notes |
|---|---|---|---|
[METRIC_NAME] | The specific metric or KPI being investigated for anomalous behavior. | daily_active_users | Must be a non-empty string. Check against a known metric catalog if available. Reject generic terms like 'something' or 'the number'. |
[METRIC_VALUE] | The observed value of the metric at the point of anomaly. | 12543 | Must be a numeric value. Parse as float or int. If the value is null or non-numeric, the prompt should not be executed; request a valid number from the user. |
[BASELINE_VALUE] | The expected or historical baseline value for comparison. | 9800 | Must be a numeric value. Compare with [METRIC_VALUE] to ensure a meaningful delta exists. If the baseline is older than the defined lookback window, flag for staleness. |
[TIME_WINDOW] | The specific time period or granularity of the observation. | 2024-05-12T14:00:00Z to 2024-05-12T15:00:00Z | Must be a valid ISO 8601 datetime range or a recognized relative alias like 'last_hour'. Reject ambiguous strings like 'recently'. |
[CONTEXTUAL_EVENTS] | A list of known events (deployments, campaigns, outages) that occurred in or near the time window. | ['v2.3.1 deploy at 13:45 UTC', 'Email campaign #4521 sent at 14:00 UTC'] | Must be a valid JSON array of strings. An empty array is acceptable. If an event string contains PII or secrets, redact it before insertion. |
[SEGMENT_FILTER] | Optional dimension or segment to scope the investigation (e.g., region, device type). | region: 'us-east-1' | If provided, must be a non-empty string in 'key: value' format. If null, the investigation is global. Validate that the segment key exists in the data source schema. |
[INVESTIGATION_DEPTH] | Controls the level of detail and number of hypotheses generated. | 'deep' | Must be one of a predefined enum: 'quick', 'standard', or 'deep'. Default to 'standard' if not provided. Reject any other string to prevent prompt injection or unexpected behavior. |
Implementation Harness Notes
How to wire the Anomaly Investigation CoT prompt into an incident management bot or data pipeline with validation, retries, and human review.
This prompt is designed to be called programmatically by an incident management bot or a data pipeline, not as a one-off chat interaction. The system sending the prompt must construct the [INPUT] with structured telemetry, the [CONTEXT] with historical baselines and recent changes, and the [OUTPUT_SCHEMA] as a strict JSON schema. The model's response must be parsed as JSON and stored as a timestamped entry in the incident timeline. Never expose the raw model output directly to a status page or customer-facing communication without validation and, for high-severity incidents, human review.
Implement a retry wrapper around the model call that validates the parsed JSON for the presence and type of two critical fields: investigation_steps (must be a non-empty array of strings) and ranked_hypotheses (must be a non-empty array of objects, each with hypothesis, likelihood, and supporting_evidence fields). If the model fails to produce valid JSON or these required fields are missing or incorrectly typed, retry once with a stricter system message that explicitly states: 'You MUST respond with ONLY a valid JSON object containing the keys "investigation_steps" and "ranked_hypotheses". No other text is permitted.' Log the raw prompt and the raw completion for every attempt to ensure auditability and to enable prompt debugging if failures persist. Do not implement infinite retries; after one retry, escalate the failure to an on-call engineer with the logged context.
For incidents classified as sev-0 or sev-1 in the triggering system, the validated and parsed output must be routed to a human on-call for review via a Slack message, PagerDuty alert, or a dedicated review queue. The human should approve, edit, or reject the hypotheses before any summary is posted to an internal or external status page. Under no circumstances should the model's output be used to automatically execute remediation steps, runbooks, or infrastructure changes. The model's role is strictly analytical: it proposes investigation paths and hypotheses, but a human operator or a deterministic, pre-approved script must decide and act on them.
When wiring this into a data pipeline, ensure the [INPUT] placeholder is populated with a structured object containing the anomaly's time window, affected metrics, deviation magnitude, and a link to the relevant dashboard. The [CONTEXT] should be assembled by querying a feature store or metrics database for the 7-day baseline average, the most recent deployment timestamps, and any currently open incidents. This assembly logic should live in the application layer, not in the prompt. After the validated output is stored, trigger a follow-up evaluation step that checks whether the ranked_hypotheses list includes a comparison to the baseline period; if it does not, flag the output for a potential confirmation bias failure mode and append a note to the incident timeline.
Expected Output Contract
Defines the strict JSON schema for the anomaly investigation output. Use this contract to validate the model's response before passing it to downstream systems or human reviewers.
| Field or Element | Type or Format | Required | Validation Rule |
|---|---|---|---|
anomaly_id | string | Must match the [ANOMALY_ID] input exactly. No modification allowed. | |
investigation_summary | string | Must be a single sentence under 200 characters. Cannot contain markdown or newlines. | |
hypotheses | array of objects | Array must contain 2-5 items. Each item must validate against the hypothesis schema. | |
hypotheses[].rank | integer | Sequential integer starting at 1. No duplicates or gaps. | |
hypotheses[].statement | string | Must be a single, falsifiable sentence. Cannot be a question or a generic observation. | |
hypotheses[].likelihood | string | Must be one of the enum values: High, Medium, Low. Case-sensitive. | |
hypotheses[].supporting_evidence | array of strings | Array must contain 1-3 items. Each string must reference a specific metric, log, or event from the [CONTEXT]. | |
hypotheses[].confirmation_bias_check | string | Must be a single sentence describing a specific data point that would disprove the hypothesis. Cannot be null or empty. | |
recommended_actions | array of strings | Array must contain 1-4 items. Each string must start with an imperative verb (e.g., Check, Query, Compare). | |
baseline_comparison | object | Must contain 'period' and 'value' keys. 'value' must be a numeric string or null if no baseline exists. | |
escalation_required | boolean | Must be true if any hypothesis has a likelihood of High and the anomaly impacts a revenue-critical metric. Otherwise false. |
Common Failure Modes
Anomaly investigation prompts fail in predictable ways. These cards cover the most common failure modes, why they happen, and the specific guardrails that prevent them in production.
Confirmation Bias in Hypothesis Ranking
What to watch: The model latches onto the first plausible hypothesis and ranks supporting evidence higher while ignoring contradictory signals. This is especially dangerous when the prompt's worked examples all follow a single investigation path. Guardrail: Include a counterexample in the few-shot set that explicitly shows an initial hypothesis being demoted when contradictory evidence appears. Add a mandatory step: 'List evidence that contradicts each hypothesis before ranking.'
Missing Baseline Comparisons
What to watch: The model declares an anomaly without comparing the observed value to any historical baseline, seasonal expectation, or control group. The investigation reads as confident but is statistically hollow. Guardrail: Require a structured output field for 'baseline comparison' that must be populated or explicitly marked as unavailable. In the prompt template, add: 'If no baseline is available, state this limitation and downgrade confidence.'
Over-Decomposition into Unverifiable Steps
What to watch: The chain-of-thought produces investigation steps that sound rigorous but cannot be executed because the required data, tools, or access don't exist. The model invents plausible-sounding but fictional diagnostic procedures. Guardrail: Constrain the investigation steps to a pre-declared tool list or data schema. Add a validator that flags any step referencing a tool or data source not in the approved inventory. Use the instruction: 'Only propose investigation steps that use the available tools listed in [TOOL_LIST].'
Premature Root Cause Closure
What to watch: The model converges on a root cause after only one or two investigation steps, skipping differential diagnosis and alternative explanations. This produces fast but fragile conclusions. Guardrail: Enforce a minimum number of hypotheses in the output schema. Add a few-shot example where the correct answer requires investigating and eliminating three alternatives before concluding. Use the constraint: 'Generate at least [MIN_HYPOTHESES] ranked hypotheses before selecting a primary root cause.'
Evidence-to-Claim Mismatch
What to watch: The model cites a piece of evidence that does not actually support the claim it's attached to, or the evidence is too vague to be probative. This is a subtle hallucination pattern where the structure looks correct but the logical chain is broken. Guardrail: Add an evaluation step after generation that checks each evidence-claim pair for relevance and sufficiency. In the prompt, include a demonstration of rejecting weak evidence: 'Evidence X is insufficient to support Claim Y because [REASON]. This claim requires further investigation.'
Normal Fluctuation Misclassified as Anomaly
What to watch: The model treats expected variance, noise, or known cyclical patterns as anomalies requiring investigation. This generates alert fatigue and wastes investigative effort on false positives. Guardrail: Include a pre-investigation classification step: 'First, determine if this observation falls within expected bounds given [HISTORICAL_RANGE] and [SEASONALITY_MODEL]. If yes, classify as expected variance and stop.' Add a few-shot example where the correct answer is 'no anomaly — within normal range.'
Evaluation Rubric
Run these checks on a golden dataset of 20-30 historical anomalies with known root causes. Each row defines a pass/fail criterion for the investigation output.
| Criterion | Pass Standard | Failure Signal | Test Method |
|---|---|---|---|
Root Cause Identification | Primary root cause matches the known cause in the golden dataset | Output blames a symptom instead of the cause or identifies a cause not supported by the provided data | Exact match against golden label; partial credit if cause is in top-3 ranked hypotheses |
Hypothesis Ranking | Top-ranked hypothesis is the correct root cause | Correct cause is ranked third or lower, or is absent from the hypothesis list entirely | Check rank position of the known cause in the ordered hypothesis list |
Evidence Grounding | Every hypothesis cites at least one specific data point, timestamp, or metric from [INPUT_DATA] | Hypothesis contains unsupported claims, vague references like 'recent changes', or hallucinated metrics not present in the input | LLM-as-judge check: does each claim map to a field in the provided data payload? |
Baseline Comparison | Output explicitly compares the anomaly window to a stated baseline period | No baseline period is mentioned, or the comparison uses an inappropriate baseline (e.g., comparing weekday to weekend without noting the difference) | Keyword check for baseline language; verify the baseline window is reasonable for the metric type |
Confirmation Bias Check | Output includes at least one alternative hypothesis that was considered and rejected with a reason | Output presents only supporting evidence for the top hypothesis with no mention of contradictory signals or alternatives | Count of rejected hypotheses with explicit rejection rationale; minimum 1 required |
Investigation Step Completeness | Output contains 3-7 discrete, ordered investigation steps before the final conclusion | Output jumps directly to a conclusion without intermediate steps, or steps are circular and non-actionable | Parse step count; verify each step contains an action verb and a specific data source to check |
Uncertainty Calibration | Confidence language matches the strength of evidence; low-evidence conclusions use hedging | Output expresses high confidence for a conclusion supported by a single weak signal or correlation | Human review or LLM judge: compare stated confidence to number and quality of evidence points cited |
Output Schema Compliance | Output is valid JSON matching [OUTPUT_SCHEMA] with all required fields present and correctly typed | Missing required fields, incorrect types, or extra text outside the JSON structure | Automated schema validation against the defined JSON Schema; reject on parse failure or missing required fields |
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 worked example and lighter validation. Focus on getting the reasoning trace shape right before adding production constraints.
- Start with one canonical anomaly example showing the full chain-of-thought: initial observation → baseline comparison → hypothesis generation → evidence ranking → conclusion.
- Remove strict schema enforcement; accept free-text reasoning traces.
- Use a frontier model (GPT-4o, Claude 3.5 Sonnet) with default temperature.
Watch for
- Confirmation bias: the model latches onto the first plausible hypothesis without exploring alternatives.
- Missing baseline comparisons: the reasoning skips "compared to what" steps.
- Overly broad investigation scope without narrowing to actionable hypotheses.

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