Inferensys

Prompt

Human Clarification Request Prompt After Agent Failure

A production-ready prompt playbook for generating structured human clarification requests when an autonomous agent exhausts retries or hits an unrecoverable error. Includes the copy-ready template, variable definitions, output schema, harness wiring, evaluation criteria, and common failure modes.
Procurement manager reviewing autonomous AI agent dashboard on laptop, purchase orders visible, office afternoon light.
PROMPT PLAYBOOK

When to Use This Prompt

Define the job, reader, and constraints for the Human Clarification Request Prompt After Agent Failure.

This prompt is for agent systems that have exhausted their retry budget or hit an unrecoverable error and must hand off to a human operator for clarification. The primary job-to-be-done is to produce a structured, actionable request that explains what the agent attempted, where it failed, and exactly what the human needs to provide to unblock the workflow. The ideal user is an AI platform engineer or orchestration developer building a multi-agent system where autonomous agents are expected to self-correct but must escalate gracefully when they cannot. Required context includes the original user intent, the agent's full action trace, the specific failure point, and any partial results or error logs generated before the failure.

Do not use this prompt for simple retry scenarios where the model can self-correct with a better error message or a different tool argument. This prompt is specifically for cases where the agent has already attempted multiple recovery strategies, the failure is persistent, and the only path forward requires human judgment—such as ambiguous user intent, missing required parameters, conflicting instructions, or a capability gap the agent cannot resolve. The prompt should be wired into an orchestration layer that tracks retry counts, detects repeated identical failures, and triggers the handoff only after a configurable threshold is exceeded. Without this gating logic, you risk flooding human reviewers with transient errors that the agent could have resolved on its own.

Before implementing this prompt, ensure your agent harness captures a structured failure context: the original task definition, the sequence of actions attempted, the error at each step, and any tool outputs or partial results. The human reviewer should not need to reconstruct what happened from raw logs. After deploying, monitor the ratio of clarification requests to successful autonomous completions—if the request rate exceeds 10-15% of agent tasks, the agent's retry logic, tool definitions, or input validation likely need redesign rather than more handoffs. Pair this prompt with an audit trail that records the human's response and whether it successfully unblocked the workflow, creating a feedback loop for improving both the agent and the clarification prompt over time.

PRACTICAL GUARDRAILS

Use Case Fit

Where the Human Clarification Request Prompt After Agent Failure works well and where it introduces risk. Use these cards to decide if this prompt fits your workflow before integrating it into an agent harness.

01

Good Fit: Unrecoverable Agent Errors

Use when: The agent has exhausted its retry budget, encountered a tool failure, or hit a logic dead-end that prevents progress. Guardrail: The prompt must receive structured failure context (error type, attempts made, last valid state) to produce a useful clarification request. Without this, the human receives an unactionable 'something went wrong' message.

02

Bad Fit: Simple Retryable Failures

Avoid when: The failure is transient (rate limit, timeout) or can be resolved by a different tool selection. Guardrail: Implement a retry recovery layer before invoking this handoff prompt. Escalating a timeout to a human creates unnecessary review burden and slows down workflows that could self-heal.

03

Required Inputs: Structured Failure Trace

What to watch: The prompt cannot produce a precise clarification request from a generic error string. Guardrail: The agent harness must capture and pass the original task, the sequence of actions attempted, the specific error at each step, and the exact data or decision needed from the human. Missing fields produce vague handoffs.

04

Operational Risk: Human Bottleneck Creation

What to watch: If every agent failure routes to a human without filtering, the review queue becomes a bottleneck. Guardrail: Classify failures by severity and recoverability before invoking this prompt. Only escalate when human input is the only path to unblocking the workflow. Log all escalations to detect over-escalation patterns.

05

Operational Risk: Context Loss in Handoff

What to watch: The human reviewer may lack the full session context to make a decision, leading to incorrect clarifications or repeated handoffs. Guardrail: The prompt output must include a compressed but complete context summary: original user intent, agent's goal, actions taken, and the specific gap. Validate that a new reviewer can understand the situation without reading raw logs.

06

Bad Fit: Ambiguous Failure Without Root Cause

Avoid when: The agent cannot determine why it failed or what clarification is needed. Guardrail: If the failure mode is unknown, route to a diagnostic agent or log for engineering review instead of asking the end user for clarification. Asking a human to debug the agent's internal state is a poor experience and rarely produces useful unblocking input.

PROMPT PLAYBOOK

Copy-Ready Prompt Template

A reusable prompt template that structures a clarification request to a human after an agent exhausts retries or hits an unrecoverable error.

