Inferensys

Prompt

Session Replay Incident Reconstruction Prompt

A practical prompt playbook for using Session Replay Incident Reconstruction Prompt in production AI workflows.
Developer doing prompt engineering on laptop, prompt variations visible on screen, casual coding session.
PROMPT PLAYBOOK

When to Use This Prompt

Defines the specific incident forensics job this prompt solves and the boundaries where it should not be applied.

This prompt is purpose-built for incident responders who need to reconstruct a specific user session from raw production trace data to understand its role in a broader incident. The core job-to-be-done is producing a single, unified timeline that overlays user session events, incident markers from external sources (such as monitoring alerts, deployment logs, or infrastructure events), and a clear impact assessment. The ideal user is an on-call engineer or SRE who already has a session ID tied to an incident and access to raw trace spans from an observability platform like Datadog, Honeycomb, or OpenTelemetry collectors. The required context includes the raw trace data for that session, the incident timeline from other systems, and the specific incident markers that define the investigation's boundaries.

Do not use this prompt for general session replay, product analytics, or user experience research. It is not designed for broad pattern discovery across many sessions, nor for generating aggregate metrics about user behavior. The prompt assumes a focused forensic context: a known incident, a known session, and a need to align that session's events with an external incident timeline. Using it outside this scope will produce verbose, misaligned output that confuses forensic analysis with general observability. The prompt also requires that the incident timeline from other sources is available as input; without it, the reconstruction cannot validate alignment and the output will lack the critical overlay that makes it useful for incident response.

Before using this prompt, confirm that you have the session ID, the raw trace spans, and the incident markers from your monitoring or deployment systems. If any of these inputs are missing, the reconstruction will be incomplete and the impact assessment will be unreliable. After running the prompt, validate the output by checking that all incident markers are correctly positioned relative to session events and that no trace spans were omitted. The next step is typically to use this reconstructed timeline to determine whether the session was a cause, a victim, or an unrelated bystander in the incident, which will guide your remediation decisions.

PRACTICAL GUARDRAILS

Use Case Fit

Where this prompt works and where it does not. Use these cards to decide if the Session Replay Incident Reconstruction Prompt is the right tool for your current investigation.

01

Good Fit: Correlating User Sessions with Known Incidents

Use when: you have a confirmed production incident with a defined time window and need to reconstruct exactly what an affected user experienced. Guardrail: always cross-reference the reconstructed timeline against independent incident markers (deployment timestamps, alert fires) to confirm alignment.

02

Bad Fit: Exploratory Browsing Without an Incident Anchor

Avoid when: you are casually browsing traces without a specific incident ID, time range, or user report. The prompt requires incident markers to produce a meaningful reconstruction. Guardrail: use a general trace review or session replay prompt instead when no incident is declared.

03

Required Inputs: Trace Data and Incident Markers

What you must provide: a complete user session trace (all spans, tool calls, model responses) and at least one incident marker (timestamp, error signature, or alert ID). Guardrail: validate that the trace is complete before reconstruction—missing spans will produce gaps in the timeline that can mislead root-cause analysis.

04

Operational Risk: Reconstruction Drift from Partial Data

What to watch: if the trace data is incomplete, truncated, or sampled, the reconstructed timeline may diverge from what actually happened. Guardrail: flag every gap in the trace explicitly in the output and assign a confidence score to each reconstructed segment so reviewers know where uncertainty exists.

05

Operational Risk: False Attribution to the Wrong Root Cause

What to watch: the prompt may attribute the incident to a visible trace event (e.g., a tool timeout) when the real cause is upstream (e.g., a deployment that changed retrieval behavior). Guardrail: require the output to list alternative hypotheses and note what trace evidence would be needed to confirm or rule out each one.

06

Process Fit: Incident Response Workflows

Use when: the reconstruction will feed directly into an incident postmortem, root-cause analysis, or stakeholder briefing. Guardrail: always have a second responder review the reconstruction before it enters the official incident record. The prompt accelerates investigation but does not replace human judgment in high-severity incidents.

PROMPT PLAYBOOK

Copy-Ready Prompt Template

A ready-to-use prompt for reconstructing a user session from trace data during an incident, with placeholders for your specific trace, incident markers, and output requirements.

