This prompt is for platform engineers and SRE teams who need a fallback agent to take over a failed task and show its reasoning step by step. The primary job-to-be-done is not just task completion, but auditable recovery. When a primary agent times out, returns an error, or produces unusable output, the fallback agent must produce a reasoned plan that explains what it assumed, what it is uncertain about, and why it chose its approach. The ideal user is an engineer integrating this into an agent orchestration framework where downstream systems or human reviewers need to audit the fallback decision. Required context includes the original task, the failure signal (error code, timeout duration, or validator rejection), any partial results from the primary agent, and the fallback agent's capability constraints.
Prompt
Fallback Chain-of-Thought Prompt

When to Use This Prompt
Defines the job-to-be-done for the fallback chain-of-thought prompt, the ideal user, required context, and critical anti-patterns to avoid.
Use this prompt when traceability matters more than speed. It is appropriate for high-stakes workflows—incident response, compliance reporting, financial reconciliation—where an opaque fallback answer is worse than a slower, explained one. Do not use this prompt when the fallback task is trivial, when latency is the primary constraint, or when the fallback agent is a simple retry wrapper with no reasoning surface. It is also a poor fit when the primary agent's failure mode is unknown or unclassified; in that case, pair it with an Agent Failure Mode Classification Prompt first to route the failure correctly. The prompt assumes the fallback agent has enough context to reason about the task, even if it lacks the primary agent's specialized tools or domain fine-tuning.
Before wiring this into production, define what a 'good' chain-of-thought looks like for your domain. At minimum, validate that the output contains explicit assumption markers, uncertainty flags for any inferred or missing data, and a decision rationale that references the original failure context. If the fallback agent's output will be shown to end users, add a human-review gate before exposure. If the output feeds another agent, ensure the downstream agent's prompt can parse and act on the structured reasoning fields. The next section provides the copy-ready template you can adapt and test against these criteria.
Use Case Fit
Where the Fallback Chain-of-Thought prompt delivers reliable reasoning and where it introduces unacceptable latency or risk.
Good Fit: High-Stakes Agent Handoffs
Use when: A primary agent fails on a task where the reasoning behind the fallback decision must be auditable, such as financial calculations or clinical data extraction. Why: The explicit assumption disclosure and uncertainty markers create a verifiable audit trail.
Bad Fit: Latency-Sensitive User Interactions
Avoid when: The fallback agent is directly exposed to an end-user waiting for a real-time response. Risk: Chain-of-thought reasoning can add significant latency, degrading user experience. Guardrail: Use this prompt for asynchronous background fallback tasks and surface only the final structured output to the user.
Required Input: Structured Failure Context
What to watch: The fallback agent receives a vague error message with no context from the failed primary agent. Guardrail: The prompt requires a [FAILURE_CONTEXT] input containing the original task, the error trace, and the primary agent's partial state. Without this, the reasoning will be speculative and low-quality.
Operational Risk: Hallucinated Justifications
What to watch: The model generates a plausible-sounding but factually incorrect reason for the primary agent's failure, leading operators to fix the wrong problem. Guardrail: Constrain the prompt to only reason about failure causes explicitly present in the [FAILURE_CONTEXT] and mark any inferred causes as [SPECULATIVE].
Good Fit: Postmortem and Debugging Workflows
Use when: SRE teams need a first-pass analysis of why an agent chain broke. Why: The structured decision rationale and uncertainty markers help engineers quickly identify where to focus their investigation, even if the model's reasoning is not the final word.
Bad Fit: Fully Autonomous Recovery Loops
Avoid when: The system is designed to recover without any human review. Risk: The fallback agent may reason its way into an unsafe action based on a flawed assumption. Guardrail: Always route the output of this prompt through a human approval step or a strict programmatic validator before executing any side effects.
Copy-Ready Prompt Template
A reusable fallback chain-of-thought prompt that forces the model to expose its reasoning, assumptions, and uncertainty when taking over a failed task.
This prompt template is designed for platform engineers who need a fallback agent to take over a task after the primary agent fails, times out, or returns an unusable result. The template forces explicit reasoning, assumption disclosure, and uncertainty marking so that downstream systems and human reviewers can trace the fallback agent's decision process. Use this when you need a reasoned fallback plan rather than a silent best-guess response.
textYou are a fallback reasoning agent. The primary agent assigned to this task failed to produce a valid result. Your job is to construct the best possible response using available context while making your reasoning fully transparent. ## Task Context [ORIGINAL_TASK] ## Primary Agent Failure Summary [FAILURE_SUMMARY] ## Available Context [AVAILABLE_CONTEXT] ## Constraints [CONSTRAINTS] ## Output Schema [OUTPUT_SCHEMA] ## Instructions 1. First, restate what you understand the original task to be and what the primary agent was expected to produce. 2. Identify what information you have and what critical information is missing. Mark each missing piece with an explicit gap label. 3. State every assumption you are making to fill those gaps. Number each assumption and explain why you chose it over alternatives. 4. For each assumption, assign an uncertainty level: LOW (well-supported by context), MEDIUM (reasonable inference), or HIGH (speculative). 5. Construct your fallback response following the output schema. For any field that relies on a HIGH-uncertainty assumption, prefix the value with [SPECULATIVE]. 6. After the response, provide a decision rationale section explaining why you chose this fallback path over other possible approaches. 7. End with a list of questions you would ask a human to resolve the HIGH-uncertainty assumptions. ## Risk Level [RISK_LEVEL] If RISK_LEVEL is HIGH, you must additionally flag any part of your response that could cause harm if incorrect and recommend human review before action.
Adaptation notes: Replace [ORIGINAL_TASK] with the full task description the primary agent received. Populate [FAILURE_SUMMARY] with the error type, timeout duration, or partial output that triggered the fallback. [AVAILABLE_CONTEXT] should include any partial results, retrieved documents, or session state that survived the failure. [CONSTRAINTS] must carry forward the original constraints plus any new degradation constraints. [OUTPUT_SCHEMA] defines the expected response structure—keep it identical to the primary agent's schema so consumers don't need to handle two formats. [RISK_LEVEL] should be set to LOW, MEDIUM, or HIGH based on the task domain. For HIGH-risk tasks, add a human-in-the-loop step after the fallback agent produces its output. Validate the output by checking that every HIGH-uncertainty assumption is explicitly marked, that no fabricated data appears without a [SPECULATIVE] tag, and that the decision rationale references the actual failure context rather than generic reasoning.
Prompt Variables
Required and optional inputs for the Fallback Chain-of-Thought Prompt. Each placeholder must be populated before the fallback agent can produce a reasoned takeover plan.
| Placeholder | Purpose | Example | Validation Notes |
|---|---|---|---|
[FAILED_TASK_DESCRIPTION] | The original task the primary agent was attempting to complete | Generate a quarterly revenue summary from the CRM export | Must be non-empty. Check length > 20 chars. Reject if only error codes or stack traces are present without task context. |
[FAILURE_REASON] | The error, timeout, or unavailability reason from the primary agent | Primary agent timed out after 45s while calling the reporting API | Must include failure category (timeout, tool error, refusal, unavailable). Parse for known failure types. Reject if empty or 'unknown' without supporting evidence. |
[PARTIAL_RESULTS] | Any intermediate output, retrieved data, or state the primary agent produced before failing | {"revenue_total": null, "accounts_processed": 142, "last_successful_page": 3} | Can be null if no progress was made. If present, validate JSON structure. Flag if partial results contain fabricated data markers or confidence scores below 0.5. |
[AGENT_CAPABILITIES] | The tools, models, and access scope available to the fallback agent | ["text-generation", "data-analysis", "no-reporting-api-access"] | Must be a non-empty list. Validate each capability against a known registry. Reject if capabilities include the failed tool without explicit override confirmation. |
[USER_QUERY] | The original user request that initiated the agent chain | What was our Q3 revenue by region? Show me the top 5 accounts. | Must be non-empty. Preserve exact user wording. Flag if query appears modified or summarized without audit trail. |
[CONFIDENCE_THRESHOLD] | Minimum confidence score the fallback agent must meet to proceed without escalation | 0.7 | Must be a float between 0.0 and 1.0. Default to 0.7 if not specified. Reject values below 0.5 as unsafe for autonomous fallback. |
[ESCALATION_TARGET] | Where to send the output if the fallback agent cannot meet the confidence threshold | human-ops-queue::revenue-reporting | Must be a valid routing identifier. Validate against known escalation targets. Reject if target is the same as the failed primary agent. |
Implementation Harness Notes
How to wire the fallback chain-of-thought prompt into a reliable agent orchestration layer.
The fallback chain-of-thought prompt is not a standalone artifact; it is a component inside an agent orchestration harness. When a primary agent fails—due to a tool error, timeout, or unavailable dependency—the orchestrator must invoke this prompt with a structured failure record, not raw logs. The harness is responsible for assembling the [FAILURE_CONTEXT], which includes the original user intent, the failed agent's role, the specific error or timeout signal, and any partial results produced before failure. Without this harness, the fallback agent receives insufficient context and produces a generic, untrustworthy plan.
Wire the prompt into your orchestration layer as a synchronous fallback step. After detecting a primary agent failure, the orchestrator should: (1) capture the failure event with a typed schema (e.g., agent_id, error_code, partial_output, tool_call_history); (2) populate the prompt's placeholders, especially [FAILURE_CONTEXT], [ORIGINAL_USER_REQUEST], and [AVAILABLE_TOOLS]; (3) invoke the model with a strict response_format requirement matching the [OUTPUT_SCHEMA] (JSON with reasoning_trace, assumptions, uncertainty_markers, fallback_plan, and escalation_decision); (4) validate the output against the schema before acting on it. If validation fails, retry once with the validation errors injected into [CONSTRAINTS]. If the retry also fails, escalate to a human operator with the raw failure record and the invalid model output attached. Log every invocation—including the prompt version, model, latency, and validation result—for later trace analysis and regression testing.
Model choice matters. Use a model with strong instruction-following and structured output support (e.g., GPT-4o, Claude 3.5 Sonnet) because the fallback agent must produce a parseable reasoning trace under degraded conditions. Avoid smaller or older models that may drop required fields or hallucinate tool capabilities when the [AVAILABLE_TOOLS] list is constrained. If the fallback agent itself fails, the harness must not loop indefinitely. Implement a circuit breaker: after two consecutive fallback failures for the same request, stop retrying, log the full failure chain, and route to a human review queue with a pre-formatted escalation payload. The fallback prompt is a safety net, not a replacement for root-cause fixing—monitor fallback invocation rates and use them to drive primary agent reliability improvements.
Expected Output Contract
Fields, format, and validation rules for the fallback chain-of-thought output. Use this contract to parse, validate, and route the fallback agent's reasoned plan before execution.
| Field or Element | Type or Format | Required | Validation Rule |
|---|---|---|---|
reasoning_trace | Array of strings | Each element must be a non-empty string. Array length >= 3. Each step must reference either an assumption, a constraint, or a prior step. | |
assumptions | Array of objects | Each object must contain 'assumption' (string) and 'confidence' (enum: high, medium, low). No more than 5 assumptions. Low-confidence assumptions must be flagged in uncertainty_markers. | |
uncertainty_markers | Array of strings | Each marker must reference a specific reasoning step or assumption by index. Format: 'Step [N]: [description of uncertainty]'. Must not be empty if any assumption has confidence 'low'. | |
fallback_plan | Object | Must contain 'approach' (string), 'steps' (array of strings, min 1), and 'expected_outcome' (string). 'approach' must differ from the primary agent's documented approach. | |
capability_gaps | Array of strings | Each gap must describe a specific capability the fallback agent lacks compared to the primary agent. Must not be empty. Gaps must be reflected in the fallback_plan.approach. | |
escalation_triggers | Array of objects | If present, each object must contain 'condition' (string) and 'action' (enum: retry, escalate_to_human, abort). Max 3 triggers. Required if fallback_plan.expected_outcome includes 'partial'. | |
decision_rationale | String | Must explain why this fallback approach was chosen over alternatives. Minimum 50 characters. Must reference at least one capability_gap and one assumption. | |
original_task_context | Object | Must contain 'task_id' (string), 'primary_agent' (string), and 'failure_reason' (string). 'failure_reason' must match one of: timeout, tool_failure, unavailability, permission_denied, unknown. |
Common Failure Modes
When a fallback agent takes over a failed task, reasoning transparency becomes critical. These are the most common failure modes that break traceability, hide assumptions, or produce confident-sounding plans built on missing evidence.
Assumption Concealment
What to watch: The fallback agent fills gaps with plausible assumptions but presents them as facts, skipping explicit disclosure. Guardrail: Require an [ASSUMPTIONS] section in the output schema and validate that every unsupported claim is tagged with an uncertainty marker before the plan is accepted.
Missing Failure Context
What to watch: The fallback agent generates a plan without acknowledging why the primary agent failed, repeating the same doomed approach. Guardrail: Inject the primary agent's failure reason and last known state into the fallback prompt as [FAILURE_CONTEXT] and require the reasoning trace to reference it explicitly.
Overconfident Partial Plans
What to watch: The fallback agent produces a complete-looking plan despite missing critical inputs, masking the degradation. Guardrail: Require a [CONFIDENCE_PER_STEP] field with explicit LOW/MEDIUM/HIGH ratings and a rule that any LOW-confidence step triggers a human escalation marker.
Decision Rationale Omission
What to watch: The fallback agent states what it will do but not why, making the plan unauditable and hard to improve. Guardrail: Enforce a [RATIONALE] block for each major decision node in the chain-of-thought output, validated by a second-pass check that flags any decision without a linked reason.
Capability Overreach
What to watch: The fallback agent plans steps that require tools, permissions, or data it does not have, creating a plan that cannot be executed. Guardrail: Provide an explicit [AVAILABLE_CAPABILITIES] list in the prompt and require the reasoning trace to map each planned action to a declared capability, aborting with a gap notice if no match exists.
Trace Incompleteness Under Timeout
What to watch: When the fallback agent itself is under time pressure, it truncates the reasoning trace, dropping assumption and rationale sections. Guardrail: Design the output schema so that the reasoning trace is emitted incrementally and a partial trace is still parseable. Add a validator that rejects plans with missing required trace sections even under degraded conditions.
Evaluation Rubric
Criteria for testing the quality and safety of a fallback chain-of-thought response before shipping to production. Each row defines a pass standard, a failure signal, and a concrete test method.
| Criterion | Pass Standard | Failure Signal | Test Method |
|---|---|---|---|
Reasoning Traceability | Every decision step references a specific input fact, constraint, or prior step. No logical leaps without stated justification. | Output contains 'therefore' or 'so' statements without a preceding 'because' clause. Steps are missing intermediate inferences. | Parse output for decision markers. Assert each marker has a corresponding evidence reference from [FAILED_TASK_CONTEXT] or [ORIGINAL_USER_INTENT]. |
Assumption Disclosure | All assumptions made due to missing or ambiguous data are explicitly tagged with '[ASSUMPTION]' and a confidence level. | The fallback plan proceeds as if missing data is known. No uncertainty markers appear in critical path decisions. | Scan output for '[ASSUMPTION]' tags. Assert count > 0 if [FAILED_TASK_CONTEXT] has missing fields. Check that no critical action is taken without a tagged assumption or confirmed fact. |
Uncertainty Marking | Confidence levels (High/Medium/Low) are assigned to each major conclusion. Low-confidence conclusions include a specific risk statement. | A low-confidence conclusion is presented with the same assertive language as a high-confidence one. No risk statement is provided. | Extract all confidence labels. For each 'Low' label, assert the adjacent sentence contains a risk qualifier (e.g., 'This may be incorrect because...'). |
Fallback Plan Completeness | The output includes: (1) what failed, (2) what is still possible, (3) a step-by-step degraded plan, and (4) what is explicitly not covered. | The output only describes the failure or only provides a new plan without acknowledging the capability gap. | Validate output against a schema requiring |
Absence of Hallucinated Recovery | The plan does not invent successful tool calls, data retrievals, or agent capabilities that are not available in the fallback context. | The output includes phrases like 'I have retrieved...' or 'After calling the tool...' when no such action occurred or is possible. | Diff the actions in the |
Escalation Trigger Definition | Clear, measurable conditions are defined for when a human or another agent must take over (e.g., 'If confidence < Medium on step 3, stop and escalate'). | The plan describes a fully autonomous degraded path with no exit criteria for further failure. | Scan for 'escalate', 'stop and wait', or 'human review required'. Assert at least one such condition exists if the plan involves more than one step. |
Context Preservation | The output carries forward the original user intent and any partial results from the failed agent without distortion. | The fallback plan solves a different problem than the one stated in [ORIGINAL_USER_INTENT]. Partial results are ignored or contradicted. | Use an LLM-as-judge with a pairwise comparison prompt: 'Does the fallback plan address the original intent [ORIGINAL_USER_INTENT] and incorporate the partial results [PARTIAL_RESULTS]?'. Assert a score > 4/5. |
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 fallback reasoning template and relax strict schema requirements. Focus on getting coherent reasoning traces before adding validation layers. Use a single model call with the fallback agent role and the failed task context.
codeYou are a fallback agent. The primary agent failed on this task: [TASK_DESCRIPTION] Failure reason: [FAILURE_REASON] Partial results available: [PARTIAL_RESULTS] Walk through your reasoning step by step: 1. What do you understand about the task? 2. What assumptions are you making? 3. What can you complete with available information? 4. What cannot be completed and why? 5. What is your recommended fallback plan? Mark uncertainty with [LOW CONFIDENCE], [ASSUMPTION], or [UNABLE TO DETERMINE].
Watch for
- Reasoning that sounds confident but ignores missing information
- Assumptions presented as facts without explicit markers
- No distinction between what the fallback agent can vs. cannot complete
- Overly verbose traces that bury the actionable fallback plan

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