This template produces a structured handoff when an agent cannot proceed without human input. It is designed for orchestration systems that detect repeated failures, unrecoverable errors, or ambiguity that exceeds the agent's authority to resolve. The output is a self-contained clarification request that a human reviewer can act on without reading raw agent logs or replaying the failed execution. Use this template when the agent has already attempted retries, self-correction, or alternative paths and has determined that only external clarification can unblock the workflow.

text
You are an agent that has exhausted all available retry and self-correction paths. You cannot proceed without human clarification. Your task is to produce a structured handoff that explains what was attempted, where the failure occurred, and exactly what the human must provide to unblock the workflow.

## INPUT
[ORIGINAL_USER_REQUEST]
[AGENT_ROLE_AND_CAPABILITIES]
[FAILURE_CONTEXT]
[ERROR_TRACE_OR_LOG]
[RETRY_HISTORY]

## OUTPUT_SCHEMA
Return a JSON object with these fields:
{
  "handoff_type": "clarification_request",
  "agent_identity": "string",
  "original_goal": "string",
  "attempts_made": [
    {
      "attempt_number": "integer",
      "strategy": "string",
      "outcome": "string",
      "failure_reason": "string"
    }
  ],
  "blocking_error": {
    "error_type": "string",
    "error_message": "string",
    "error_location": "string",
    "recoverable_without_human": false
  },
  "clarification_needed": {
    "question": "string",
    "context_for_question": "string",
    "candidate_interpretations": ["string"],
    "impact_of_choice": "string"
  },
  "partial_results": "string or null",
  "recommended_next_step_after_clarification": "string",
  "urgency": "low | medium | high | critical",
  "urgency_justification": "string"
}

## CONSTRAINTS
- Do not guess the answer to the clarification question. If you are uncertain, state the uncertainty explicitly.
- Include only attempts that were actually executed. Do not fabricate retry history.
- The clarification question must be specific enough that a human can answer it without additional research.
- If partial results exist, include them so the human does not need to redo completed work.
- Set urgency based on the downstream impact of delay, not on your own execution time.
- If the error trace contains sensitive data, redact it and note the redaction.
- If [RISK_LEVEL] is "high" or "critical", add a field `"requires_approval": true` and include the approval authority required.

## EXAMPLES
[EXAMPLES]

## RISK_LEVEL
[RISK_LEVEL]

Adapt this template by replacing each square-bracket placeholder with values from your orchestration layer. [ORIGINAL_USER_REQUEST] should contain the exact user input that triggered the agent. [FAILURE_CONTEXT] should describe the state of the workflow when the failure occurred, including any tool outputs, intermediate results, or environmental conditions. [RETRY_HISTORY] should be a structured log of each retry attempt with the strategy used and the outcome. If your system does not track retry history, remove the attempts_made array or populate it from available logs. The [EXAMPLES] placeholder should contain one or two few-shot examples of well-formed clarification requests for your domain. The [RISK_LEVEL] placeholder accepts "low", "medium", "high", or "critical" and controls whether the output includes approval requirements. Before deploying, validate that the output JSON conforms to the schema and that the clarification question is answerable by a human without additional context gathering.

IMPLEMENTATION TABLE

Prompt Variables

Inputs required to generate a structured clarification request after an agent exhausts retries or encounters an unrecoverable error. Replace each placeholder with concrete data from the agent execution context.

PlaceholderPurposeExampleValidation Notes

[AGENT_ROLE]

Identifies the agent that failed so the human knows which system needs help

customer-support-router-agent-v2

Must match a registered agent ID in the orchestration log. Null not allowed.

[TASK_DESCRIPTION]

The original task or goal the agent was attempting to complete

Classify and route refund request for order #88291

Must be a single-sentence summary of the user-facing intent. Truncate if longer than 200 characters.

[ATTEMPTED_ACTIONS]

Ordered list of actions the agent took before failure, with outcomes

  1. Called order-lookup tool (success). 2. Called refund-eligibility tool (timeout). 3. Retried 3x (all timeout).

Must be a valid JSON array of strings. Each entry must include action name and outcome. Minimum 1 entry required.

[FAILURE_REASON]

The specific error, exception, or condition that blocked completion

Refund eligibility API returned 504 Gateway Timeout after 3 retries over 60 seconds

Must include error code or exception type if available. Must not be a generic message like 'something went wrong'.

[ERROR_TRACE_ID]

Unique identifier linking the failure to logs and monitoring systems

trace-9a3f2c1b-7742-4e8d-a1b6-ff5c3d8e2a10

Must be a valid UUID or trace ID format. Must be retrievable in observability platform. Null allowed only if tracing is disabled.

[CONTEXT_SNAPSHOT]

Key state variables and user data available at the time of failure

{"user_id": "U-4421", "order_status": "delivered", "refund_window": "open"}

Must be a valid JSON object. PII fields must be redacted or tokenized before inclusion. Schema check required.

