Inferensys

Prompt

Golden Trace Capture Prompt for Production Logs

A practical prompt playbook for observability engineers harvesting real examples from production logs to build and maintain golden test datasets.
Data scientist building training data pipeline on laptop, data preprocessing visible, technical workspace.
PROMPT PLAYBOOK

When to Use This Prompt

Defines the ideal user, required context, and boundaries for the Golden Trace Capture Prompt.

This prompt is built for observability engineers and AI ops teams who need to bootstrap or expand a regression test suite with real-world data. The core job-to-be-done is converting raw, unstructured production traces into a curated, sanitized golden dataset. The ideal user has access to production logs, understands the system's expected behavior, and needs to create test records that represent correct behavior, interesting edge cases, or instructive failures—not synthetic approximations. You should use this prompt when your team is moving from ad-hoc testing to structured regression gates and needs high-signal examples that reflect actual user interactions and system responses.

The prompt requires several concrete inputs to function reliably. You must provide a set of raw production traces in a structured format (e.g., JSONL with trace_id, input, output, metadata). You must also supply a [SELECTION_CRITERIA] block that defines what makes a trace valuable for your test suite—this could include correctness markers, latency thresholds, tool-call patterns, or specific error codes. A [SANITIZATION_RULES] block is required to specify which fields to redact (PII, secrets, internal IPs) and how to replace them. The prompt expects an [OUTPUT_SCHEMA] that defines the shape of each golden record, including fields for the sanitized input, expected output, trace metadata, inclusion justification, and a privacy redaction log. Without these inputs, the prompt will produce inconsistent or unsafe results.

Do not use this prompt when you lack access to production logs or when the logs do not contain enough signal to distinguish correct behavior from noise. It is also inappropriate for generating synthetic test data from scratch—use the Golden Example Generation Prompt Template for that purpose. Avoid using this prompt on traces that contain unredactable sensitive data or where the sanitization process would strip away the very details that make the trace valuable for testing. Finally, this prompt is not a replacement for human review of the resulting golden dataset; every selected trace should be reviewed by an engineer who understands the system's expected behavior before it enters the regression suite.

PRACTICAL GUARDRAILS

Use Case Fit

Where the Golden Trace Capture Prompt delivers value and where it creates risk. Use these cards to decide if this prompt belongs in your observability pipeline.

01

Good Fit: Production Trace Harvesting

Use when: you need to extract representative, high-signal examples from production logs to build or refresh a golden test suite. Guardrail: always filter traces by outcome (success, failure, edge case) before capture to avoid polluting the dataset with noise.

02

Bad Fit: Real-Time Guardrails

Avoid when: you need to block, rewrite, or gate a live model response. This prompt selects and sanitizes traces after the fact. Guardrail: pair with a separate real-time validation prompt or circuit breaker for in-request protection.

03

Required Inputs: Structured Log Context

What to watch: the prompt cannot function on raw, unstructured log lines alone. Guardrail: ensure each trace includes the final prompt, the model response, tool-call metadata, and any validator or guard outputs before invoking capture.

04

Operational Risk: PII Leakage into Golden Sets

What to watch: production traces often contain customer names, emails, or account IDs that must never land in a test repository. Guardrail: run a separate PII redaction step before capture and verify the sanitized output with a regex + NER audit before committing to the dataset.

05

Operational Risk: Selection Bias

What to watch: capturing only high-confidence or successful traces creates a golden set that over-represents easy cases. Guardrail: stratify capture by confidence score, intent category, and failure type to maintain coverage across the full difficulty spectrum.

06

Bad Fit: Untriaged Incident Logs

Avoid when: logs are dominated by a known outage, model bug, or upstream data corruption. Guardrail: wait until the incident is resolved and root-caused, then capture traces with the incident context attached as metadata, not as representative normal behavior.

PROMPT PLAYBOOK

Copy-Ready Prompt Template

A production-ready prompt for selecting, sanitizing, and justifying golden traces from raw log batches.

