Inferensys

Prompt

Partial Failure Detection Prompt for Multi-Step Agents

A practical prompt playbook for detecting silent partial failures in sequential agent tool chains, producing a step-by-step health report before downstream corruption occurs.
Developer demonstrating multi-agent tool use, agent tool selection interface on laptop, casual tech demo moment.
PROMPT PLAYBOOK

When to Use This Prompt

Define the job, ideal user, and constraints for the Partial Failure Detection Prompt.

This prompt is for agent operators and platform engineers who run sequential tool chains where intermediate steps can fail silently. The core job-to-be-done is detecting partial failures—substeps that completed without throwing an exception but produced degraded, empty, or incorrect results—before those failures corrupt downstream reasoning. The ideal user is someone integrating multi-step agent workflows into production systems, such as a backend engineer wiring a research agent to a vector database and a web search tool, or an SRE running a diagnostic agent that queries multiple observability APIs in sequence. You need this prompt when your agent's execution graph is linear or branching but each step's output becomes the next step's input, creating a cascading failure risk.

Use this prompt when a step's return code or HTTP 200 is insufficient to guarantee correctness. For example, a web search tool might return a list of URLs with empty snippets, a code execution sandbox might return a zero-byte file, or a database query might return an empty result set when a non-empty one is expected. The prompt requires the full execution trace as input: the original objective, each step's intended function, the tool call arguments, and the raw output. It produces a structured health report classifying each step as SUCCESS, DEGRADED, or FAILURE, with evidence and a downstream corruption risk score. Do not use this prompt for single-step workflows, for agents with robust built-in error handling that already surfaces structured exceptions, or when the cost of the detection pass exceeds the cost of simply re-running the entire workflow.

Before implementing this prompt, ensure you have access to the complete step execution log, including tool call parameters and raw responses. If your agent framework does not log this data, instrument it first. The prompt is designed for post-hoc analysis after a multi-step run completes, not for real-time interception. For high-risk workflows involving mutable resources—database writes, cloud provisioning, or file system changes—pair this prompt with a human review step before any automated rollback or retry logic is triggered. The next section provides the copy-ready template you can adapt to your agent's specific tool set and failure taxonomy.

PRACTICAL GUARDRAILS

Use Case Fit

Where the Partial Failure Detection Prompt delivers value and where it introduces risk. Use these cards to decide if this prompt fits your agent architecture before integrating it into a production pipeline.

01

Good Fit: Sequential Tool Chains

Use when: your agent executes 3+ tools in sequence where each step depends on the previous step's output. Why: a silent failure in step 2 corrupts steps 3 through N. This prompt catches partial failures before they cascade.

02

Bad Fit: Single Atomic Actions

Avoid when: the agent performs exactly one tool call per user request with no downstream dependencies. Why: the detection overhead adds latency and token cost without providing value. A simple output validator is sufficient.

03

Required Inputs

You must provide: the original plan with ordered substeps, the output or return value from each executed step, and the expected success criteria per step. Without these, the prompt cannot distinguish between degraded success and silent failure.

04

Operational Risk: False Negatives

What to watch: the model may classify a subtly degraded output as fully successful, allowing corruption to propagate. Guardrail: pair this prompt with a structural output schema check. If the schema is violated, override the model's verdict.

05

Operational Risk: Over-Blocking

What to watch: the model flags acceptable partial results as failures, halting the agent unnecessarily. Guardrail: implement a severity threshold. Allow warnings to proceed with a flag; only block on critical failures that would corrupt downstream reasoning.

06

Latency Budget Impact

What to watch: adding this detection step after every tool call doubles the LLM round-trips in your pipeline. Guardrail: run the detection prompt in parallel across independent steps, or batch multiple step outputs into a single detection call when dependencies allow.

PROMPT PLAYBOOK

Copy-Ready Prompt Template

A reusable prompt template for detecting partial failures across multi-step agent executions, producing a structured health report with per-step success, failure, and degradation assessments.

