This prompt is for agent developers and platform engineers who need their multi-step tool chains to survive partial failure without losing completed work or producing inconsistent state. The job-to-be-done is generating explicit instructions that tell an agent how to preserve successful step results, report which steps failed and why, and decide whether to commit partial work, roll back, or escalate. The ideal user already has a working tool chain but has observed production incidents where one failed step caused the entire workflow to discard valid results, or where partial commits left downstream systems in an unrecoverable state. You need this prompt when your agent orchestrates three or more tool calls with data dependencies, when some tools have side effects that cannot be easily undone, or when the business can tolerate partial completion but cannot tolerate silent data corruption.
Prompt
Partial Success Handling in Tool Chains Prompt

When to Use This Prompt
Define the job, reader, and constraints for handling partial success in multi-step tool chains.
Do not use this prompt for single-tool invocations, simple retry loops, or workflows where atomicity is already guaranteed by the underlying system. If your tool chain is stateless and idempotent by design, a basic error-handling wrapper is sufficient. This prompt becomes necessary when you cross the threshold into multi-step workflows with mixed success states—for example, an agent that successfully creates a ticket in one system, updates a record in a second, but fails to send a notification in a third. Without explicit partial-success handling, the agent will either discard the ticket and update (wasting work) or silently proceed (leaving the notification gap undetected). The prompt template requires you to supply the tool sequence, expected outputs per step, side-effect classifications, and your organization's policy on partial commits. If you cannot articulate which steps are reversible and which are not, resolve that ambiguity before using this prompt.
The output you should expect is a structured handling plan that includes: a per-step success/failure classification, rules for preserving successful results, a decision matrix for commit-vs-rollback based on failure location and severity, and a user-facing summary template that honestly reports partial completion. Wire this into your agent's execution loop after each tool call returns, not just at the end of the sequence. The most common production failure mode is not the prompt itself but the integration point—agents that buffer all results and only apply the handling logic after the final step, by which time partial state has already leaked into downstream systems. Start by implementing the per-step preservation logic first, then add the commit decision logic, and only then expose partial-success summaries to end users. If any step in your chain triggers irreversible external effects (payments, provisioning, credential issuance), insert a human approval gate before that step executes, regardless of what the prompt's decision matrix recommends.
Use Case Fit
Where the Partial Success Handling prompt delivers value and where it introduces unacceptable risk.
Good Fit: Multi-Step Data Pipelines
Use when: your agent runs extract-transform-load sequences where partial results are valuable and full rollback is expensive. Guardrail: require the prompt to output a structured manifest of succeeded, failed, and skipped steps with preserved intermediate outputs.
Good Fit: Batch Processing with Independent Items
Use when: processing lists of independent items where individual failures should not block the batch. Guardrail: include explicit per-item status tracking and aggregate summary requirements in the output schema.
Bad Fit: Atomic Transactions
Avoid when: all steps must succeed or none should take effect, such as financial transfers or database commits. Guardrail: use transaction managers or saga patterns instead; this prompt should explicitly refuse partial commits for atomic operations.
Bad Fit: Irreversible Side Effects
Avoid when: tool calls produce permanent external effects like sending emails, creating accounts, or publishing content. Guardrail: require human approval gates before any irreversible action and never allow partial success to silently commit side effects.
Required Input: Tool Success Criteria
Risk: without explicit per-step success definitions, the model cannot reliably distinguish partial success from silent failure. Guardrail: provide a schema mapping each tool call to its expected output shape, required fields, and validation assertions.
Operational Risk: Inconsistent State Propagation
Risk: downstream steps consume partial outputs and produce corrupted results without detection. Guardrail: require the prompt to validate intermediate outputs before passing them forward and flag any data integrity gaps in the final report.
Copy-Ready Prompt Template
A reusable prompt template with square-bracket placeholders for handling partial success in multi-step tool chains.
This prompt template instructs the model to execute a sequence of tool calls while explicitly handling partial success. It separates the workflow into three phases: execution with per-step result tracking, a structured summary of successes and failures, and a decision framework for whether to commit partial work, roll back, or escalate. Use this template when your agent orchestrates multiple dependent or independent tool calls where some steps may fail while others succeed, and you need the agent to preserve successful results rather than discarding everything on first failure.
codeYou are an agent executing a multi-step tool workflow. Your primary directive is to maximize useful completion while preventing data inconsistency. Follow these rules: ## EXECUTION PHASE 1. Execute each tool call in the specified order: [TOOL_SEQUENCE]. 2. After each tool call, record the result in this structure: - step_id: [STEP_IDENTIFIER] - tool_name: [TOOL_NAME] - status: SUCCESS | FAILURE | PARTIAL - output_summary: [BRIEF_RESULT_DESCRIPTION] - error_details: [ERROR_MESSAGE_IF_FAILED] - data_preserved: [KEY_OUTPUT_FIELDS_SAVED] 3. If a step fails, do NOT discard successful results from previous steps. 4. If a step produces partial results (e.g., batch operation with some items failed), preserve the successful subset and note which items failed. ## DECISION PHASE After all steps complete or an abort condition is triggered, evaluate the results against these rules: - If [COMMIT_THRESHOLD]% or more steps succeeded AND no data integrity constraint is violated, mark the workflow as PARTIAL_SUCCESS and preserve all successful outputs. - If a step failure makes downstream steps impossible due to missing dependencies, skip those dependent steps and mark them as BLOCKED. - If [ABORT_CONDITIONS] are met, stop execution, preserve results so far, and escalate. - If any step violates [DATA_INTEGRITY_RULES], mark the entire workflow as REQUIRES_ROLLBACK and list the compensating actions needed. ## OUTPUT FORMAT Return a JSON object with this schema: { "workflow_status": "COMPLETE" | "PARTIAL_SUCCESS" | "REQUIRES_ROLLBACK" | "ESCALATED", "steps_executed": [ { "step_id": "string", "tool_name": "string", "status": "SUCCESS" | "FAILURE" | "PARTIAL" | "BLOCKED" | "SKIPPED", "output_summary": "string", "error_details": "string | null", "data_preserved": {} } ], "successful_outputs": {}, "failed_steps": [], "blocked_steps": [], "rollback_actions": [], "escalation_reason": "string | null", "recommendation": "string" } ## CONSTRAINTS - Never fabricate successful outputs for failed steps. - Never silently discard partial results without recording them. - If [HUMAN_APPROVAL_GATES] are configured, pause and request approval before executing [IRREVERSIBLE_ACTIONS]. - Respect [TOOL_CALL_BUDGET] and stop if exceeded. - Apply [OUTPUT_VALIDATION_RULES] to each step's output before passing it to the next step. ## CONTEXT [WORKFLOW_CONTEXT] ## INPUT [USER_INPUT_OR_TRIGGER_EVENT]
To adapt this template, replace the square-bracket placeholders with your specific workflow configuration. [TOOL_SEQUENCE] should contain the ordered list of tool calls with their input mappings. [COMMIT_THRESHOLD] defines what percentage of steps must succeed to consider the workflow partially successful—set this based on your business tolerance for incomplete results. [ABORT_CONDITIONS] should enumerate specific failure patterns that require immediate termination, such as authentication failures, data corruption detected, or critical dependency chain breaks. [DATA_INTEGRITY_RULES] must specify the invariants that cannot be violated, such as "order total must match line item sum" or "user identity must be consistent across all steps." [HUMAN_APPROVAL_GATES] should list which actions require human review before execution, particularly for write operations, financial transactions, or data deletion. Before deploying, test this prompt against scenarios where the first step fails, a middle step fails, the last step fails, and multiple non-adjacent steps fail—each should produce a different but correct output structure with appropriate rollback or partial-success decisions.
Prompt Variables
Required inputs for the Partial Success Handling in Tool Chains prompt. Each variable must be populated before the prompt is assembled and sent to the model. Missing or malformed variables will cause the prompt to produce unreliable partial-success instructions.
| Placeholder | Purpose | Example | Validation Notes |
|---|---|---|---|
[TOOL_CHAIN_STEPS] | Ordered list of tool calls in the sequence, each with a unique step ID, tool name, and purpose | [{"step_id":"fetch_invoice","tool":"db_query","purpose":"Retrieve invoice record"},{"step_id":"validate_line_items","tool":"schema_validator","purpose":"Check line item schema"}] | Must be a valid JSON array with at least 2 steps. Each step must have step_id, tool, and purpose fields. Reject if any step_id is duplicated. |
[STEP_RESULTS] | Map of step_id to execution outcome including status, output payload, and error details if failed | {"fetch_invoice":{"status":"success","output":{"invoice_id":"INV-42"}},"validate_line_items":{"status":"failed","error":{"code":"SCHEMA_MISMATCH","message":"Missing required field 'quantity'"}}} | Must be a valid JSON object. Each key must match a step_id from [TOOL_CHAIN_STEPS]. Status must be one of 'success', 'failed', or 'timeout'. Failed steps must include an error object with code and message. |
[COMMIT_POLICY] | Rules for whether partial work can be committed, including which steps are reversible and which require atomic completion | {"allow_partial_commit":true,"reversible_steps":["fetch_invoice"],"atomic_groups":[["validate_line_items","update_ledger"]],"max_partial_ratio":0.7} | Must be a valid JSON object. If allow_partial_commit is true, reversible_steps must be a non-empty array. atomic_groups must be an array of arrays of step_ids. max_partial_ratio must be a float between 0.0 and 1.0. |
[OUTPUT_SCHEMA] | Expected structure for the partial success report including preserved results, failed steps, and commit decision | {"type":"object","required":["overall_status","preserved_results","failed_steps","commit_decision"],"properties":{"overall_status":{"enum":["full_success","partial_success","full_failure"]},"preserved_results":{"type":"array"},"failed_steps":{"type":"array"},"commit_decision":{"enum":["commit_partial","rollback_all","hold_for_review"]}}} | Must be a valid JSON Schema object. Required fields must include overall_status, preserved_results, failed_steps, and commit_decision. Enum values must be present and non-empty. |
[DATA_CONSISTENCY_RULES] | Integrity constraints that must hold across preserved results, including foreign key relationships and state invariants | ["invoice_id must exist in invoices table for any preserved line item","ledger_balance must equal sum of committed line item totals","no orphaned payment records allowed"] | Must be a non-empty array of strings. Each rule must reference specific fields or entities. Reject if any rule is empty or contains only generic language like 'data must be consistent'. |
[ESCALATION_THRESHOLD] | Conditions that trigger human review instead of automated commit or rollback, including failure count, data volume, and risk level | {"max_failed_steps":2,"min_success_ratio":0.5,"high_risk_tools":["update_ledger","send_payment"],"require_approval_if_high_risk_fails":true} | Must be a valid JSON object. max_failed_steps must be a positive integer. min_success_ratio must be a float between 0.0 and 1.0. high_risk_tools must be an array of tool names present in [TOOL_CHAIN_STEPS]. |
[USER_COMMUNICATION_TEMPLATE] | Template for how partial success should be communicated to the end user, including what was saved, what failed, and next steps | {"success_summary":"Successfully completed {completed_count} of {total_count} steps.","failure_detail":"Step '{step_name}' failed: {error_message}","next_steps":"Your {preserved_items} have been saved. A support ticket has been created for the failed steps."} | Must be a valid JSON object with success_summary, failure_detail, and next_steps fields. Each field must be a non-empty string. Placeholders in curly braces are allowed and will be resolved at runtime. |
[ROLLBACK_INSTRUCTIONS] | Step-by-step instructions for reversing committed work if the commit decision is rollback_all, including ordering and idempotency | ["Delete ledger entry for invoice INV-42 using transaction ID from step update_ledger","Restore invoice status to 'pending' in invoices table","Verify no orphaned audit log entries remain"] | Must be a non-empty array of strings. Each instruction must reference a specific step or entity. Reject if instructions are generic like 'undo all changes'. Order matters and will be executed sequentially. |
Implementation Harness Notes
How to wire the partial success prompt into an agent orchestration loop with validation, state preservation, and decision gates.
This prompt is designed to sit between tool execution and the agent's next planning step. After a multi-step tool chain completes—or halts mid-sequence—you feed the raw results, error payloads, and the original plan into this prompt. Its job is to produce a structured partial success report that downstream code can act on without ambiguity. The prompt does not execute tools or make commit decisions; it classifies outcomes, preserves successful work, and recommends next actions. Your orchestration harness must enforce those recommendations through explicit control flow, not by trusting the model to self-limit.
Wire the prompt into your agent loop as a post-execution analysis step. After each tool sequence completes, capture three inputs: the original execution plan with per-step success criteria, the ordered list of tool call results including status codes and error bodies, and any intermediate state artifacts produced by successful steps. Feed these into the prompt template using the [EXECUTION_PLAN], [TOOL_RESULTS], and [INTERMEDIATE_STATE] placeholders. Parse the output against a strict schema that includes completion_status (enum: full_success, partial_success, full_failure), preserved_results (array of step outputs to keep), failed_steps (array with error classification and retry eligibility), compensation_required (boolean), and recommended_action (enum: commit_partial, rollback_all, retry_failed, escalate). Validate that every step in the input plan appears in either preserved_results or failed_steps—missing steps indicate a hallucinated or truncated analysis. Log mismatches as critical errors and escalate to a human operator rather than silently proceeding with incomplete state.
The highest-risk failure mode is the model recommending commit_partial when the system of record cannot accept incomplete transactions. Your harness must enforce a policy layer above the prompt's recommendation. Maintain a registry of tool chains marked as atomic—where partial commit is forbidden regardless of the model's output. For atomic chains, override any commit_partial recommendation to rollback_all and trigger compensating actions using the saga pattern. For non-atomic chains, gate commit_partial on a human approval step if the preserved results include writes to production databases, customer-facing state, or financial records. Log every override decision with the model's original recommendation, the policy rule applied, and the operator's approval status. This audit trail is essential for debugging production incidents where the model's partial success analysis was correct but the business rules required a different outcome. Test this harness with injected failures at every step position—first step, middle step, last step—and verify that the combined prompt-plus-policy system produces the expected commit, rollback, or escalation behavior without data inconsistency.
Expected Output Contract
Define the structure, types, and validation rules for the partial success report. Use this contract to parse and validate the agent's output before passing it to downstream systems or human reviewers.
| Field or Element | Type or Format | Required | Validation Rule |
|---|---|---|---|
overall_status | enum: ['complete_success', 'partial_success', 'complete_failure'] | Must exactly match one of the three enum values. Reject any other string. | |
summary | string | Non-empty string between 10 and 500 characters. Must mention the number of succeeded, failed, and skipped steps. | |
steps | array of objects | Array length must equal the number of tool calls in the input plan. Each element must match the step schema below. | |
steps[].tool_name | string | Must match a tool name from the input execution plan. Case-sensitive exact match required. | |
steps[].status | enum: ['succeeded', 'failed', 'skipped', 'not_attempted'] | Must be one of the four enum values. 'not_attempted' is only valid when a dependency failed or an abort condition was triggered. | |
steps[].output_summary | string or null | Required when status is 'succeeded'. Must be null when status is 'failed', 'skipped', or 'not_attempted'. Non-null values must be between 1 and 200 characters. | |
steps[].error | object or null | Required when status is 'failed'. Must contain 'error_type' (string) and 'error_message' (string). Must be null for all other statuses. | |
committed_results | array of strings | If present, each string must reference a step index or tool_name from the steps array. Empty array is valid and means no partial results were committed. |
Common Failure Modes
Partial success in tool chains creates subtle failure modes where the agent reports completion but the system state is inconsistent. These are the most common breakages and how to prevent them.
Silent Partial Completion
What to watch: The agent reports success after only some tool calls completed, leaving downstream state incomplete. This happens when the prompt lacks explicit partial-success detection logic. Guardrail: Require the agent to enumerate every tool call's outcome individually before declaring overall status. Add a structured summary block with per-step pass/fail/partial indicators.
Orphaned Side Effects
What to watch: Early steps succeed and produce side effects (database writes, API calls, file creation), but later steps fail, leaving orphaned state with no cleanup path. Guardrail: Define compensating actions for every tool step that has side effects. Require the agent to track which steps completed and execute corresponding rollbacks when the chain fails mid-execution.
Misleading Success Signals
What to watch: A tool returns HTTP 200 or a non-error response, but the payload contains partial results, empty fields, or degraded data that the agent treats as complete success. Guardrail: Add output validation rules between steps that check for required fields, non-null values, and expected data shapes. Reject outputs that pass transport checks but fail semantic checks.
State Contamination Across Steps
What to watch: A failed step's partial output leaks into subsequent steps because the agent passes stale or corrupted state forward without checking integrity. Guardrail: Explicitly clear or quarantine state from failed steps. Require the agent to label each state object with its source step and success status before passing it downstream.
Commit Decision Without Evidence
What to watch: The agent decides to commit partial work without evaluating whether the partial result is useful, safe, or recoverable. This produces inconsistent data that downstream systems can't reconcile. Guardrail: Require a structured commit decision with explicit criteria: what succeeded, what failed, whether partial results are independently usable, and what cleanup is needed before commit.
Retry Loop Masking Structural Failures
What to watch: The agent retries a failed step repeatedly without changing inputs or strategy, consuming resources while hiding the root cause from the operator. Guardrail: Set a maximum retry count per step and require the agent to classify the failure type before retrying. Escalate non-transient failures immediately rather than looping.
Evaluation Rubric
Use this rubric to test the Partial Success Handling prompt's output before deploying it in a production agent. Each criterion targets a specific failure mode in multi-step tool chains where partial completion must be preserved, reported, and decided upon.
| Criterion | Pass Standard | Failure Signal | Test Method |
|---|---|---|---|
Successful Step Preservation | All successfully completed steps are explicitly listed with their outputs, arguments, and completion timestamps in the [PARTIAL_RESULTS] block. | Successful step outputs are missing, truncated, or replaced with a summary instead of the raw structured result. | Execute a 5-step chain where steps 1, 2, and 4 succeed. Parse output and assert that exactly 3 step records exist in [PARTIAL_RESULTS] with matching step IDs and output payloads. |
Failed Step Identification | Every failed step is reported with its step ID, tool name, error code, error message, and the arguments that were attempted. | A failed step is omitted entirely, or the error is described generically without the specific tool name and error code. | Inject a 403 Forbidden error on step 3. Assert that the [FAILED_STEPS] array contains exactly one entry with tool_name matching the failed tool and error_code equal to 403. |
Commit Decision Rationale | The [COMMIT_DECISION] field contains a boolean value and a structured rationale referencing specific business rules, data integrity risks, or user impact from the provided [COMMIT_POLICY]. | The commit decision is true or false without any rationale, or the rationale is a generic statement like 'it seems safe' without citing the policy. | Provide a [COMMIT_POLICY] that states 'commit if at least 3 critical steps succeed.' Run a scenario with 2 critical successes. Assert commit_decision is false and the rationale string contains the substring 'critical steps' and the number 2. |
Compensation Action Completeness | For each committed step that requires rollback, a specific compensating action is defined with the target step ID, the tool to invoke, and the required arguments derived from the original step's output. | Compensation actions are missing for committed steps that have side effects, or the compensation tool name is hallucinated and does not exist in the [AVAILABLE_TOOLS] list. | Provide a tool chain where step 2 creates a database record and step 3 fails. Set commit_decision to false. Assert that the [COMPENSATION_PLAN] contains an action targeting step 2 with a tool name that exists in [AVAILABLE_TOOLS]. |
State Integrity After Partial Failure | The [CURRENT_STATE] block reflects only the outputs of successfully completed and committed steps. No data from failed or rolled-back steps is present. | The state block contains a field from a failed step's output, or a field that should have been rolled back is still present. | Run a chain where step 1 creates a user ID and step 2 updates the user email but then fails. Set commit_decision to false with rollback of step 1. Assert that [CURRENT_STATE] does not contain the user ID created in step 1. |
User-Facing Summary Accuracy | The [USER_SUMMARY] accurately reflects what was completed and what failed without exposing internal error codes, stack traces, or raw tool payloads. | The summary claims 'all operations completed successfully' when steps failed, or it leaks a raw SQL error message or internal stack trace. | Inject a database connection timeout on step 4. Assert that the [USER_SUMMARY] string does not contain 'connection refused', 'stack trace', or 'all steps succeeded', and does contain a plain-language description of the failure. |
Non-Committable Work Flagging | Steps that succeeded but cannot be committed due to policy violations are flagged in a [BLOCKED_RESULTS] array with the blocking policy rule cited. | A step that violates the commit policy is silently included in [PARTIAL_RESULTS] without any flag, or it is incorrectly treated as a failure. | Set a [COMMIT_POLICY] that blocks any step modifying a 'production' environment. Have step 3 succeed against a production database. Assert that step 3 appears in [BLOCKED_RESULTS] and not in [PARTIAL_RESULTS], with a reference to the 'production' policy rule. |
Idempotency Key Handling | The output includes an [IDEMPOTENCY_MAP] that associates each step's idempotency key with its final status, enabling safe replay of the entire chain. | Idempotency keys from the input [TOOL_CHAIN_DEFINITION] are missing from the output, or the status for a replayed step is incorrect. | Provide a chain definition with idempotency keys for each step. Run the prompt twice with the same keys. Assert that the second run's [IDEMPOTENCY_MAP] shows status 'skipped' for steps that succeeded in the first run. |
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 hardcoded list of 2-3 tool steps. Use a simple success/failure flag per step without detailed error classification. Accept unstructured natural-language summaries of partial results.
codeAfter each tool call, report: [STEP_NAME]: [SUCCESS | FAILURE]. If any step fails, list what succeeded and what failed. Do not attempt retries or compensation.
Watch for
- The model declaring overall success when half the steps failed
- Missing output fields when a step is skipped
- No distinction between retryable and permanent failures

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