The following prompt template is designed to be dropped directly into your observability pipeline or a manual review workflow. It instructs the model to act as a strict curator, selecting only traces that meet specific criteria for correctness, diversity, and safety. The template uses square-bracket placeholders for all dynamic inputs, ensuring you can wire it into a script, a Retool UI, or a CI/CD harness without modification.

code
You are a senior QA engineer curating a golden dataset for regression testing. Your task is to analyze a batch of production traces and select the best candidates.

## INPUT DATA
[PRODUCTION_TRACE_BATCH]

## SELECTION CRITERIA
Analyze each trace and select candidates that meet these rules:
1. **Correctness**: The final output correctly fulfills the user's intent without factual errors or hallucinations.
2. **Diversity**: The batch should represent a mix of simple, complex, and edge-case interactions. Avoid selecting near-duplicate traces.
3. **Interesting Failure**: Include traces where the model correctly refused, asked for clarification, or hit a known limitation gracefully. Do not include traces with unhandled exceptions or toxic outputs.
4. **Sanitization**: Before inclusion, redact all personally identifiable information (PII), API keys, and internal hostnames from the `input` and `output` fields. Replace them with placeholders like `[REDACTED_EMAIL]`.

## OUTPUT FORMAT
Return a single JSON object with the following schema:
{
  "selected_traces": [
    {
      "trace_id": "string",
      "sanitized_input": "string",
      "sanitized_output": "string",
      "inclusion_reason": "string (one of: 'correct_behavior', 'edge_case', 'graceful_failure')",
      "difficulty_rating": "string (one of: 'easy', 'medium', 'hard')"
    }
  ],
  "rejected_trace_ids": ["string"],
  "rejection_reasons": {
    "trace_id": "string (brief reason for rejection)"
  }
}

## CONSTRAINTS
- Do not select more than [MAX_TRACES] traces.
- If no traces meet the criteria, return an empty `selected_traces` array.
- Ensure the `sanitized_input` and `sanitized_output` do not contain raw user data.

To adapt this template, replace [PRODUCTION_TRACE_BATCH] with your JSONL or structured log data. The [MAX_TRACES] variable should be set based on your review budget—typically between 5 and 20 for a manual review cycle. The output schema is designed to be machine-readable so you can pipe the results directly into a database or a test harness. If your traces contain multi-turn conversations, ensure the sanitized_input field includes the full message history to preserve the context required for regression testing.

Before deploying this prompt, validate its output against a known set of traces. A common failure mode is the model being too permissive, selecting traces that contain subtle hallucinations or formatting errors. To guard against this, implement a post-processing validation step in your harness that checks for the presence of redacted placeholders and rejects any trace where the inclusion_reason is not from the allowed enum list. For high-risk domains, always require a human to approve the final batch before it is committed to the golden dataset.

IMPLEMENTATION TABLE

Prompt Variables

Required inputs for the Golden Trace Capture Prompt. Each placeholder must be populated before the prompt is sent. Missing or malformed inputs will cause the capture to fail validation or produce traces that cannot be used in regression suites.

PlaceholderPurposeExampleValidation Notes

[TRACE_PAYLOAD]

Raw production trace containing the full request, response, tool calls, and metadata for one interaction

{"request": {...}, "response": {...}, "tool_calls": [...], "latency_ms": 342}

Must be valid JSON. Parse check required before prompt assembly. Reject if payload exceeds 100KB or contains binary blobs.

[TRACE_SOURCE]

Identifier for the system, service, or pipeline that produced this trace

prod-chat-api-us-east-1 / staging-rag-pipeline-v2

Must match a known source in the trace registry. Unknown sources require manual approval before capture.

[CAPTURE_CRITERIA]

Rules defining which traces qualify for golden set inclusion: correct behavior, edge case, interesting failure, or user correction

correct_behavior / edge_case / interesting_failure / user_correction

Must be exactly one of the four enum values. Invalid criteria causes the prompt to abort with a schema error.

[PRIVACY_POLICY]

Redaction rules specifying which entity types to mask or remove: PII, secrets, internal URLs, customer names, or custom patterns

{"redact": ["PII", "secrets", "customer_name"], "preserve": ["error_codes", "tool_names"]}