This template is designed to be dropped into an agent harness after a multi-step execution completes. It takes the original plan, the execution trace, and the outputs from each step, then produces a structured health report that identifies which substeps succeeded, which failed, and which produced degraded results. The prompt is built to catch cascading failure blindness—the most dangerous failure mode in sequential tool chains, where an early partial failure goes undetected and corrupts every downstream step.

text
You are an agent execution auditor. Your job is to analyze a multi-step agent execution trace and produce a structured health report identifying which steps succeeded, which failed, and which produced degraded results.

## INPUTS

### Original Plan
[PLAN]

### Execution Trace
[EXECUTION_TRACE]

### Step Outputs
[STEP_OUTPUTS]

### Success Criteria Per Step
[SUCCESS_CRITERIA]

### Known Failure Modes
[KNOWN_FAILURE_MODES]

## OUTPUT SCHEMA

Return a JSON object with this structure:

{
  "workflow_id": "string",
  "overall_status": "success | partial_failure | failure | degraded",
  "steps": [
    {
      "step_id": "string",
      "step_name": "string",
      "status": "success | failure | degraded | skipped | unknown",
      "evidence": ["string"],
      "failure_mode": "string | null",
      "degradation_details": {
        "expected": "string",
        "actual": "string",
        "gap": "string"
      } | null,
      "downstream_impact": ["string"],
      "recoverable": true | false,
      "recommended_action": "retry | skip | rollback | escalate | continue"
    }
  ],
  "cascading_failures": [
    {
      "root_step_id": "string",
      "affected_steps": ["string"],
      "propagation_path": "string"
    }
  ],
  "summary": "string",
  "requires_human_review": true | false
}

## CONSTRAINTS

1. Do not assume a step succeeded just because it produced output. Check the output against the success criteria.
2. Flag any step where the output is valid but semantically degraded (e.g., correct structure but incomplete data).
3. For each failed or degraded step, identify which downstream steps consumed its output and assess whether corruption propagated.
4. If you cannot determine a step's status from the available evidence, mark it as "unknown" and request human review.
5. Do not recommend "continue" for any step where downstream corruption is confirmed.
6. Prioritize false negatives over false positives: it is safer to flag a healthy step for review than to miss a real failure.

## RISK LEVEL
[RISK_LEVEL]

## EXAMPLES
[EXAMPLES]

To adapt this template, replace each square-bracket placeholder with the relevant data from your agent runtime. [PLAN] should contain the original task decomposition with expected outputs per step. [EXECUTION_TRACE] should include tool calls, responses, and any error messages. [STEP_OUTPUTS] should contain the actual outputs from each completed step. [SUCCESS_CRITERIA] should define what constitutes success for each step—this is critical because the model cannot infer your domain-specific expectations without explicit criteria. [KNOWN_FAILURE_MODES] should list common failure patterns you have observed in your tool chain, such as silent API timeouts, partial writes, or schema drift. [RISK_LEVEL] should be set to high if any step mutates production resources, triggers financial transactions, or affects user-facing state; this will tighten the model's threshold for flagging degradation. [EXAMPLES] should include at least two annotated traces: one with a clean execution and one with a known partial failure, showing the expected health report for each.

Before deploying this prompt into a production harness, validate the output schema with a JSON schema validator and run at least 20 annotated traces through it to measure precision and recall on failure detection. Pay special attention to false negatives on degraded steps—these are the failures that will compound silently. If your agent operates on mutable resources, pair this prompt with a side-effect detection check and require human review when overall_status is partial_failure or degraded. Do not use this prompt as a replacement for step-level precondition and postcondition checks; it is a post-hoc audit layer that catches what those checks miss.

IMPLEMENTATION TABLE

Prompt Variables

Required inputs for the Partial Failure Detection Prompt. Each placeholder must be populated before the prompt is assembled and sent. Missing or malformed inputs are the most common cause of false-negative failure reports.

