This prompt is for data platform engineers who need to protect batch processing pipelines from corrupt records that cause cascading downstream failures. It identifies poison pill records before they enter transformation, aggregation, or loading stages. Use this prompt when you have a stream of records arriving in batches, and a single malformed or malicious record can crash a Spark job, corrupt a partition, or trigger an infinite retry loop. The prompt classifies corruption type, assesses propagation risk, and produces a quarantine decision with a corruption signature.
Prompt
Poison Pill Detection Prompt for Corrupt Batch Records

When to Use This Prompt
Identifies the ideal user, required context, and boundaries for the Poison Pill Detection Prompt.
The prompt assumes records are already parsed into a structured representation and that you have a defined schema to validate against. It works best when you can provide the record payload, the expected schema, and any known failure patterns from previous pipeline incidents. The output includes a corruption classification, a propagation risk score, and a quarantine recommendation that your orchestration layer can act on. For high-risk pipelines where data loss is unacceptable, always route quarantine decisions through a human review step before permanent deletion.
Do not use this prompt for real-time streaming event triage where latency is measured in milliseconds; use the Streaming Event Triage Prompt instead. It is also not suitable for schema validation alone—this prompt focuses on corruption that survives basic parsing, such as logically valid but semantically dangerous records. Avoid using it as a replacement for input sanitization at the ingestion boundary; it should sit after parsing but before transformation stages.
Use Case Fit
Where this prompt works and where it does not. Understand the operational boundaries before deploying poison pill detection into a production batch pipeline.
Good Fit: Deterministic Schema Violations
Use when: records violate a strict, known schema (malformed JSON, missing required fields, wrong data types). The prompt excels at classifying structural corruption with high confidence. Guardrail: Pair with a lightweight structural validator before the LLM call to reduce latency and cost for obvious failures.
Good Fit: Semantic Corruption Patterns
Use when: records are structurally valid but contain logical impossibilities (negative ages, future-dated events for historical data, null IDs in required relational fields). Guardrail: Provide a concrete data dictionary and business rules in the prompt context so the model can reason about semantic constraints rather than guessing.
Bad Fit: Real-Time Single-Record Ingestion
Avoid when: you need sub-millisecond per-record decisions in a synchronous API path. LLM latency and cost make this unsuitable for real-time ingress. Guardrail: Use this prompt for offline batch scanning or async dead-letter queue triage. For real-time paths, use a rules engine with the LLM as a periodic auditor.
Bad Fit: Unbounded Free-Text Anomaly Detection
Avoid when: the only signal is that a free-text field 'looks unusual' without a defined corruption taxonomy. The model will hallucinate corruption signatures or over-flag benign outliers. Guardrail: Define explicit corruption categories (e.g., truncation, encoding error, injection, schema mismatch) and require the model to map each flagged record to a category.
Required Input: Corruption Taxonomy and Examples
Risk: Without a clear taxonomy, the model produces inconsistent or overlapping corruption labels, making downstream quarantine routing unreliable. Guardrail: Supply a fixed enum of corruption types with definitions and 2-3 few-shot examples per type. Validate output labels against the enum programmatically before acting on quarantine decisions.
Operational Risk: False Positive Data Loss
Risk: Over-aggressive quarantine decisions silently drop valid records, causing downstream data gaps that are hard to detect. Guardrail: Implement a quarantine-and-review pattern, not auto-deletion. Route high-confidence corruption to quarantine and low-confidence flags to a human review queue. Monitor quarantine volume trends to detect threshold drift.
Copy-Ready Prompt Template
A copy-ready prompt template for detecting and classifying corrupt batch records before they poison downstream processing.
This prompt template is designed to be dropped directly into your batch processing harness. It instructs the model to act as a data quality gate, scanning a batch of records for structural corruption, schema violations, and semantic anomalies that will cause deterministic failures in downstream ETL, analytics, or model inference steps. The prompt forces a structured JSON output that your pipeline can parse to quarantine bad records, log corruption signatures, and route clean records forward without manual inspection.
Below is the copy-ready template. Every placeholder in square brackets must be replaced by your application at runtime. The [INPUT] block expects a serialized batch of records (JSON Lines or a JSON array). The [OUTPUT_SCHEMA] block defines the exact JSON structure the model must return, including required fields like corruption_type, propagation_risk, and quarantine_decision. The [CONSTRAINTS] block lets you enforce domain-specific rules, such as field length limits, required columns, or expected enum values. The [EXAMPLES] block should contain 2-3 few-shot examples of corrupt records with their correct classifications to anchor model behavior. The [RISK_LEVEL] block controls the model's sensitivity—use high for regulated data where false negatives are unacceptable, or low for non-critical pipelines where throughput matters more than exhaustive detection.
textYou are a data quality gate for a batch processing pipeline. Your task is to analyze the following batch records and identify any poison pill records that will cause downstream processing failures. For each corrupt record you find, you must: 1. Classify the corruption type from the allowed taxonomy. 2. Assess the propagation risk (how far the corruption will spread if not quarantined). 3. Produce a quarantine decision with a unique corruption signature for deduplication. 4. Return only valid JSON matching the output schema exactly. [INPUT] [EXAMPLES] [OUTPUT_SCHEMA] [CONSTRAINTS] [RISK_LEVEL] Return only the JSON object. Do not include explanations, markdown fences, or additional text.
After copying this template, you must adapt the placeholder blocks to your specific pipeline. The [OUTPUT_SCHEMA] is the most critical—define a JSON schema that your downstream quarantine handler can parse without ambiguity. Include a corruption_signature field that is deterministic enough to deduplicate repeated poison pills across retry attempts. The [CONSTRAINTS] block should encode your schema contracts: required fields, allowed types, value ranges, and referential integrity rules. Without these constraints, the model will miss corruption that is obvious to your pipeline but invisible to a general-purpose LLM. Validate the model's output against your schema before acting on quarantine decisions—malformed JSON from the model should trigger a retry or fallback to a safe default (quarantine the entire batch). For high-risk pipelines, route all quarantine decisions through a human review queue before permanent deletion.
Prompt Variables
Required inputs for the Poison Pill Detection Prompt. Each variable must be populated before the prompt is assembled and sent. Validation notes describe how to programmatically verify the input before incurring model cost.
| Placeholder | Purpose | Example | Validation Notes |
|---|---|---|---|
[BATCH_RECORD] | The single data record to inspect for corruption | {"id": "evt_9a2b", "payload": "\x00\x1F...", "schema_version": "2.1"} | Must be a single JSON object or stringified record. Reject if null, empty, or exceeds max record size (e.g., 1 MB). Check that record can be parsed before sending to model. |
[SCHEMA_DEFINITION] | The expected schema or contract the record should conform to | {"fields": [{"name": "user_id", "type": "uuid"}, {"name": "timestamp", "type": "iso8601"}], "required": ["user_id", "timestamp"]} | Must be a valid JSON Schema or equivalent type definition. Validate the schema itself is parseable JSON. Reject if null or empty object. |
[DOWNSTREAM_SYSTEMS] | List of downstream systems that will consume this record, used to assess propagation risk | ["billing_ledger", "fraud_detector", "user_profile_cache"] | Must be a non-empty array of strings. Each string should match a known system identifier from the platform registry. Warn if any system ID is unrecognized. |
[CORRUPTION_CATALOG] | Known corruption signatures and patterns to match against | ["null_required_field", "truncated_payload", "type_mismatch", "encoding_error", "future_timestamp"] | Must be a non-empty array of strings. Each entry should correspond to a defined corruption type in the team's runbook. Validate against allowed corruption type enum. |
[QUARANTINE_POLICY] | Rules for when to quarantine vs. reject vs. allow with warning | {"quarantine_threshold": "high", "auto_reject_types": ["truncated_payload", "encoding_error"], "warn_types": ["future_timestamp"]} | Must be a valid JSON object with required keys: quarantine_threshold, auto_reject_types, warn_types. Validate threshold is one of: low, medium, high, critical. Reject if policy object is missing required keys. |
[PIPELINE_CONTEXT] | Operational context about the batch pipeline state | {"batch_id": "batch_2025-03-15_04", "total_records": 50000, "failure_rate_so_far": 0.02, "latency_budget_ms": 200} | Must be a valid JSON object. Required fields: batch_id (non-empty string), failure_rate_so_far (float between 0.0 and 1.0). Optional: total_records, latency_budget_ms. Validate numeric ranges before sending. |
[OUTPUT_SCHEMA] | The exact JSON schema the model must return | {"type": "object", "properties": {"corruption_detected": {"type": "boolean"}, "corruption_type": {"type": "string"}, "propagation_risk": {"type": "string", "enum": ["none", "low", "medium", "high", "critical"]}, "quarantine_decision": {"type": "string", "enum": ["allow", "warn", "quarantine", "reject"]}, "corruption_signature": {"type": "string"}, "affected_fields": {"type": "array", "items": {"type": "string"}}, "confidence": {"type": "number", "minimum": 0.0, "maximum": 1.0}}}, "required": ["corruption_detected", "corruption_type", "propagation_risk", "quarantine_decision", "confidence"]} | Must be a valid JSON Schema. Validate schema is parseable. Required output fields must include: corruption_detected, corruption_type, propagation_risk, quarantine_decision, confidence. Reject if schema allows values outside expected enums. |
Implementation Harness Notes
How to wire the poison pill detection prompt into a batch processing pipeline with validation, retries, and quarantine logic.
Integrating the Poison Pill Detection Prompt into a production batch pipeline requires treating it as a deterministic gate, not an advisory tool. The prompt should be invoked as a pre-processing step before any record reaches a transformation, enrichment, or loading stage. In a typical Apache Spark, Apache Beam, or Kafka Streams job, each record or micro-batch is passed through a map or filter operation that calls the LLM endpoint. The model's response—containing the corruption_type, propagation_risk, and quarantine_decision—must be parsed and enforced immediately. A record classified as QUARANTINE should be written to a dead-letter queue (DLQ) or a quarantine storage path (e.g., s3://bucket/quarantine/YYYY-MM-DD/) and never reach the main processing sink. This prevents a single malformed record from crashing an entire Spark partition or causing a cascading write failure in a data warehouse.
The implementation must include a strict validation layer between the model's output and the routing decision. Parse the JSON response and validate that corruption_type is one of the allowed enum values (e.g., SCHEMA_VIOLATION, ENCODING_ERROR, TRUNCATED_RECORD, INJECTION_PATTERN, LOGICAL_CORRUPTION). If the output fails to parse or contains an unknown type, default to QUARANTINE with a corruption_type of UNCLASSIFIED to avoid passing potentially dangerous data. Implement a lightweight retry policy for transient model errors (HTTP 429, 503) with exponential backoff, but cap retries at 2-3 attempts to maintain pipeline throughput. For high-throughput streams, consider batching records into groups of 10-50 and sending them in a single prompt call with a structured output schema that returns an array of per-record classifications. This reduces API overhead while maintaining per-record traceability.
Observability is critical. Log every classification decision with the record's unique identifier, the model's confidence score, the corruption signature, and the routing outcome. Emit metrics on quarantine rate, classification latency (p50, p99), and the distribution of corruption types. Set alerts on sudden spikes in quarantine rate, which may indicate an upstream data producer failure or a prompt drift issue. Regularly sample quarantined records and run them through a human review process to measure the false positive rate—incorrectly quarantining valid records causes data loss that downstream consumers will notice. If the false positive rate exceeds a defined threshold (e.g., 2%), tune the prompt's instructions or adjust the confidence threshold for automatic quarantine. Never silently drop quarantined records; always retain them with metadata for forensic analysis and potential reprocessing after the root cause is fixed.
Expected Output Contract
The expected JSON output for a poison pill detection prompt. Each field must be validated before the quarantine decision is executed downstream.
| Field or Element | Type or Format | Required | Validation Rule |
|---|---|---|---|
corruption_detected | boolean | Must be true or false. If true, quarantine_decision must be 'quarantine'. | |
corruption_type | string (enum) | Must match one of: 'schema_violation', 'encoding_error', 'truncation', 'injection_attempt', 'semantic_corruption', 'unknown'. Null allowed only if corruption_detected is false. | |
corruption_signature | string | Must contain a specific, human-readable description of the detected anomaly. Minimum 10 characters if corruption_detected is true. | |
propagation_risk | string (enum) | Must be 'high', 'medium', or 'low'. 'high' requires immediate quarantine regardless of other fields. | |
quarantine_decision | string (enum) | Must be 'quarantine', 'repair', or 'pass'. 'repair' requires a non-null repair_suggestion. | |
repair_suggestion | string or null | If quarantine_decision is 'repair', must be a non-null string describing the repair action. If 'quarantine' or 'pass', must be null. | |
affected_fields | array of strings | Must be a JSON array of field names or paths. Empty array allowed only if corruption_detected is false. | |
confidence_score | number | Must be a float between 0.0 and 1.0. Scores below 0.7 should trigger a human review flag in the harness. |
Common Failure Modes
Poison pill detection fails silently in production when the prompt cannot distinguish between a corrupt record and a novel but valid one. These cards cover the most common failure modes and the operational guardrails that prevent them from corrupting downstream systems.
Novel-Valid Records Misclassified as Corrupt
What to watch: Schema evolution, new product lines, or legitimate edge cases produce records that look corrupt to a rigid classifier. The prompt flags valid data as poison, causing unnecessary quarantine and data loss. Guardrail: Include explicit instructions to distinguish between 'violates known schema' and 'matches no known corruption pattern.' Require the model to output a corruption_confidence score and route low-confidence positives to a review queue instead of quarantine.
Subtle Corruption Passing Detection
What to watch: Bit flips, truncated fields, or encoding errors that produce syntactically valid but semantically wrong records. The prompt sees valid JSON or CSV structure and misses the corruption entirely, allowing poison into downstream processing. Guardrail: Add semantic validation checks to the prompt, such as field range validation, cross-field consistency rules, and expected distribution checks. Pair the prompt with a statistical outlier detector that flags records deviating from batch-level norms.
Detection Latency Exceeding Batch Window
What to watch: Large batches or complex corruption patterns cause the prompt to exceed processing time budgets. Late detection means poison already propagated before quarantine decisions are made. Guardrail: Implement a two-stage triage: a fast pre-scan prompt that flags obviously corrupt records within the latency budget, and a deeper analysis prompt for ambiguous cases that can run asynchronously. Monitor p95 detection latency against the batch processing SLA.
Corruption Signature Drift Over Time
What to watch: Corruption patterns change as upstream systems evolve, but the prompt's corruption taxonomy remains static. Detection recall degrades silently as new corruption types emerge. Guardrail: Include a corruption_signature field in the output that describes the detected pattern, not just a classification label. Log signatures from false negatives discovered downstream. Schedule periodic prompt reviews against recent poison pill incidents to update the corruption taxonomy.
False Positive Cascade in Downstream Systems
What to watch: Overly aggressive detection quarantines a large fraction of the batch, starving downstream systems of data and triggering their own alerting thresholds. The quarantine itself becomes a production incident. Guardrail: Set a maximum quarantine rate threshold. If the prompt flags more than a configured percentage of a batch, halt automatic quarantine and escalate the entire batch for human review. Include a batch_quarantine_rate check in the harness before quarantine decisions are executed.
Encoding and Serialization Corruption Bypass
What to watch: Corruption at the byte or encoding level (UTF-8 errors, BOM artifacts, mixed encodings) is invisible to a prompt that only sees decoded text. The model receives cleaned or partially decoded input and misses the underlying corruption. Guardrail: Perform pre-prompt encoding validation at the ingestion layer. Pass encoding metadata and raw byte-level error flags as context to the prompt. Instruct the model to check for encoding-related anomalies even when the decoded text appears valid.
Evaluation Rubric
Use this rubric to test the Poison Pill Detection Prompt before deploying it to a production batch pipeline. Each criterion targets a specific failure mode that can corrupt downstream data or halt processing.
| Criterion | Pass Standard | Failure Signal | Test Method |
|---|---|---|---|
Corruption Type Classification | Correctly labels the record as [CORRUPTION_TYPE] from the defined taxonomy (e.g., SCHEMA_VIOLATION, ENCODING_ERROR) with a confidence score above the [CONFIDENCE_THRESHOLD]. | Outputs a generic label like 'ERROR' or misclassifies a valid record as corrupt. | Run against a golden dataset of 50 pre-labeled corrupt records and assert exact match accuracy > 0.95. |
Propagation Risk Assessment | Assigns a [PROPAGATION_RISK] level (HIGH, MEDIUM, LOW) that matches the downstream blast radius. A malformed JSON record that will crash the parser must be HIGH. | Flags a parser-crashing record as LOW risk, causing it to bypass quarantine and halt the pipeline. | Inject 10 records with known crash-inducing payloads and assert all are classified as HIGH risk. |
Quarantine Decision Accuracy | Returns a [QUARANTINE_DECISION] of true for any record with a propagation risk of HIGH or a corruption confidence above the threshold. Returns false for clean records. | A clean record is quarantined (false positive), causing data loss, or a corrupt record is passed through (false negative). | Process a mixed batch of 100 clean and 100 corrupt records. Assert false positive rate < 0.01 and false negative rate == 0. |
Corruption Signature Extraction | Outputs a non-empty [CORRUPTION_SIGNATURE] string that uniquely identifies the failure pattern (e.g., 'unexpected token at line 45') for deduplication. | Returns null or an empty string for a record that triggered a quarantine decision. | Validate that the [CORRUPTION_SIGNATURE] field is non-null and non-empty for every record where [QUARANTINE_DECISION] is true. |
Output Schema Compliance | The model output strictly conforms to the defined [OUTPUT_SCHEMA] without extra keys or malformed JSON. | The response fails to parse as valid JSON or is missing the required [QUARANTINE_DECISION] field. | Parse the raw model output with a JSON schema validator. Assert no validation errors for 100 consecutive calls. |
Detection Latency Budget | The end-to-end classification completes within the [LATENCY_BUDGET_MS] for a single record. | Processing time exceeds the budget, causing backpressure in the streaming or batch pipeline. | Measure the 99th percentile (p99) latency over 1000 requests and assert it is less than [LATENCY_BUDGET_MS]. |
Adversarial Input Robustness | Correctly identifies a corrupt record even when it is padded with benign-looking text or valid metadata. | The model is tricked by a 'wolf in sheep's clothing' payload and classifies a malicious record as clean. | Craft 5 adversarial records that embed a corrupt payload inside a valid wrapper. Assert all are quarantined. |
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
Start with the base prompt and a small sample of known-bad records. Remove strict output schema requirements initially. Use a simple pass/fail check: does the model correctly flag records you know are corrupt? Focus on corruption type accuracy over propagation risk scoring.
Simplify the prompt by removing [PROPAGATION_RISK] and [QUARANTINE_RATIONALE] fields. Use a basic JSON structure with only is_poison_pill, corruption_type, and confidence.
Watch for
- Over-flagging: the model marks too many records as corrupt because the instructions are too broad
- Missing schema validation: malformed model output breaks your test harness before you can evaluate detection quality
- Inconsistent corruption type labels across runs, making it hard to compare results

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