Must be a valid JSON object with redact and preserve arrays. Empty redact array allowed only if trace is from a synthetic or sanitized source.

[OUTPUT_SCHEMA]

Target schema for the sanitized golden trace record including required fields, optional metadata, and field-level constraints

{"required": ["trace_id", "input", "expected_output", "criteria_label"], "optional": ["latency_ms", "model_version"]}

Must be a valid JSON schema fragment. Required fields must be present in the trace payload or derivable from it. Schema mismatch triggers a repair retry.

[INCLUSION_JUSTIFICATION]

Free-text field explaining why this trace belongs in the golden set, written by the operator or upstream classifier

Correct handling of multi-turn context switch with tool call chaining. Represents happy path for RAG pipeline.

Must be non-empty and between 20-500 characters. Justifications shorter than 20 characters are rejected as insufficient. Null or empty triggers a human review flag.

[MAX_REDACTION_RATIO]

Threshold for the maximum allowed percentage of redacted content before the trace is rejected as too sparse for testing

0.30

Must be a float between 0.0 and 1.0. Traces exceeding this ratio after redaction are flagged as UNUSABLE and excluded from the golden set. Default 0.30 if not specified.

PROMPT PLAYBOOK

Implementation Harness Notes

How to wire the Golden Trace Capture Prompt into an observability pipeline with validation, sanitization, and human review gates.

The Golden Trace Capture Prompt is designed to run as a batch or streaming post-processing step in your observability pipeline, not as a real-time user-facing prompt. After your AI application logs request-response pairs, tool calls, and metadata, this prompt reviews candidate traces and selects those worth promoting to your golden regression dataset. The harness must enforce three gates before any trace enters the golden set: schema validation (the output matches the expected JSON structure with required fields like trace_id, inclusion_justification, and sanitized_output), privacy verification (PII and secrets are redacted, with a redaction_log present), and human approval (a reviewer confirms the trace represents correct behavior, an interesting edge case, or a failure mode worth testing).

Wire the prompt into a message queue or batch job that triggers after a configurable sampling window (e.g., every 1,000 production requests or every hour). The harness should: (1) fetch raw traces from your logging store (e.g., OpenTelemetry, Datadog, custom log tables), (2) assemble the prompt with [TRACE_BATCH] containing up to 20 candidate traces in a structured JSON array, [SELECTION_CRITERIA] describing what makes a trace valuable (e.g., 'correct complex reasoning', 'edge case with ambiguous input', 'failure with informative error'), and [OUTPUT_SCHEMA] specifying the exact JSON shape, (3) call the model with response_format set to json_object and a low temperature (0.0–0.2) for deterministic selection, (4) validate the output against a JSON Schema that requires selected_traces as an array of objects with trace_id, sanitized_input, sanitized_output, inclusion_category, inclusion_justification, redaction_log, and confidence_score, (5) run a secondary PII scanner (e.g., Presidio, AWS Comprehend, or a regex-based secret detector) on the sanitized_input and sanitized_output fields to catch any leaks the model missed, and (6) write approved traces to a staging table with a review_status of pending_human_review. Use exponential backoff with a max of 3 retries if the model returns malformed JSON or fails schema validation; after 3 failures, log the batch for manual triage.

For model choice, prefer a model with strong structured output support and low latency for batch processing—GPT-4o or Claude 3.5 Sonnet work well. If cost is a concern, use a smaller model (e.g., GPT-4o-mini) for initial filtering and escalate ambiguous candidates to a larger model. Do not skip human review for traces flagged as inclusion_category: 'failure_mode' or confidence_score < 0.8; these require an engineer to verify the trace is reproducible and worth testing. Wire the human review step into your existing ticketing or review queue system (e.g., Jira, Linear, a custom admin panel) with a link to the raw trace and the model's justification. Once approved, move the trace to the golden dataset and update the review_status to approved. Track metrics: selection rate (traces selected per batch), validation failure rate (how often the model output fails schema or PII checks), human rejection rate (how often reviewers override the model), and golden set growth rate over time. These metrics will surface when the prompt needs tuning—for example, if the selection rate drops below 5%, your criteria may be too strict, or if the human rejection rate exceeds 30%, the model is over-selecting noisy traces.