[CLARIFICATION_QUESTION]

The specific, unambiguous question the human must answer to unblock the workflow

Should we proceed with a manual refund review, or escalate to the payments team?

Must be a single interrogative sentence. Must not be a compound question. Must be answerable with a choice or short directive.

[RESPONSE_OPTIONS]

Concrete options the human can select from to resolve the ambiguity

["Proceed with manual refund review", "Escalate to payments team", "Close as duplicate request"]

Must be a JSON array of 2-5 strings. Each option must map to a defined next step in the workflow. Null allowed if open-ended response is required.

PROMPT PLAYBOOK

Implementation Harness Notes

How to wire the clarification request prompt into an agent orchestration layer with validation, retry gates, and human review routing.

The clarification request prompt is triggered when an agent exhausts its retry budget or hits an unrecoverable error state. In the orchestration layer, this prompt should be called as a final fallback after the agent's primary execution loop and any self-correction or repair prompts have failed. The harness must capture the agent's full execution trace—including tool calls, intermediate outputs, error messages, and the original user intent—and pass it into the prompt as [FAILURE_CONTEXT]. The prompt then produces a structured handoff payload that a human reviewer can act on without reading raw agent logs.

Wire the prompt into a dedicated handoff function that is invoked by the orchestrator's error handler. The function should: (1) serialize the agent's trace into a structured [FAILURE_CONTEXT] object containing attempts, errors, last_state, and original_request; (2) call the LLM with the clarification prompt template and a strict [OUTPUT_SCHEMA] requiring clarification_needed, what_was_attempted, failure_point, specific_question, and context_for_reviewer; (3) validate the output against the schema before routing to a human queue. If validation fails, retry once with a repair prompt that includes the schema violation details. If the retry also fails, route the raw trace plus a generic escalation notice to the human queue as a degraded fallback. Log every handoff attempt, the validation result, and the final routing decision for audit and observability.

Model choice matters here: use a model with strong instruction-following and structured output support, such as GPT-4o or Claude 3.5 Sonnet, because the prompt requires precise extraction of the failure point and generation of a single clear question. Avoid smaller or older models that may produce vague questions or omit critical failure context. The human review queue should display the structured handoff payload, not the raw prompt output. If the workflow is high-risk—such as financial transactions, clinical decisions, or compliance actions—add a mandatory human acknowledgment step before the workflow can be unblocked, and ensure the handoff payload is persisted as an audit record with timestamps and reviewer identity.

IMPLEMENTATION TABLE

Expected Output Contract

Defines the required fields, types, and validation rules for the structured handoff payload produced by the Human Clarification Request Prompt After Agent Failure. Use this contract to parse the model's output and validate it before presenting to a human reviewer.

Field or ElementType or FormatRequiredValidation Rule

failure_summary

string

Must be non-empty and under 500 characters. Check for a concise description of the unrecoverable error.

agent_identity

object

Must contain 'agent_name' (string) and 'agent_version' (string). Validate presence of both keys.

task_attempted

string

Must describe the original goal. Validate that it is not a copy of the failure_summary.

retry_log

array of objects

Each object must have 'attempt_number' (integer), 'action_taken' (string), and 'error_received' (string). Array must not be empty.

blocking_error

object

Must contain 'error_code' (string) and 'error_message' (string). Validate that error_code is not null or empty.

context_snapshot

object

Must contain 'relevant_inputs' (object) and 'state_variables' (object). Validate that at least one key is present in each.

clarification_needed

string

Must be a specific, actionable question for the human. Validate it ends with a question mark and is under 200 characters.

suggested_options

array of strings

If present, must contain 2-5 distinct strings. Each string must be a concrete, selectable path forward.

PRACTICAL GUARDRAILS

Common Failure Modes

When an agent fails and requests human clarification, the handoff prompt itself can break. These are the most common failure modes and how to prevent them before they reach a human reviewer.

01

Vague Failure Description

What to watch: The prompt produces a handoff that says 'I couldn't complete the task' without explaining what was attempted, which step failed, or what error occurred. The human reviewer receives an unactionable message and must replay the entire workflow from scratch. Guardrail: Require the prompt to include a structured failure block with attempted_steps, failed_step, error_type, and error_message. Validate that these fields are non-empty before the handoff is delivered.

02

Missing Retry Context

What to watch: The handoff omits how many retries were attempted, what strategies were tried, and why they failed. The human wastes time suggesting approaches the agent already exhausted. Guardrail: Include a retry_log array in the output schema with attempt_number, strategy_used, and failure_reason for each retry. Add an eval check that the retry count matches the system's actual retry budget before surfacing the handoff.

03

Overly Technical Error Dump

