This prompt is designed for platform engineers and AI SREs who need to attribute a user-reported failure to a specific tool call, argument error, or tool timeout by analyzing a production trace. The ideal user has access to raw trace data—including tool-call spans, arguments, responses, and timing metadata—and needs to move from a vague user complaint like 'the search didn't work' to a precise, actionable diagnosis. The prompt takes three inputs: the user's complaint, the associated trace data, and the tool definitions that were available to the model at runtime. It produces a structured tool-failure report identifying the exact failing tool call, the error context, and a recommended remediation.
Prompt
Tool Failure Attribution Prompt for User Reports

When to Use This Prompt
Diagnose user-reported tool failures by attributing root cause to a specific tool call, argument error, or timeout using production trace data.
Use this prompt when a user reports that the assistant couldn't complete a request, a tool-based action failed silently, or a response was incomplete due to a suspected tool issue. It is particularly valuable during incident triage, post-mortem analysis, and feedback-loop closure where support tickets must be mapped to engineering fixes. The prompt assumes you already have access to the trace data and tool definitions—it does not replace infrastructure monitoring or alerting systems. It is a diagnostic tool for post-hoc failure analysis, not a real-time guardrail. For high-severity incidents where the remediation involves a prompt change, retrieval pipeline update, or tool configuration modification, always require human review of the suggested fix before deployment.
Do not use this prompt when the failure is clearly a model reasoning error unrelated to tool use, when the trace data is incomplete or missing tool-call spans, or when the user complaint is too vague to map to a specific session. The prompt is also not suitable for aggregate trend analysis across many sessions—it is designed for single-session, single-complaint diagnosis. If you need to correlate multiple user reports to identify systemic tool failures, pair this prompt with a feedback-cluster analysis workflow and run it across a batch of traces with human sampling for false-attribution prevention. For regulated or high-risk domains where tool actions have compliance implications, ensure the output report is reviewed by a human before any remediation is applied to production systems.
Use Case Fit
Where the Tool Failure Attribution Prompt works well and where it introduces risk. Use this to decide if a trace-based attribution workflow is the right approach before investing in prompt engineering.
Good Fit: Structured Trace Data Available
Use when: your observability platform captures structured spans with tool names, arguments, error codes, and timestamps. Guardrail: validate that the trace schema includes tool_name, error.message, and error.type fields before running attribution. Incomplete traces produce unreliable attribution.
Bad Fit: User-Reported Issues Without Trace IDs
Avoid when: the user report lacks a session ID, trace ID, or timestamp that can be correlated to a specific trace. Guardrail: require support engineers to attach a trace identifier before invoking the attribution prompt. Without it, the prompt will hallucinate a plausible but incorrect tool failure.
Required Inputs: Trace Span and Error Context
What you need: a full trace span JSON with tool-call events, error payloads, and surrounding context. Guardrail: include at least 3 spans before and after the failure event so the prompt can distinguish a root-cause tool failure from a cascading downstream error.
Operational Risk: False Attribution to the Wrong Tool
What to watch: the prompt may blame the most recent tool call rather than the actual failing call, especially in parallel tool executions. Guardrail: add an eval check that verifies the attributed tool call's error payload matches the user-reported symptom before accepting the attribution.
Operational Risk: Overlooking Infrastructure Failures
What to watch: the prompt may attribute a timeout or network error to a tool argument mistake when the real cause is an infrastructure outage. Guardrail: include infrastructure health signals (HTTP status codes, latency percentiles) in the trace context so the prompt can distinguish tool errors from platform errors.
Bad Fit: Ambiguous User Reports Without Symptoms
Avoid when: the user report says 'it didn't work' without describing the expected vs. actual behavior. Guardrail: require a structured user-report template with fields for expected outcome, actual outcome, and timestamp before invoking attribution. Ambiguous reports produce low-confidence attributions that waste engineering time.
Copy-Ready Prompt Template
A copy-ready prompt for attributing a user-reported failure to a specific tool call, argument error, or timeout within a production trace.
This prompt template is designed to be pasted directly into your trace analysis workflow. It instructs the model to act as a platform engineer reviewing a user-reported failure against a provided trace log. The goal is to produce a structured tool-failure report that isolates the exact point of failure, rather than a general summary of the session. You must replace the square-bracket placeholders with actual data from your observability platform before execution.
textYou are a platform engineer analyzing a production trace to attribute a user-reported failure to a specific tool call. Your analysis must be precise, evidence-based, and confined to the provided trace data. [INPUT] User Report: [USER_REPORT_DESCRIPTION] Trace Data (JSON): [FULL_TRACE_JSON] [CONSTRAINTS] 1. Identify the single most likely failing tool call. If multiple calls failed, identify the first one that caused the cascade. 2. For the identified tool call, extract the exact function name, input arguments, and the error message or timeout signal from the trace. 3. If the failure is due to a malformed argument, specify the exact argument and why it is invalid. 4. If the failure is a timeout, state the duration attempted and the timeout threshold if available in the trace. 5. Do not speculate about fixes outside the trace evidence. Your remediation recommendation must be directly traceable to the identified failure. 6. If no tool failure is evident in the trace, state that explicitly and suggest the failure may be in the model's reasoning, retrieval, or prompt instructions. [OUTPUT_SCHEMA] { "attribution_report": { "primary_failure_tool_call": { "function_name": "string | null", "span_id": "string | null", "input_arguments": {}, "error_message": "string | null", "failure_type": "enum: [MALFORMED_ARGUMENT, TIMEOUT, EXECUTION_ERROR, AUTHORIZATION_ERROR, NOT_FOUND]" }, "causal_chain": [ { "step": "string", "trace_evidence": "string" } ], "root_cause_summary": "string", "recommended_remediation": "string", "confidence": "enum: [HIGH, MEDIUM, LOW]", "alternative_hypotheses": ["string"] } } [EXAMPLES] User Report: "The assistant said it couldn't find my order but I provided the order ID." Trace shows a call to `lookup_order` with argument `order_id: null`. The tool returned an error: "Missing required parameter: order_id". Correct Attribution: The tool call `lookup_order` failed due to a MALFORMED_ARGUMENT. The `order_id` was null, likely because the model failed to extract it from the user's input. User Report: "The report generation just hung and then said it failed." Trace shows a call to `generate_report` with a start time and an end time 30 seconds later with a status of "TIMEOUT". The tool's timeout threshold is 30 seconds. Correct Attribution: The tool call `generate_report` failed due to a TIMEOUT after 30 seconds, matching the tool's configured threshold.
After pasting this template, replace [USER_REPORT_DESCRIPTION] with the verbatim text from the user's support ticket or feedback channel. Replace [FULL_TRACE_JSON] with the complete trace object from your observability platform, ensuring it includes all spans, tool-call events, and error metadata. The output schema is designed to be machine-readable for automated ticketing systems, but the causal_chain and root_cause_summary fields provide the human-readable narrative needed for a postmortem. Before deploying this prompt into an automated pipeline, run it against a golden set of 20 known tool-failure traces to validate that primary_failure_tool_call.span_id and failure_type match your ground-truth labels with at least 90% accuracy.
Prompt Variables
Required inputs for the Tool Failure Attribution Prompt. Each placeholder must be populated from production trace data before the prompt is executed. Missing or malformed inputs are the most common cause of false attribution.
| Placeholder | Purpose | Example | Validation Notes |
|---|---|---|---|
[USER_REPORT] | The verbatim user complaint or feedback text describing the failure | The assistant said it couldn't find my order but I just placed it 5 minutes ago | Must be non-empty string. Truncate to 2000 chars. Flag for PII redaction before use. |
[TRACE_JSON] | The full production trace in structured JSON including all spans, tool calls, and responses | {"trace_id": "abc123", "spans": [...]} | Must parse as valid JSON. Must contain at least one tool-call span. Reject if spans array is empty or missing. |
[TOOL_CATALOG] | A list of available tools with their names, argument schemas, and expected behavior descriptions | ["search_orders": {"args": ["customer_id", "date_range"], "timeout_ms": 5000}] | Must be a valid JSON array. Each tool entry must include name and args. Null allowed if no tools are registered. |
[TIMEOUT_THRESHOLD_MS] | The maximum allowed tool execution time in milliseconds before a timeout is considered a failure | 5000 | Must be a positive integer. Default to 10000 if not provided. Values below 100 should trigger a warning. |
[ERROR_LOG] | Any error messages, stack traces, or exception data captured during the session | ToolExecutionError: search_orders timed out after 5000ms | Null allowed if no errors were logged. If present, must be non-empty string. Check for sensitive data before inclusion. |
[SESSION_METADATA] | Context about the user session including timestamps, model version, prompt version, and environment | {"model": "gpt-4o", "prompt_version": "v2.3.1", "env": "production"} | Must parse as valid JSON. Must include model and prompt_version fields. Reject if production environment is unconfirmed. |
[EXPECTED_BEHAVIOR] | A description of what the system should have done in this scenario under normal operation | When a user asks about a recent order, search_orders should be called with the customer_id and return results within 2 seconds | Must be a non-empty string. Should be sourced from the system prompt or runbook. Vague descriptions produce unreliable attribution. |
Implementation Harness Notes
How to wire the Tool Failure Attribution prompt into an observability pipeline for automated diagnosis.
The Tool Failure Attribution Prompt is designed to be integrated into an automated trace analysis pipeline, not used as a one-off chat interface. When a user report or support ticket is linked to a specific trace ID, the harness should fetch the full trace payload from your observability store (e.g., LangSmith, Arize, a custom OpenTelemetry collector), extract the relevant spans, and inject them into the prompt's [TRACE_JSON] placeholder. The [USER_REPORT] field should contain the verbatim user complaint, including any error messages they saw. The harness must also supply [TOOL_CATALOG] as a structured list of available tools with their expected argument schemas, so the model can distinguish between a tool timeout, an argument error, and a missing tool.
Before calling the LLM, validate the trace payload to ensure it contains at least one tool-call span. If the trace has no tool interactions, skip this prompt and route to a different diagnostic flow (e.g., a retrieval gap or model hallucination prompt). After receiving the model's output, parse the JSON response and validate that the attributed_tool_call_id field matches an actual span ID in the input trace. If the model attributes the failure to a tool call that does not exist in the trace, log a false-attribution event and retry with a stricter prompt variant that instructs the model to respond with "attributed_tool_call_id": null when no tool failure is found. This prevents the harness from acting on hallucinated attributions.
For high-severity incidents where the tool failure impacts billing, data integrity, or user safety, route the model's output to a human review queue before any automated remediation is triggered. The review interface should display the original trace visualization alongside the model's failure report, with the attributed span highlighted. Log every attribution result—including null attributions—to a dedicated tool_failure_attribution_log index with the trace ID, user report, model version, and attribution confidence score. This log becomes your ground-truth dataset for fine-tuning a smaller, faster attribution classifier later. Avoid wiring this prompt directly to automated rollback or tool-disable actions without human-in-the-loop approval for any action beyond a non-critical alert.
Expected Output Contract
Defines the required fields, types, and validation rules for the Tool Failure Attribution Report. Use this contract to parse, validate, and integrate the model's output into downstream systems.
| Field or Element | Type or Format | Required | Validation Rule |
|---|---|---|---|
failure_report_id | string (UUID) | Must match regex pattern for UUID v4. Parse check. | |
user_report_summary | string | Must be a non-empty string under 500 characters. Length check. | |
attributed_tool_call | object | Must contain 'tool_name' (string) and 'call_id' (string) fields. Schema check. | |
tool_error_type | enum | Must be one of: 'argument_error', 'tool_timeout', 'tool_not_found', 'permission_denied', 'unexpected_response'. Enum check. | |
trace_evidence | array of objects | Each object must have 'span_id' (string) and 'evidence_excerpt' (string). Min 1 item. Schema and length check. | |
root_cause_confidence | number | Must be a float between 0.0 and 1.0. Range check. If below 0.7, flag for human review. | |
recommended_remediation | string | Must be a non-empty string. If 'argument_error', must suggest a corrected argument. Conditional content check. | |
false_attribution_risk | string | If present, must be one of: 'low', 'medium', 'high'. If 'high', require human approval before accepting the report. Conditional approval check. |
Common Failure Modes
When attributing user-reported failures to specific tool calls, these are the most common ways the prompt breaks and how to prevent misattribution in production.
False Attribution to Wrong Tool
What to watch: The prompt blames a tool call that executed correctly while the real failure occurred earlier in the trace (e.g., a retrieval gap that starved the tool of correct arguments). Guardrail: Require the prompt to list all candidate tool calls with their error status before selecting the root cause. Validate attribution against explicit error codes, not proximity to the user complaint.
Ignoring Silent Argument Errors
What to watch: A tool call succeeds with a 200 status but receives semantically wrong arguments (e.g., a date parsed as the wrong timezone). The prompt treats the call as healthy and misses the real failure. Guardrail: Add a schema validation step that compares tool arguments against expected ranges, formats, and business rules before clearing a tool call as non-failing.
Timeout Misclassification
What to watch: The prompt treats a tool timeout as a tool logic failure rather than an infrastructure or rate-limit issue, recommending a code fix when the correct action is increasing the timeout or adding retry logic. Guardrail: Require the prompt to distinguish between timeout errors, HTTP 5xx errors, and application-level errors in its attribution. Include the exact error type in the failure report.
Trace Span Gaps Masking Failures
What to watch: Missing trace spans (due to instrumentation gaps or sampling) cause the prompt to skip over the actual failure point and blame the next visible tool call. Guardrail: Instruct the prompt to flag any gaps in the trace span sequence and downgrade its confidence score when spans are missing. Never allow attribution to skip over unobserved execution segments.
User Feedback Overweighting
What to watch: The prompt anchors on the user's description of the problem ("the search didn't work") and forces attribution to the search tool even when trace evidence points elsewhere. Guardrail: Require the prompt to evaluate trace evidence independently before considering user feedback. Include a contradiction flag when trace evidence conflicts with the user report.
Downstream Cascade Misattribution
What to watch: A failure in an early tool call cascades to later calls, but the prompt attributes the failure to the last tool in the chain rather than the originating error. Guardrail: Require the prompt to walk the tool-call sequence in chronological order and identify the first tool call with an error status or invalid output. Mark downstream failures as cascading effects, not root causes.
Evaluation Rubric
Criteria for evaluating the quality and correctness of the Tool Failure Attribution Prompt output before shipping or integrating into an automated pipeline.
| Criterion | Pass Standard | Failure Signal | Test Method |
|---|---|---|---|
Correct Tool-Call Identification | The [FAILED_TOOL_CALL_ID] in the output matches the exact span ID of the tool call that caused the error in the trace. | Output references a tool call that succeeded, a non-existent span ID, or blames the model when a tool timeout occurred. | Parse the output JSON and cross-reference the [FAILED_TOOL_CALL_ID] against the ground-truth error span in the provided [TRACE_JSON]. |
Accurate Error Classification | The [ERROR_CATEGORY] field exactly matches one of the allowed enum values: 'tool_timeout', 'invalid_argument', 'tool_returned_error', 'tool_not_found'. | Output uses a vague category like 'failure' or 'problem', or misclassifies a timeout as an invalid argument. | Validate the [ERROR_CATEGORY] string against the allowed enum list and check for consistency with the error message in the trace span. |
Argument Error Isolation | When [ERROR_CATEGORY] is 'invalid_argument', the [FAILED_ARGUMENT_NAME] field correctly identifies the specific parameter name from the tool call that caused the failure. | Output blames the wrong argument, lists all arguments, or fails to identify any argument when the trace shows a clear validation error. | Parse the tool call arguments from the trace span and verify the [FAILED_ARGUMENT_NAME] matches the field that triggered the error response. |
Remediation Actionability | The [RECOMMENDED_REMEDIATION] field provides a specific, implementable fix (e.g., 'Retry with a valid [PARAMETER] format: ISO 8601 date string') rather than generic advice. | Output contains vague suggestions like 'fix the error' or 'check the tool' without specifying what to change or how. | Human review by an engineer: can they implement the remediation without additional investigation? Score pass/fail. |
False-Attribution Prevention | The output does not attribute the failure to a tool call when the root cause is a missing tool, a prompt instruction error, or an infrastructure outage. | Output confidently blames a specific tool call when the trace shows the tool was never invoked or the error occurred outside any tool span. | Inject a trace where the failure is a missing tool definition. Verify the output abstains or correctly identifies 'tool_not_found' rather than blaming a call. |
Trace Evidence Grounding | Every claim in the [ERROR_CONTEXT] field is supported by a direct quote or timestamp reference from the provided [TRACE_JSON]. | Output fabricates error messages, hallucinates argument values not present in the trace, or makes claims without trace evidence. | Parse the [ERROR_CONTEXT] claims and use a substring search against the [TRACE_JSON] to confirm each quoted value or timestamp exists in the source. |
Confidence Score Calibration | The [CONFIDENCE_SCORE] is between 0.0 and 1.0, and scores below 0.8 correlate with ambiguous or incomplete trace data. | Output always returns 0.95+ even when the trace is truncated or the error message is ambiguous. | Run the prompt against a set of traces with known ambiguity levels. Check that confidence scores drop when error details are missing or conflicting. |
Output Schema Compliance | The output is valid JSON that strictly matches the [OUTPUT_SCHEMA] with all required fields present and no extra fields. | Output is missing required fields like [FAILED_TOOL_CALL_ID], contains markdown wrapping, or includes hallucinated fields not in the schema. | Validate the output against the [OUTPUT_SCHEMA] using a JSON schema validator. Reject any output that fails validation. |
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Adapt This Prompt
How to adapt
Use the base prompt with a single trace span and a simplified output schema. Drop the eval checks and focus on getting the tool-call identification right.
codeAnalyze this trace and identify which tool call failed: [TRACE_JSON] Return: { "failed_tool": string, "error_type": string, "argument_issue": string | null }
Watch for
- Misattributing a downstream error to the wrong tool call
- Missing timeout errors that don't produce explicit error messages
- Overly broad error_type values that don't help with remediation

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