IMPLEMENTATION TABLE

Expected Output Contract

Define the exact shape, types, and validation rules for the golden trace record produced by the capture prompt. Use this contract to build downstream parsers, storage schemas, and automated validation checks.

Field or ElementType or FormatRequiredValidation Rule

trace_id

string (UUID v4)

Must parse as valid UUID v4. Reject if null or malformed.

capture_timestamp

string (ISO 8601 UTC)

Must parse as valid ISO 8601 datetime with UTC offset. Must be within the last 30 days.

source_environment

enum: [production, staging, development]

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

original_user_input

string

Must be non-empty after trimming. Max length 32,000 characters. No validation on content, but must be present.

model_response

string

Must be non-empty after trimming. Max length 64,000 characters. No validation on content, but must be present.

inclusion_category

enum: [correct_behavior, edge_case, interesting_failure, boundary_test]

Must match one of the allowed enum values exactly. Reject if missing or invalid.

inclusion_justification

string

Must be between 20 and 500 characters. Must contain at least one specific reason referencing the trace content.

privacy_redactions_applied

array of strings

Must be a valid JSON array. Each element must be a non-empty string describing a redaction. Empty array is allowed if no redactions were needed.

redacted_fields

array of strings

Must be a valid JSON array if present. Each element must name a field that was redacted. Null allowed if no redactions.

expected_behavior_summary

string

Must be between 10 and 300 characters. Must describe the correct or expected behavior demonstrated or violated by this trace.

trace_quality_score

number (0.0 to 1.0)

Must be a float between 0.0 and 1.0 inclusive. Reject if outside range or non-numeric.

review_status

enum: [pending_review, approved, rejected, needs_clarification]

Must match one of the allowed enum values exactly. Default to pending_review on capture.

PRACTICAL GUARDRAILS

Common Failure Modes

Golden trace capture fails silently in production. These are the most common failure modes when harvesting real examples for test suites, and the guardrails that prevent bad traces from poisoning your regression datasets.

01

PII Leakage into Golden Traces

What to watch: Production traces containing emails, names, phone numbers, or account IDs slip past redaction and enter the golden dataset. Once stored, they become training or eval data with no audit trail. Guardrail: Run a mandatory PII detection pass before any trace is written to the golden set. Require explicit redaction logs and reject traces where redaction confidence falls below threshold.

02

Incorrect Behavior Captured as Correct

What to watch: A trace looks clean but contains a subtle hallucination, wrong citation, or off-policy response. The capture prompt marks it as correct because surface formatting passes. Guardrail: Require the capture prompt to produce an inclusion justification with specific evidence from the trace. Add a secondary semantic equivalence check against the expected output contract before acceptance.

03

Over-Sampling Happy Path Traces

What to watch: The capture prompt selects only successful, low-complexity traces because they are easier to validate. The golden set becomes a best-case benchmark that misses edge cases and failure modes. Guardrail: Enforce diversity quotas in the capture prompt: require minimum percentages for edge cases, refusals, tool-call failures, and ambiguous inputs. Log distribution metrics per capture run.

04

Stale Traces from Deprecated Prompt Versions

What to watch: Golden traces captured against an old system prompt or tool schema become invalid after a prompt migration. The test suite passes against stale references but fails in production. Guardrail: Attach prompt version, model version, and tool schema version to every golden trace. Run a pre-commit check that rejects traces referencing versions outside the current compatibility window.

05

Capture Prompt Itself Drifts Over Time

What to watch: The prompt that selects golden traces is modified without version control, changing selection criteria silently. Suddenly, traces that were previously rejected are accepted, or vice versa. Guardrail: Version the capture prompt alongside the golden dataset. Run the new capture prompt against a holdout set of previously reviewed traces and flag any classification changes for human review.

06

Missing Context Makes Traces Unreplayable