This prompt template is designed for incident responders who need to reconstruct a specific user session from production trace data and align it with known incident markers. The goal is to produce a chronological timeline that connects user-visible events with internal system behavior, helping you determine whether the incident originated from a prompt defect, retrieval gap, tool failure, or model error. Copy the template below, replace every square-bracket placeholder with actual values from your observability platform, and execute it in your incident response workflow. The output should be treated as an investigative artifact—not a final root-cause determination—and must be validated against independent incident timelines from other sources such as monitoring dashboards, on-call reports, or deployment logs.

text
You are an incident response analyst reconstructing a user session from production trace data. Your task is to produce a structured incident timeline that connects user session events with known incident markers and assesses the impact on the user.

## INPUT DATA

### Trace Data
[TRACE_DATA]

### Incident Markers
[INCIDENT_MARKERS]

### User Session Identifier
[SESSION_ID]

### Incident Time Window
[INCIDENT_TIME_WINDOW]

## OUTPUT SCHEMA

Return a JSON object with the following structure:

{
  "session_identifier": "string",
  "incident_time_window": {
    "start": "ISO8601 timestamp",
    "end": "ISO8601 timestamp"
  },
  "reconstruction_timeline": [
    {
      "sequence_number": "integer",
      "timestamp": "ISO8601 timestamp",
      "event_type": "user_input | model_response | tool_call | tool_result | retrieval | state_change | error | incident_marker",
      "description": "string describing what occurred",
      "trace_span_id": "string or null",
      "incident_relevance": "direct | indirect | none",
      "impact_assessment": "string or null if no impact"
    }
  ],
  "incident_alignment": {
    "incident_markers_matched": ["list of matched marker IDs"],
    "alignment_confidence": "high | medium | low",
    "discrepancies": ["list of any mismatches between trace and incident markers"]
  },
  "impact_summary": {
    "user_visible_impact": "string describing what the user experienced",
    "failure_category": "prompt_defect | retrieval_gap | tool_failure | model_error | infrastructure | unknown",
    "severity": "critical | high | medium | low",
    "affected_turns": ["list of turn numbers or span IDs"]
  },
  "candidate_root_causes": [
    {
      "cause": "string description",
      "supporting_evidence": ["trace span IDs or event references"],
      "confidence": "high | medium | low"
    }
  ],
  "reconstruction_completeness": {
    "total_trace_spans": "integer",
    "spans_accounted_for": "integer",
    "gaps_identified": ["list of any missing spans or unexplained gaps"],
    "completeness_score": "0.0 to 1.0"
  }
}

## CONSTRAINTS

1. Include every trace span in the reconstruction. If a span cannot be placed in the timeline, list it under `gaps_identified`.
2. For each event, cite the specific trace span ID that supports it.
3. Do not invent events not present in the trace data.
4. When aligning with incident markers, note any discrepancies explicitly—do not force alignment.
5. If the trace data is incomplete or truncated, state this in `gaps_identified` and reduce `completeness_score` accordingly.
6. For `failure_category`, select exactly one value. Use `unknown` only if the trace evidence is insufficient to determine the category.
7. Mark `incident_relevance` as `direct` only if the event coincides with a known incident marker; use `indirect` for events in the same time window without clear causal connection.
8. If the trace contains sensitive data, redact it before including it in the output. Flag any remaining PII concerns in a separate note.

## VALIDATION RULES

Before returning the output, verify:
- The timeline is in strict chronological order.
- Every incident marker in the input appears in `incident_markers_matched` or is explained in `discrepancies`.
- `completeness_score` equals `spans_accounted_for / total_trace_spans`.
- No event description contradicts the trace data.

## RISK LEVEL: [RISK_LEVEL]

If RISK_LEVEL is `high`, append a human-review note to the output recommending that an incident commander validate the reconstruction before using it for root-cause determination.

After pasting this template, replace [TRACE_DATA] with the raw trace export from your observability platform—include all spans, tool calls, model responses, and retrieval steps for the session. Replace [INCIDENT_MARKERS] with the known incident timeline markers such as alert timestamps, deployment events, or error-rate spikes. Set [RISK_LEVEL] to high if the incident affects production users or involves regulated data; otherwise use medium or low. The output JSON can be ingested directly into your incident document or postmortem tool. Before relying on the reconstruction, cross-reference it against at least one independent data source—such as your monitoring dashboard or a separate trace query—to confirm the timeline alignment. If the completeness_score is below 0.9 or alignment_confidence is low, escalate for manual trace review rather than treating the output as authoritative.