PlaceholderPurposeExampleValidation Notes

[ORIGINAL_OBJECTIVE]

The top-level goal the agent was instructed to achieve across all steps

Provision a staging environment for the payment service and run the integration test suite

Must be a non-empty string. If the objective is compound, break it into a bullet list before insertion to improve step-to-goal alignment scoring.

[STEP_EXECUTION_LOG]

A structured log of every step the agent attempted, including tool calls, arguments, timestamps, and raw responses

JSON array of step objects with fields: step_id, tool_name, arguments, raw_output, timestamp, declared_status

Must be valid JSON. Each step object requires step_id and raw_output at minimum. Null raw_output is allowed only if the step failed before producing output. Validate array length matches expected step count.

[EXPECTED_STEP_COUNT]

The number of steps the agent was expected to execute according to the original plan

5

Must be a positive integer. Used to detect truncated logs and missing steps. If the plan allows variable step counts, provide the minimum expected count and note the variance in [CONSTRAINTS].

[STEP_SUCCESS_CRITERIA]

Per-step definitions of what constitutes success, partial success, or failure for each step type

Step 3: DB migration must return exit code 0 and contain no 'ERROR' lines in stdout. Step 4: Health check must return HTTP 200 within 3 retries.

Must be a non-empty string or structured object mapping step identifiers to criteria. Vague criteria like 'should work' produce unreliable failure detection. Prefer observable signals: exit codes, HTTP status, log patterns, field presence.

[DOWNSTREAM_DEPENDENCIES]

A map of which steps depend on which prior steps, used to assess cascading failure risk

Step 4 depends on Step 3. Step 5 depends on Step 3 and Step 4.

Must be parseable as a directed acyclic graph. Cycles indicate a planning error and should be rejected before prompt assembly. If no dependencies exist, explicitly state 'No inter-step dependencies' to prevent the model from hallucinating relationships.

[OUTPUT_SCHEMA]

The expected JSON schema for the health report output, defining required fields and types

See Output Contract table for field-level schema

Must be a valid JSON Schema object or a plain-text description of required fields. If using a plain-text description, include explicit type constraints for each field to reduce format drift.

[CONSTRAINTS]

Boundary conditions, edge-case handling rules, and severity classification thresholds

Treat HTTP 5xx as failure. Treat timeout after 30s as degraded. Do not flag warnings as failures unless they appear in the error stream. If a step was skipped due to prior failure, classify as 'not_executed' not 'failed'.

Must be a non-empty string. Missing constraints cause the model to apply inconsistent severity rules. Include explicit rules for timeout, retry exhaustion, skipped steps, and partial output handling.

PROMPT PLAYBOOK

Implementation Harness Notes

How to wire the partial failure detection prompt into an agent runtime with validation, retries, and logging.

The partial failure detection prompt is not a standalone artifact; it is a gating function that sits between agent steps. Wire it into your agent's execution loop immediately after a multi-step tool chain completes and before any downstream step consumes the output. The prompt expects a structured input containing the original objective, the ordered list of substeps with their expected outcomes, and the actual outputs or side effects produced. Assemble this input programmatically from your agent's trace log, tool-call history, and state snapshot. Do not rely on the agent's own summary of what happened—use the raw tool outputs and return codes as ground truth. The model's job is to compare expected versus actual, not to reconstruct events from memory.

For the integration, wrap the prompt in a validation harness that enforces the output schema before the agent proceeds. The expected output is a JSON object with a step_results array, where each element contains step_id, status (one of success, failure, degraded), evidence, and cascading_risk (boolean). Implement a post-processing validator that rejects any response missing required fields or containing status values outside the enum. If validation fails, retry the prompt once with the validation error message appended as additional context. If the retry also fails, escalate to a human operator or trigger a safe abort—never proceed with an unvalidated health report. Log every invocation, including the input assembly, raw model response, validation result, and the final gating decision, to an audit trail for debugging cascading failures later.