What to watch: A trace is captured with only the final user message and model response, but the upstream retrieval results, tool outputs, or conversation history that shaped the response are missing. The golden trace cannot be replayed for regression testing. Guardrail: Require the capture prompt to verify that all upstream context dependencies are included in the trace payload. Reject traces where context completeness score falls below threshold.

IMPLEMENTATION TABLE

Evaluation Rubric

Criteria for evaluating the quality and safety of golden traces produced by the capture prompt before they are admitted into the regression test suite.

CriterionPass StandardFailure SignalTest Method

Schema Compliance

Output is valid JSON matching the [OUTPUT_SCHEMA] exactly; all required fields present and correctly typed.

JSON parse error, missing required field, or incorrect data type for any field.

Automated schema validator run against the raw model output.

PII Redaction Completeness

No personally identifiable information (emails, names, phone numbers, SSNs) present in the sanitized trace fields.

Regex or entity detection model flags a potential PII entity in the sanitized output.

Automated PII scanner (e.g., Presidio, regex suite) run on the sanitized_input and sanitized_output fields.

Inclusion Justification Quality

The inclusion_justification field contains a specific, non-generic reason referencing the trace's behavior (e.g., 'correct tool call', 'edge case refusal').

Justification is empty, a generic placeholder like 'good example', or does not match the trace content.

LLM-as-judge evaluation: prompt checks if the justification is specific, accurate, and non-trivial.

Trace Completeness

The captured trace includes all required spans: user input, final output, and any intermediate tool calls or reasoning steps.

A required span (e.g., tool_calls array) is missing or empty when the trace metadata indicates a tool was used.

Structural assertion: check for the presence and non-null status of all required span objects based on the trace type.

Behavioral Correctness

The captured trace represents a correct system behavior as defined by the product spec (e.g., correct answer, appropriate refusal, valid tool call).

The trace contains a known error pattern (e.g., hallucinated citation, incorrect calculation, policy violation).

Human review of a sample; automated check against a blocklist of known failure signatures for high-volume capture.

Metadata Accuracy

The capture_timestamp, trace_id, and model_version fields accurately reflect the source production log entry.

A metadata field is null, contains a default placeholder, or does not match the linked production log record.

Automated reconciliation: compare captured metadata fields against the source log entry in the observability platform.

Diversity Tagging

The tags array includes at least one label from the required taxonomy (e.g., 'correct', 'edge_case', 'refusal') that accurately categorizes the trace.

The tags array is empty, contains an invalid tag, or the tag contradicts the trace content (e.g., tagging a failure as 'correct').

Enum validation for tag values; spot-check via LLM judge to confirm tag accuracy against the trace content.

Sanitization Integrity

The sanitized trace preserves the semantic structure and testable properties of the original interaction while removing sensitive data.

Sanitization corrupts the JSON structure, changes the intent of a user query, or removes a key element needed for testing (e.g., a specific entity type).

Semantic equivalence check: an LLM judge confirms the sanitized trace is functionally identical to the original for testing purposes, minus the PII.

ADAPTATION OPTIONS

Adapt This Prompt

How to adapt

Add structured output schema, privacy redaction rules, and inclusion justification fields. Wire the prompt into a log processing pipeline with retry logic and schema validation before traces enter the golden dataset.

code
You are a golden trace curator. Analyze the production log entry and return a structured decision.

Log Entry:
[LOG_ENTRY]

Output Schema:
{
  "selected": boolean,
  "trace_id": "string",
  "category": "correct_behavior | edge_case | interesting_failure | not_selected",
  "inclusion_justification": "string",
  "sanitized_input": "string",
  "sanitized_output": "string",
  "redactions_applied": ["field_name"],
  "metadata": {
    "model_version": "string",
    "prompt_version": "string",
    "timestamp": "ISO8601"
  }
}

Constraints:
- Redact all PII, secrets, and credentials
- Only select traces that demonstrate distinct behavior
- Justify each inclusion against [COVERAGE_TAXONOMY]

Watch for

  • Silent schema drift when model output format changes
  • Incomplete redaction of nested PII fields
  • Duplicate traces diluting golden set value
  • Missing human review gate before traces enter regression suite
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.