IMPLEMENTATION TABLE

Prompt Variables

Required inputs for the Session Replay Incident Reconstruction Prompt. Validate each variable before execution to prevent misattribution, missing spans, or incorrect incident correlation.

PlaceholderPurposeExampleValidation Notes

[TRACE_DATA]

Raw trace spans, events, and metadata for the user session under investigation

JSON array of OpenTelemetry-compatible spans with trace_id, span_id, parent_span_id, timestamps, attributes, and events

Schema check: must be valid JSON array with at least one span. Reject if trace_id is missing or spans have no timestamps. Null not allowed.

[INCIDENT_TIMESTAMP]

The UTC timestamp when the production incident was declared or detected

2025-03-15T14:32:00Z

Parse check: must be valid ISO 8601 UTC string. Reject if timestamp is in the future or predates the session by more than 24 hours. Null not allowed.

[INCIDENT_SEVERITY]

The declared severity level of the incident from the incident management system

SEV2

Enum check: must match one of SEV0, SEV1, SEV2, SEV3. Reject if unrecognized severity string. Null not allowed.

[USER_ID]

The unique identifier for the user whose session is being reconstructed

user_8a7b3c2d

Format check: must be non-empty string matching the user_id field in trace attributes. Reject if user_id appears in fewer than 80% of spans. Null not allowed.

[SESSION_ID]

The session identifier to isolate the correct trace segment from other user activity

sess_f9e2d1a4

Format check: must be non-empty string present in trace span attributes. Reject if no spans match the session_id. Null not allowed.

[INCIDENT_MARKERS]

Known incident signals from monitoring systems to correlate against the session trace

JSON array of objects with marker_type, timestamp, description, and source_system fields

Schema check: each marker must have timestamp and marker_type. Reject if empty array. Null allowed only if no external markers exist yet.

[RECONSTRUCTION_DEPTH]

Controls how much detail the reconstruction includes: summary, turn-level, or span-level

turn-level

Enum check: must be one of summary, turn-level, span-level. Default to turn-level if null or missing.

[CORRELATION_SOURCES]

External incident timelines or reports to validate the reconstruction against

JSON array of objects with source_name, timeline_events, and confidence fields

Schema check: each source must have source_name and at least one timeline_event. Null allowed if no external correlation data is available yet.

PROMPT PLAYBOOK

Implementation Harness Notes

How to wire the Session Replay Incident Reconstruction Prompt into an incident response workflow with validation, retries, and human review.

This prompt is designed to be called during an active incident or post-incident review, not as a real-time streaming component. The primary integration point is an incident response bot or a runbook automation that receives an incident ID and a user session ID. The harness must first fetch the raw trace data from your observability platform (e.g., LangSmith, Arize, Datadog LLM Observability) and the incident timeline from your incident management tool (e.g., PagerDuty, FireHydrant). These two datasets become the [SESSION_TRACE] and [INCIDENT_TIMELINE] inputs. The prompt should only be invoked after both datasets are available and normalized to a common timezone, typically UTC, to prevent chronological misalignment.

Validation is critical because an incorrect reconstruction can misdirect an incident response. Implement a post-generation validation step that checks the output against a strict JSON schema. The schema must enforce that every session_event has a non-null timestamp, event_type, and trace_span_id, and that every incident_marker has a corresponding incident_timeline_id. Additionally, run a cross-reference check: for every incident_marker in the output, confirm that its correlated_session_event trace span ID actually exists in the input [SESSION_TRACE]. If validation fails, do not retry blindly. Log the validation error, append it to the prompt as a new [CONSTRAINTS] block (e.g., 'The previous output failed validation because incident marker X referenced a missing trace span'), and retry once. If the second attempt also fails, escalate to a human responder with the raw trace, the incident timeline, and both failed outputs.