Model choice matters here. Use a model with strong instruction-following and structured output capabilities, such as GPT-4o, Claude 3.5 Sonnet, or Gemini 1.5 Pro. Avoid smaller or older models that may conflate degraded and failure statuses or miss subtle evidence of partial completion. Set temperature to 0 or near-zero to minimize variance in status classification. If your agent operates in a high-risk domain—such as database migrations, financial transactions, or infrastructure changes—add a human review step for any health report containing a failure or cascading_risk: true flag before the next step executes. The prompt is a detection tool, not an auto-remediation tool; it tells you what broke, but deciding whether to roll back, retry, skip, or abort is a separate decision prompt that should follow this one.

IMPLEMENTATION TABLE

Expected Output Contract

Define the exact structure, types, and validation rules for the partial failure detection report. Use this contract to build a parser that gates the agent's next step.

Field or ElementType or FormatRequiredValidation Rule

overall_status

enum: [healthy, degraded, failed]

Must match one of the three enum values. If any step has status 'failed', overall_status must be 'failed' or 'degraded'.

steps

array of objects

Must be a non-empty array. If empty, the entire output is invalid. Validate array length >= 1.

steps[].step_id

string

Must match the exact step identifier from the input [STEP_PLAN]. Regex check for non-empty, no whitespace.

steps[].status

enum: [success, degraded, failed, skipped]

Must be one of the four enum values. A 'skipped' status requires a non-null skip_reason.

steps[].evidence_summary

string

Must be a non-empty string. If status is 'failed' or 'degraded', must contain a concrete error signal, not just 'it failed'.

steps[].cascading_risk

enum: [none, low, high, critical]

If status is 'success', cascading_risk must be 'none'. If status is 'failed', risk must be 'high' or 'critical'.

steps[].downstream_dependencies

array of strings

If present, each string must match a step_id from another step in the plan. Validate cross-reference integrity.

recommendation

enum: [proceed, retry, skip_and_proceed, abort]

If overall_status is 'failed', recommendation must be 'retry' or 'abort'. If 'healthy', must be 'proceed'.

PRACTICAL GUARDRAILS

Common Failure Modes

Partial failures in multi-step agents are the hardest to debug because the agent continues executing with corrupted state. These are the most common failure patterns and how to catch them before they cascade.

01

Silent Null Propagation

What to watch: A step returns a valid-looking JSON structure but critical fields are null, empty strings, or missing. The next step consumes these nulls without error, producing confident but wrong outputs downstream. Guardrail: Add a Null and Empty Value Detection Prompt after every data-mutating step. Require field-level null audits with severity classification before the output is passed to the next step's input context.

02

False-Positive Step Completion

What to watch: A tool returns a success status code or a natural-language confirmation, but the actual system state didn't change. Common with async operations, eventual consistency stores, or tools that return 200 OK on no-op writes. Guardrail: Use a Step Completion Confirmation Prompt that requires evidence of state change, not just status codes. Compare pre- and post-execution snapshots when the resource is mutable.

03

Unintended Side Effect Contamination

What to watch: A step modifies resources beyond its declared scope—updating audit timestamps, triggering cascading deletes, or altering shared configuration. The agent has no awareness of these side effects, and downstream steps operate on corrupted assumptions. Guardrail: Deploy a Side Effect Detection Prompt after every step that touches mutable resources. Require a catalog of detected side effects with severity ratings before the next planning cycle.

04

Schema Drift Between Steps

What to watch: Step A produces output matching schema version 1, but Step B expects schema version 2. The agent doesn't detect the mismatch and passes malformed data forward. This is common when tools are updated independently or when LLM outputs drift from the expected contract. Guardrail: Insert an Output Contract Validation Prompt between every step boundary. Compare actual output against the declared schema with field-level mismatch reporting. Fail fast on structural violations.

05

Cascading Hallucination from One Bad Step