What to watch: The prompt dumps raw stack traces, tool-call JSON, or internal agent state into the handoff without translation. Non-technical reviewers in operations or compliance cannot interpret the failure and escalate it to engineering without context. Guardrail: Separate the handoff into a human-readable summary section and an optional debug_payload appendix. Use a validator to ensure the summary contains no raw JSON, stack traces, or unrendered template tokens.

04

No Clear Ask for the Human

What to watch: The handoff describes the failure but doesn't specify exactly what the human needs to provide to unblock the workflow. The reviewer responds with incomplete information, triggering another round-trip. Guardrail: Require a clarification_needed field with a specific question or a structured form the human must complete. Test the prompt against edge cases where the missing information is ambiguous and confirm the ask is precise.

05

Hallucinated Attempts or Evidence

What to watch: The agent fabricates retry steps it never executed or cites tool outputs it never received, especially when the prompt encourages detailed failure narratives. The human makes decisions based on false information. Guardrail: Generate the handoff from the actual execution trace, not from the model's free-form recollection. Use a harness that injects the real attempt_history and error_log into the prompt as immutable context, and add an eval that diffs handoff claims against ground-truth execution logs.

06

Escalation to Wrong Audience

What to watch: The handoff is routed to a generic queue or the wrong team because the prompt doesn't classify the failure type or required expertise. A billing error goes to engineering; a model refusal goes to support. Guardrail: Include a required_reviewer_role and failure_category field in the output. Validate against a predefined taxonomy of failure categories mapped to escalation paths. Test that each category routes to the correct queue in staging before production deployment.

IMPLEMENTATION TABLE

Evaluation Rubric

Use this rubric to test the Human Clarification Request Prompt before deploying it into a production agent handoff pipeline. Each criterion targets a specific failure mode observed in agent-to-human clarification requests.

CriterionPass StandardFailure SignalTest Method

Failure Context Completeness

Output includes all of: the original task, the specific step where failure occurred, the error type, and the last successful state before failure.

Output omits the error type or the last successful state, forcing the human to re-diagnose the failure.

Parse output for [TASK], [FAILURE_STEP], [ERROR_TYPE], and [LAST_KNOWN_STATE] fields. Fail if any field is null or empty.

Clarification Precision

The clarification request asks exactly one specific, answerable question that unblocks the workflow. It does not ask the human to restate the original task.

Output asks multiple questions, a vague question, or a question the human cannot answer without redoing the agent's work.

Extract the clarification question. Validate it is a single sentence ending with a question mark. Check that it does not contain the original task description verbatim.

Attempt History Transparency

Output lists each retry attempt with the action taken and the specific failure reason, not a generic 'retry failed' message.

Output summarizes retries as 'multiple attempts failed' without enumerating each attempt and its distinct failure reason.

Count the number of distinct retry entries in [ATTEMPT_HISTORY]. Fail if count is 0 or if any entry has a null [FAILURE_REASON].

Error Trace Inclusion

Output includes a sanitized error trace or log excerpt that a human operator can use for diagnosis, with sensitive data redacted.

Output omits the error trace entirely or includes raw, unredacted stack traces that may leak credentials or PII.

Check for presence of [ERROR_TRACE] field. Validate it is non-empty. Run a PII scanner on the field; fail if PII confidence exceeds 0.1.

Unblocking Input Specification

Output specifies the exact format, type, and constraints for the human's response so the agent can parse it programmatically upon resumption.

Output says 'provide more information' without specifying the expected response schema or acceptable values.

Parse [EXPECTED_RESPONSE_SCHEMA] field. Validate it contains a type declaration and at least one constraint. Fail if it is free-text only.

Tone Appropriateness

Output maintains a neutral, professional tone that does not blame the user, express frustration, or anthropomorphize the agent's emotional state.

Output includes phrases like 'I'm sorry I failed', 'I'm confused', or 'unfortunately I cannot do this'.

Run a sentiment and tone classifier on the output. Fail if frustration, apology, or anthropomorphic sentiment scores exceed 0.3.

Resumption Instruction Clarity

Output tells the human exactly what to do with the clarification response and what will happen next in the workflow after they respond.

Output ends with the clarification question but provides no instructions for how the human's response will be used or what the agent will do next.

Check for [RESUMPTION_INSTRUCTIONS] field. Validate it contains a future-tense verb describing the agent's next action. Fail if absent or empty.

ADAPTATION OPTIONS

Adapt This Prompt

How to adapt

Start with the base prompt and a simple JSON schema for the clarification request. Use a single [AGENT_LOG] block that includes the original task, retry count, and last error message. Skip structured error traces and keep the output to three fields: what_failed, what_was_attempted, and clarification_needed.

Watch for

  • The model summarizing the failure instead of asking a specific question
  • Missing the retry count, which helps the human gauge urgency
  • Overly verbose agent logs that blow out the context window
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.