Model choice matters here. Use a model with a large context window (at least 128k tokens) because production traces can be verbose. GPT-4o or Claude 3.5 Sonnet are strong defaults. Set temperature=0 to maximize determinism in the timeline reconstruction. Enable prompt caching on the static system instructions and the output schema to reduce latency and cost during repeated incident use. Log every invocation—including the prompt version, model, input trace IDs, and validation results—to an audit table. This log becomes part of the incident record and is essential for postmortem reviews. Never expose raw user inputs or PII in these logs without redaction. Finally, wire the validated output into your incident dashboard as a pinned timeline view, so that all responders share the same reconstructed session context.

IMPLEMENTATION TABLE

Expected Output Contract

Fields, types, and validation rules for the session replay incident reconstruction response. Use this contract to parse, validate, and store the model output before presenting it to an incident responder.

Field or ElementType or FormatRequiredValidation Rule

incident_timeline

Array of event objects

Must contain at least one event. Each event must have timestamp, event_type, and source fields.

incident_timeline[].timestamp

ISO 8601 string

Must parse as valid datetime. Must be within the incident window [INCIDENT_START] to [INCIDENT_END].

incident_timeline[].event_type

Enum: user_action | tool_call | model_response | error | incident_marker | system_event

Must match one of the allowed enum values exactly. Case-sensitive.

incident_timeline[].source

String matching a trace span ID or log reference

Must be a non-empty string. Should match a span_id from the input trace data when event_type is tool_call or model_response.

incident_timeline[].description

String

Must be non-empty. Maximum 500 characters. Must not contain unresolved template tokens.

impact_assessment

Object

Must contain severity, affected_users, and failure_category fields.

impact_assessment.severity

Enum: critical | high | medium | low | none

Must match one of the allowed enum values. If severity is critical, human approval is required before incident close.

impact_assessment.failure_category

Enum: prompt_defect | retrieval_gap | tool_failure | model_error | infrastructure | unknown

Must match one of the allowed enum values. If unknown, a follow-up deep-dive trace review must be triggered.

PRACTICAL GUARDRAILS

Common Failure Modes

Session replay reconstruction fails silently when trace data is incomplete, timelines drift, or the model confuses correlation with causation. These are the most common failure modes and how to prevent them before the incident report reaches a stakeholder.

01

Incomplete Trace Span Coverage

Risk: The reconstruction omits critical spans because the trace sampling rate is too low, spans were dropped, or the query filtered out relevant events. The resulting timeline looks clean but is dangerously incomplete. Guardrail: Validate span completeness before reconstruction. Require a pre-processing check that counts expected span types (user input, tool call, retrieval, generation) and flags sessions with gaps. Reject reconstruction if coverage falls below 95% of expected events.

02

Timeline Drift and Clock Skew

Risk: Distributed trace spans have inconsistent timestamps due to clock skew across services. The model orders events incorrectly, placing a tool response before its request or a user correction before the original output. Guardrail: Normalize all timestamps to a single reference clock before prompting. Include explicit ordering instructions in the prompt that require the model to validate causal ordering (response must follow request, correction must follow original). Flag events where timestamp ordering contradicts causal ordering.

03

Confirmation Bias Toward Incident Hypothesis

Risk: When the prompt includes the incident description or known failure mode, the model selectively highlights trace events that confirm the hypothesis and ignores contradictory evidence. The reconstruction becomes a self-fulfilling diagnosis. Guardrail: Split the prompt into two phases. Phase 1 reconstructs the session timeline without the incident context. Phase 2 overlays the incident markers and compares the reconstruction against the hypothesis. Require explicit contradiction checks and flag events that don't align with the incident narrative.

04

Tool-Call Attribution Errors

Risk: The model misattributes a failure to the wrong tool call, especially when multiple tool calls occur in rapid succession or share similar argument patterns. The incident report blames the retrieval step when the actual failure was a subsequent formatting tool. Guardrail: Require the prompt to extract and verify the exact tool name, arguments, and return values for each attributed failure. Include a cross-reference step that checks whether the attributed tool call's output was actually consumed downstream. Flag attributions where the causal chain is ambiguous.

05

Impact Assessment Inflation