What to watch: A single step hallucinates a value, entity, or relationship. Because the agent trusts its own outputs, that hallucination becomes ground truth for all subsequent reasoning, compounding errors across the remaining steps. Guardrail: Use a Downstream Corruption Guard Prompt that evaluates whether the current step output contains errors, hallucinations, or malformed data that would poison the next step's input. Block propagation when confidence is low.

06

Premature Workflow Success Declaration

What to watch: The agent declares the workflow complete because all steps returned without errors, but the final state doesn't match the original objective. Partial completions, skipped side effects, or degraded outputs are treated as full success. Guardrail: Add an End-to-End Workflow Success Assertion Prompt as the final gate. Compare the final state against the original goal with per-step contribution analysis. Require explicit evidence that every objective was met.

IMPLEMENTATION TABLE

Evaluation Rubric

Use this rubric to test whether the Partial Failure Detection Prompt produces accurate, actionable health reports before shipping to production. Each criterion targets a known failure mode in multi-step agent validation.

CriterionPass StandardFailure SignalTest Method

Step Status Classification

Every declared step is classified as SUCCESS, FAILURE, or DEGRADED with a non-empty evidence string

Missing step in report; ambiguous status label; empty evidence field

Run 10 traces with known step outcomes and assert classification accuracy >= 95%

Cascading Failure Flagging

Report includes a cascading_failure_risk boolean and lists downstream steps that consumed output from a failed step

cascading_failure_risk is false when a FAILURE step's output was used by a later step; affected steps not enumerated

Inject a mid-pipeline failure and verify the flag is true with correct downstream step IDs listed

Evidence Grounding

Every status claim is supported by a concrete observation from tool output, return code, or state snapshot

Evidence contains hallucinated values not present in the actual step output; evidence is generic prose without specific values

Diff evidence strings against ground-truth tool outputs; flag any claim with no matching substring or value

Degraded Result Detection

Steps that completed but produced partial, truncated, or low-confidence output are classified as DEGRADED with a severity enum

DEGRADED steps misclassified as SUCCESS; severity missing or always set to LOW

Test with intentionally truncated JSON, missing optional fields, and low-confidence model outputs; assert DEGRADED rate matches expected

Report Completeness

Report includes total_steps, success_count, failure_count, degraded_count, and an overall_health enum

Counts don't sum to total_steps; overall_health is HEALTHY when failures exist; fields missing

Parse output schema and validate count arithmetic; assert schema conformance on 20 varied traces

Actionable Remediation Hints

Each FAILURE or DEGRADED step includes a remediation_hint string suggesting retry, skip, rollback, or escalate

Remediation hints are empty, identical across all failures, or recommend retry for non-idempotent steps

Review hints for 10 failure scenarios; assert each hint is non-empty, step-specific, and appropriate for the failure type

False-Positive Resistance

Steps that succeeded with valid output are not flagged as FAILURE or DEGRADED due to benign warnings or non-zero exit codes that indicate success

Report flags a step as FAILURE because of a warning log line; exit code 0 treated as failure

Run steps with known warning-level stderr and exit code 0; assert SUCCESS classification rate >= 98%

Schema Conformance

Output matches the declared JSON schema with all required fields present and correct types

Missing required fields; type mismatches; extra fields that break downstream parsers

Validate output against JSON Schema using a programmatic validator; reject any response that fails strict validation

ADAPTATION OPTIONS

Adapt This Prompt

How to adapt

Use the base prompt with a single model call and no external validation harness. Focus on getting structured step-by-step health reports before adding tool integration. Replace [TOOL_LOG] with a manually pasted execution trace. Remove strict schema enforcement and accept markdown tables or bulleted lists as output.

Prompt snippet

code
Analyze this agent execution trace and identify which steps succeeded, failed, or produced degraded results:

[TOOL_LOG]

Return a health report with step name, status, and evidence.

Watch for

  • The model inventing step names not present in the trace
  • Overly confident success declarations when evidence is ambiguous
  • Missing degraded-result detection entirely
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.