This prompt is for data platform engineers and MLOps teams who operate batch processing pipelines where some records succeed and others fail. Its job is to classify failed records by error type and determine the correct recovery strategy—retry, skip, or quarantine—producing a structured remediation plan. Use it when your pipeline produces a partial-failure output and you need a deterministic, auditable decision before the next retry attempt, rather than blindly retrying everything or discarding failures without analysis.
Prompt
Partial-Failure Recovery Classification Prompt

When to Use This Prompt
Define the job, ideal user, and constraints for the Partial-Failure Recovery Classification Prompt.
The ideal user has access to the failed record payload, the error message or exception type, the retry attempt count, and any relevant pipeline state (such as whether downstream systems are healthy). The prompt expects these as structured inputs and returns a classification label, a confidence score, a recommended action, and a rationale. It is designed for integration into a retry harness that enforces idempotency, tracks attempt counts, and prevents infinite retry loops. Do not use this prompt for real-time streaming failures where latency constraints preclude classification, or for failures where the root cause is unknown and requires human investigation before any automated recovery decision.
Before deploying, wire the prompt into a pipeline that validates the output schema, enforces max retry limits, and logs every classification decision for audit. For high-risk pipelines—such as financial transaction processing or healthcare data ingestion—require human review for any record classified as quarantine or any record exceeding a configurable retry threshold. The prompt is a classification and routing tool, not a root-cause analysis engine; it tells you what to do with a failure, not why the failure occurred in depth. Pair it with separate observability and debugging workflows for deep failure analysis.
Use Case Fit
Where this prompt works and where it does not. Use these cards to quickly assess fit, required inputs, and operational risk before integrating the Partial-Failure Recovery Classification Prompt into your batch pipeline.
Good Fit: Heterogeneous Batch Failures
Use when: Your batch pipeline produces a mix of transient errors (timeouts, rate limits), permanent data corruption, and schema violations that require different recovery paths. Guardrail: The prompt excels at classifying these distinct failure modes into retry, skip, or quarantine decisions, but you must provide structured error context for each failed record.
Bad Fit: Real-Time Request Paths
Avoid when: You need sub-second classification on a live user request path. Guardrail: This prompt is designed for asynchronous batch processing. Using it in a synchronous request flow will violate latency budgets. Route real-time failures to a lightweight rule-based classifier and use this prompt for offline recovery.
Required Inputs: Structured Error Context
What to watch: The prompt cannot classify failures from a raw stack trace alone. Guardrail: You must provide a structured input containing the error code, the failed payload, the target system, and the retry count. Without this, the model will hallucinate a failure reason, leading to incorrect recovery actions.
Operational Risk: Idempotency Violations
What to watch: A 'retry' classification on a non-idempotent operation can cause duplicate side effects. Guardrail: The prompt must be instructed to check for an idempotency key in the failed payload. If the key is missing and the operation is non-idempotent, the classification should default to 'quarantine' for manual review, not 'retry'.
Operational Risk: State Tracking Drift
What to watch: The prompt's retry decision may be correct, but your application's retry counter could be out of sync, causing infinite loops. Guardrail: Never rely solely on the prompt's output to track state. The application harness must enforce a hard limit on retry attempts and override the prompt's 'retry' decision with 'quarantine' if the max attempts are exceeded.
Bad Fit: Undifferentiated Error Handling
Avoid when: All failures in your pipeline are treated the same way (e.g., log and discard). Guardrail: The overhead of an LLM call for classification is wasted if there is only one recovery path. Use this prompt only when you have distinct downstream queues for retry, skip, and quarantine that justify the classification cost.
Copy-Ready Prompt Template
A reusable prompt template for classifying batch processing failures and generating structured remediation plans.
This prompt template is designed to be dropped into a batch processing pipeline's error-handling path. When a batch job completes with partial failures, the system should collect the failed records, their error metadata, and the current retry state, then pass them to this prompt. The model's job is not to fix the data but to classify each failure into a recovery strategy—retry, skip, or quarantine—and produce a machine-readable remediation plan that downstream orchestration logic can execute. The template uses square-bracket placeholders for all dynamic inputs so you can wire it directly into your job runner, Airflow DAG, or stream processor without modifying the instruction structure.
textYou are a batch processing recovery classifier. Your task is to analyze a set of failed records from a data pipeline and produce a structured remediation plan. ## INPUT You will receive: - A list of failed records, each with an error type, error message, record identifier, and the current retry attempt count. - The pipeline's retry policy, including max attempts and backoff strategy. - The pipeline's idempotency configuration (idempotency key field, deduplication window). Failed Records: [FAILED_RECORDS] Retry Policy: [RETRY_POLICY] Idempotency Configuration: [IDEMPOTENCY_CONFIG] ## CLASSIFICATION RULES For each failed record, classify it into exactly one recovery strategy: - **RETRY**: The error is transient (e.g., network timeout, rate limit, temporary downstream unavailability) AND the current attempt count is below the max retry limit. Include a recommended backoff duration in seconds. - **SKIP**: The error is permanent and non-critical (e.g., single-record schema mismatch, known benign data issue, record already exists and idempotency key confirms successful prior processing). The record can be safely discarded without data loss. - **QUARANTINE**: The error is permanent and requires investigation (e.g., data corruption, unexpected null in required field, foreign key violation, poison pill pattern). The record must be preserved for manual review. ## OUTPUT SCHEMA Return a valid JSON object with this exact structure: { "remediation_plan": [ { "record_id": "string", "error_type": "string", "error_message": "string", "current_attempt": number, "recovery_strategy": "RETRY" | "SKIP" | "QUARANTINE", "confidence": number (0.0 to 1.0), "rationale": "string (one sentence explaining the classification)", "retry_backoff_seconds": number | null, "quarantine_reason": "string | null" } ], "summary": { "total_failed": number, "retry_count": number, "skip_count": number, "quarantine_count": number, "requires_human_review": boolean } } ## CONSTRAINTS - Do not invent recovery strategies outside RETRY, SKIP, or QUARANTINE. - If current_attempt equals or exceeds max_attempts, the record must be QUARANTINE or SKIP, never RETRY. - If an idempotency key is present and matches a previously successful record, prefer SKIP with rationale citing idempotency. - Set confidence below 0.7 if the error message is ambiguous or the failure pattern is mixed (e.g., timeout that has occurred on every attempt might indicate a persistent downstream issue rather than a transient one). - For QUARANTINE records, populate quarantine_reason with a specific, actionable description of what needs investigation. - Return ONLY the JSON object. No markdown fences, no commentary. ## EXAMPLES [FEW_SHOT_EXAMPLES]
Adaptation guidance: Replace [FAILED_RECORDS] with a JSON array of failure objects from your batch processor's error log. [RETRY_POLICY] should contain your pipeline's max attempts and backoff configuration as a structured object. [IDEMPOTENCY_CONFIG] should specify the field used for deduplication and the time window. The [FEW_SHOT_EXAMPLES] placeholder is critical for production—include 3-5 examples covering each recovery strategy, especially edge cases like a timeout that has recurred on every attempt (should be QUARANTINE, not RETRY) and a schema mismatch on a non-critical optional field (should be SKIP). If your pipeline uses a dead letter queue, wire the QUARANTINE decisions directly to that queue's producer. For high-throughput pipelines, consider batching failed records into groups of 50-100 to stay within context windows while maintaining classification quality.
Before deploying: Run this prompt against a golden dataset of 50-100 known failures with pre-labeled recovery strategies. Measure precision and recall per strategy—RETRY misclassification causes unnecessary compute waste, SKIP misclassification causes data loss, and QUARANTINE misclassification floods your review queue. Set a minimum confidence threshold (we recommend 0.8) below which records should default to QUARANTINE with a human-review flag. Wire the requires_human_review boolean in the summary to your on-call alerting if true. For idempotency-aware pipelines, add an eval that verifies the model never marks a record as RETRY when the idempotency key confirms prior success.
Prompt Variables
Required inputs for the Partial-Failure Recovery Classification Prompt. Each placeholder must be populated before the prompt is assembled and sent to the model. Validation notes describe how to check the input at the harness level before invocation.
| Placeholder | Purpose | Example | Validation Notes |
|---|---|---|---|
[FAILED_RECORDS] | Array of records that failed upstream processing, each containing the original payload, error metadata, and attempt count. | [{"id": "evt_421", "payload": {...}, "error": {"code": "TIMEOUT", "message": "..."}, "attempt": 2}] | Must be a non-empty JSON array. Each element must contain an 'error' object with a non-null 'code' field. Reject if array is empty or any record is missing an error code. |
[PIPELINE_STAGE] | Identifier for the processing stage where the failure occurred, used to determine applicable recovery strategies. | "payment_processor_ingest_v2" | Must be a non-empty string matching a known stage in the pipeline registry. Validate against an allowlist of registered stage names. Reject unknown stages. |
[RETRY_POLICY] | Current retry configuration including max attempts, backoff strategy, and timeout windows for this pipeline stage. | {"max_attempts": 3, "backoff": "exponential", "base_delay_ms": 1000, "timeout_ms": 30000} | Must be a valid JSON object containing at minimum 'max_attempts' as a positive integer. Validate schema before prompt assembly. If null, the prompt should assume no retry is permitted. |
[IDEMPOTENCY_STORE_STATE] | Current state of the idempotency store for the failed records, including any previously recorded outcomes or in-flight markers. | {"evt_421": {"status": "in_flight", "last_attempt": "2025-03-15T10:30:00Z"}, "evt_422": null} | Must be a JSON object keyed by record ID. Values must be null or objects containing a 'status' field. Validate that keys match the IDs in [FAILED_RECORDS]. Null values indicate no prior state. |
[DOWNSTREAM_HEALTH] | Health status of downstream systems that would receive retried or recovered records. | {"payment_api": "healthy", "audit_log": "degraded", "notification_svc": "healthy"} | Must be a JSON object mapping downstream system names to one of: 'healthy', 'degraded', 'unavailable'. Validate enum values. If null, the prompt should assume all downstream systems are healthy. |
[QUARANTINE_TOPIC] | Destination topic or queue identifier where quarantined records should be routed for manual inspection. | "dlq.payment.manual_review" | Must be a non-empty string. Validate that the topic exists in the messaging infrastructure before prompt assembly. Reject if the topic is not provisioned or accessible. |
[CORRELATION_ID] | Trace identifier linking this classification request to the upstream batch run for observability. | "batch-run-9f86d081-2025-03-15" | Must be a non-empty string. Validate format matches the organization's correlation ID convention. Include in all log output for traceability but do not pass to the model if it adds no classification value. |
Implementation Harness Notes
How to wire the Partial-Failure Recovery Classification Prompt into a resilient batch processing pipeline with idempotency, state tracking, and retry logic.
This prompt is designed to be invoked as a post-processing step within a batch pipeline's error-handling path. When a batch processor encounters a set of failed records, it should package the error context—including the original payload, the error message, the stack trace or error code, and the current retry attempt number—into the prompt's [FAILED_RECORDS] and [ERROR_CONTEXT] placeholders. The model's structured output, which classifies each failure as retryable, skip, or quarantine, then becomes the direct input to the pipeline's recovery orchestrator. Do not use this prompt for real-time, single-record failures where latency is critical; it is optimized for bulk triage of accumulated dead letters or batch-level error logs.
To integrate this into an application, wrap the model call in a function that enforces a strict schema validation layer. The expected output is a JSON array of objects, each with a record_id, error_type, recovery_action, and retry_strategy. Before the orchestrator acts on any decision, validate that every record_id from the input batch is present in the output and that no recovery_action is null. Implement a state-tracking mechanism, such as a Redis hash or a database table keyed by record_id, to store the retry count and last error signature. Before executing a retryable action, check this state store to enforce a maximum retry limit and to detect poison pills—records that fail identically on consecutive attempts. For quarantine actions, publish the record and its classification to a dedicated dead-letter queue for manual inspection. Log every classification decision with the model's confidence_score and the prompt version to create an audit trail for debugging classification drift.
Idempotency is the most critical harness requirement. The recovery orchestrator must be able to re-process the same batch of failures without duplicating successful retries or re-quarantining already-inspected records. Achieve this by having the orchestrator acquire a distributed lock per batch before processing and by writing the final status of each record (retried, skipped, quarantined) to the state store atomically. When choosing a model, prefer one with strong JSON mode and low variance at low temperatures (e.g., temperature=0). Start your evaluation suite by testing against a golden dataset of known transient failures (network timeouts), permanent failures (schema violations), and ambiguous cases (timeouts that have already been retried multiple times). The primary failure mode to monitor in production is the model classifying a permanent failure as retryable, which creates an infinite loop. Mitigate this with the hard retry limit in the state store and an alert that fires if any single record_id cycles through the recovery path more than a configured threshold.
Expected Output Contract
Defines the structured JSON output expected from the Partial-Failure Recovery Classification Prompt. Use this contract to validate the model's response before feeding it into a remediation orchestrator.
| Field or Element | Type or Format | Required | Validation Rule |
|---|---|---|---|
remediation_plan | Array of objects | Must be a non-empty array. If no records are classifiable, return an empty array and set top-level status to 'unable_to_classify'. | |
remediation_plan[].record_id | String | Must match the [INPUT_RECORD_ID] from the failed batch item. Null or missing values cause a schema rejection. | |
remediation_plan[].error_category | Enum: transient | permanent | schema_violation | timeout | unknown | Must be one of the specified enum values. 'unknown' is permitted only when confidence is below the [CONFIDENCE_THRESHOLD]. | |
remediation_plan[].recovery_action | Enum: retry | skip | quarantine | dead_letter | manual_review | Must be consistent with error_category. 'retry' is only valid for 'transient' or 'timeout'. 'manual_review' is required for 'unknown'. | |
remediation_plan[].retry_strategy | Object or null | Required if recovery_action is 'retry'. Must contain 'max_attempts' (integer) and 'backoff_seconds' (integer). Null otherwise. | |
remediation_plan[].idempotency_key | String | Must be a non-empty string derived from the record payload to ensure safe retries. If extraction fails, set to a new UUID v4 string and set a 'idempotency_key_generated' flag to true. | |
remediation_plan[].confidence | Number | Must be a float between 0.0 and 1.0. Values below [CONFIDENCE_THRESHOLD] must force recovery_action to 'manual_review'. | |
remediation_plan[].rationale | String | A concise, non-empty explanation of the classification decision, referencing the specific error signal or log line provided in [ERROR_CONTEXT]. |
Common Failure Modes
What breaks first when classifying failed records for recovery and how to guard against it.
Idempotency Collapse on Retry
What to watch: The prompt classifies the same failure differently on retry, causing the recovery orchestrator to apply conflicting strategies (e.g., retry vs. quarantine) for the same record. This breaks exactly-once processing guarantees. Guardrail: Include the original error signature and a deterministic retry count in the prompt context. Validate that classification output is stable across retries using a golden set of failure signatures.
Transient vs. Permanent Misclassification
What to watch: The model treats a permanent corruption (poison pill) as a transient timeout, causing infinite retry loops that waste compute and block the batch. Conversely, treating a brief network blip as permanent causes unnecessary data loss. Guardrail: Require the prompt to output a discrete recovery_strategy enum (RETRY, SKIP, QUARANTINE) with a mandatory evidence field citing specific error codes or timestamps. Implement a circuit breaker on retry counts.
State Contamination Across Records
What to watch: When processing records in micro-batches, the model leaks context from a previous corrupted record into the classification of a healthy one, causing cascading false quarantines. Guardrail: Strictly isolate each record's prompt context. Do not include neighboring records in the prompt. Validate output cardinality—N records in must produce exactly N independent classifications out.
Schema Drift in Error Payloads
What to watch: The downstream system changes its error response format. The prompt relies on brittle string matching (e.g., "Connection refused") that silently fails against the new structured error object, defaulting everything to UNKNOWN. Guardrail: Abstract error parsing into a pre-processing step that normalizes error codes into a stable schema before the prompt sees them. Test the prompt against both legacy and current error schemas.
Overfitting to Recovery Heuristics
What to watch: The prompt memorizes specific retry windows or backoff strategies instead of classifying the root cause. When operations change the retry policy, the prompt's hardcoded logic conflicts with the system's actual behavior. Guardrail: The prompt must classify the nature of the failure, not prescribe the mechanics of the fix. Keep retry timing and backoff logic in the application harness, outside the model's decision boundary.
Quarantine Flooding from Downstream Outages
What to watch: A total downstream outage causes every record to fail with a timeout. The prompt classifies the entire batch as QUARANTINE, overwhelming the dead-letter store and halting the pipeline. Guardrail: Add a pre-prompt health check. If the failure rate exceeds a threshold (e.g., >50%), bypass the model and route the entire batch to a circuit-breaker state. The prompt should only handle partial-failure scenarios.
Evaluation Rubric
Criteria for testing the Partial-Failure Recovery Classification Prompt before production deployment. Each row defines a pass standard, a failure signal, and a concrete test method.
| Criterion | Pass Standard | Failure Signal | Test Method |
|---|---|---|---|
Error Type Classification Accuracy | Correctly classifies >= 95% of records into [ERROR_TYPE] categories (Transient, Permanent, Unknown) compared to a labeled golden dataset. | Misclassifies a permanent schema error as transient, causing an infinite retry loop. | Run prompt against a golden dataset of 200 pre-labeled failure records. Assert F1 score >= 0.95 for each class. |
Recovery Strategy Appropriateness | Assigns [RECOVERY_STRATEGY] (Retry, Skip, Quarantine) that matches the runbook for the given [ERROR_TYPE] in >= 98% of cases. | Assigns 'Skip' to a transient network timeout, resulting in silent data loss. | Validate strategy assignment against a decision table mapping [ERROR_TYPE] to expected [RECOVERY_STRATEGY]. Assert accuracy >= 98%. |
Idempotency Key Extraction | Extracts a non-null [IDEMPOTENCY_KEY] for every record where [RECOVERY_STRATEGY] is 'Retry'. | Returns null or empty string for [IDEMPOTENCY_KEY] on a retry-eligible record, causing duplicate processing. | Parse output for all records with [RECOVERY_STRATEGY] = 'Retry'. Assert [IDEMPOTENCY_KEY] is not null and matches a valid field path from the original payload. |
Retry State Tracking | Correctly increments [RETRY_ATTEMPT] count and updates [NEXT_RETRY_AT] timestamp based on an exponential backoff strategy. | [RETRY_ATTEMPT] fails to increment after a failed retry, causing the system to lose track of attempts. | Simulate a second-pass input with a prior failure record. Assert [RETRY_ATTEMPT] = 2 and [NEXT_RETRY_AT] > previous timestamp. |
Quarantine Reason Clarity | Provides a specific, non-generic [QUARANTINE_REASON] for every record with [RECOVERY_STRATEGY] = 'Quarantine'. | Returns a generic reason like 'Error occurred' instead of a specific corruption signature. | Check all quarantined records. Assert [QUARANTINE_REASON] length > 20 characters and contains a reference to the specific field or violation. |
Output Schema Compliance | Output is valid JSON matching the [OUTPUT_SCHEMA] for all records, with no missing required fields. | Output is missing the [RECOVERY_STRATEGY] field for a record, breaking the downstream dispatcher. | Validate the entire batch output against the strict [OUTPUT_SCHEMA] using a JSON Schema validator. Assert zero validation errors. |
Confidence Threshold Adherence | Returns [CONFIDENCE_SCORE] >= 0.85 for all classifications. Scores below threshold correctly trigger [RECOVERY_STRATEGY] = 'Quarantine'. | Returns a high confidence score for a completely novel error type, routing it to an automated retry instead of quarantine. | Inject 20 novel, out-of-distribution error messages. Assert [CONFIDENCE_SCORE] < 0.85 and [RECOVERY_STRATEGY] = 'Quarantine' for all of them. |
Batch Consistency | Produces the same [RECOVERY_STRATEGY] for identical failure records within the same batch and across different batches. | Two identical records in the same batch receive different recovery strategies, causing non-deterministic pipeline behavior. | Duplicate a failure record 5 times within a single batch and across 3 separate runs. Assert identical [RECOVERY_STRATEGY] and [ERROR_TYPE] for all copies. |
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 model call and lighter validation. Focus on getting the classification logic right before adding retry state tracking. Start with a small batch of known failure types to calibrate the error categories.
Prompt snippet
codeClassify each failed record by error type and recovery strategy. [FAILED_RECORDS] Return JSON with: error_category, recovery_action (retry|skip|quarantine), reason
Watch for
- Missing idempotency checks on retry decisions
- Overly broad error categories that merge distinct failure modes
- No confidence scoring, so ambiguous failures get arbitrary routing

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