Risk: The model overstates the user impact of a trace anomaly, conflating a minor latency spike with a session-breaking failure. The incident report escalates unnecessarily because the impact language is uncalibrated. Guardrail: Define a structured impact severity scale in the prompt (e.g., degraded, blocked, data_loss, no_impact). Require the model to cite specific trace evidence for each impact level and flag assessments where the evidence doesn't support the claimed severity. Include a human-review gate for any blocked or data_loss classification.

06

Reconstruction-Ignored External Signals

Risk: The prompt reconstructs the session entirely from trace data and ignores external signals like user feedback, support tickets, or monitoring alerts that contradict the trace narrative. The reconstruction is internally consistent but externally wrong. Guardrail: Include external signal fields as optional inputs in the prompt template. When provided, require the model to reconcile the trace reconstruction with external signals and explicitly flag any contradictions. If a user reported a failure but the trace shows success, the reconstruction must explain the discrepancy rather than silently accepting the trace.

IMPLEMENTATION TABLE

Evaluation Rubric

Use this rubric to test the quality of a reconstructed incident timeline before relying on it for postmortems or stakeholder communication. Each criterion targets a specific failure mode in session replay prompts.

CriterionPass StandardFailure SignalTest Method

Timeline Completeness

All trace spans from [SESSION_TRACE] are represented in the output timeline with no gaps

Output omits one or more spans present in the input trace, or introduces fabricated events not in the trace

Diff the set of span IDs in the input against span IDs referenced in the output; flag missing or extra IDs

Incident Marker Alignment

All incident markers from [INCIDENT_TIMELINE] are correctly placed at the corresponding session event with timestamp match within 5 seconds

Incident marker is attached to the wrong session event, or timestamp offset exceeds threshold

For each incident marker, verify the paired session event timestamp is within the tolerance window using a scripted comparison

Impact Assessment Grounding

Every impact statement in the output cites a specific trace span or incident marker as evidence

Impact claims appear without a trace reference, or the cited span does not support the claimed impact

Extract all impact claims and their citations; validate each citation exists in the trace and that the span content supports the claim

Chronological Ordering

All events are listed in ascending timestamp order with no inversions

Two or more events appear out of sequence relative to their trace timestamps

Parse all timestamps from the output and assert monotonic increase; flag any inversion

User Action Fidelity

User actions in the reconstruction match the original [USER_INPUT] events from the trace verbatim or with faithful paraphrase

User action is summarized in a way that changes the intent, omits a required parameter, or adds information not present in the trace

For each reconstructed user action, compare against the corresponding trace input event using a semantic similarity check with a threshold of 0.95

Tool Call Accuracy

All tool calls in the reconstruction include the correct tool name, arguments, and response status as recorded in the trace

Tool name is wrong, arguments are altered, or error status is misrepresented

Extract tool call blocks from the output and diff against the trace tool-call spans; flag any mismatch in name, arguments, or status

External Source Consistency

The reconstruction does not contradict the [INCIDENT_TIMELINE] from other sources; any discrepancy is explicitly flagged with a confidence note

Output presents a timeline that conflicts with the external incident timeline without acknowledging the conflict

Cross-reference key event timestamps and descriptions against the external incident timeline; flag unresolved contradictions

Confidence Annotation

Any event with ambiguous or incomplete trace data is annotated with a confidence level and the reason for uncertainty

Low-confidence events are presented as certain, or confidence annotations are missing where trace data is sparse

Scan output for events where the corresponding trace span has missing fields or error flags; verify a confidence annotation is present and correctly reflects the data quality

ADAPTATION OPTIONS

Adapt This Prompt

How to adapt

Use the base prompt with lighter validation. Focus on getting a readable timeline first, then tighten the schema.

  • Remove strict [OUTPUT_SCHEMA] requirements; accept structured markdown instead of JSON.
  • Replace [INCIDENT_MARKERS] with a simple list of timestamps or event descriptions.
  • Skip cross-reference validation against [EXTERNAL_TIMELINE].
  • Use a single [TRACE_DATA] blob without requiring span-level granularity.

Watch for

  • Missing schema checks that let the model invent events not present in the trace.
  • Overly broad instructions causing the model to summarize instead of reconstructing step-by-step.
  • No confidence scoring, making it hard to distinguish confirmed events from inferred ones.
  • Timeline gaps where the model silently skips spans it cannot interpret.
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.