Inferensys

Prompt

Tool Degradation Detection Prompt Template

A practical prompt playbook for platform reliability engineers to detect and assess tool degradation in production AI agents using structured response patterns, latency metrics, and error signatures.
Developer demonstrating multi-agent tool use, agent tool selection interface on laptop, casual tech demo moment.
PROMPT PLAYBOOK

When to Use This Prompt

Use this prompt inside an agent health monitor or pre-flight check to assess tool degradation before cascading failures impact users.

This prompt is designed for platform reliability engineers and agent developers who need an automated, structured assessment of tool health before cascading failures impact users. Use it inside an agent health monitor, a pre-flight check before critical tool calls, or as part of a circuit breaker decision pipeline. The prompt ingests recent tool response patterns, latency metrics, and error signatures, then produces a degradation assessment with a severity classification, supporting evidence, and a recommended action. It assumes you already collect tool-level telemetry and can feed that data into the prompt context.

Do not use this prompt as a replacement for metric-based alerting; it is a reasoning layer that interprets signals a threshold-based system might miss or misclassify. The prompt works best when paired with a validation harness that checks output schema compliance, severity classification consistency, and evidence grounding. For high-risk production systems, always route the assessment through a human review step before triggering automated circuit breaker state changes or load shedding decisions. The prompt is not designed for real-time sub-second decisions—expect latency appropriate for LLM inference and budget accordingly.

Before deploying, calibrate the prompt against your historical incident data. Run it against known degradation events to verify it correctly classifies severity and recommends appropriate actions. Pay special attention to false-positive degradation signals during maintenance windows, deployment rollouts, and known brownout periods. The prompt's value comes from catching subtle degradation patterns—gradual latency creep, intermittent error rate increases, or partial failure modes—that static thresholds routinely miss. Wire the output into your existing observability stack, not as a standalone alerting channel.

PRACTICAL GUARDRAILS

Use Case Fit

Where the Tool Degradation Detection Prompt Template delivers reliable signals and where it introduces operational risk.

01

Good Fit: Production Health Monitoring

Use when: You have consistent tool response patterns, latency metrics, and error signatures flowing through a monitoring pipeline. The prompt excels at structured degradation assessment from known signals. Guardrail: Feed it pre-aggregated metrics windows rather than raw log streams to keep context manageable and assessment stable.

02

Good Fit: Pre-Flight Health Checks

Use when: Agents run a self-check before executing tool calls to assess current tool availability and recent failure patterns. Guardrail: Pair the prompt output with a hard timeout and circuit breaker state check—never let the health check itself become a blocking dependency.

03

Bad Fit: Real-Time Stream Interruption

Avoid when: You need sub-millisecond degradation decisions on live request paths. The prompt adds inference latency unsuitable for hot-path circuit breaking. Guardrail: Use this prompt for async analysis and policy updates; keep inline circuit breakers in application code with pre-computed thresholds.

04

Bad Fit: No Baseline Data Available

Avoid when: You lack historical latency distributions, error rate baselines, or normal behavior profiles. The prompt cannot distinguish degradation from normal variance without reference points. Guardrail: Require at least 7 days of baseline metrics before enabling degradation detection; otherwise, flag output as 'insufficient data'.

05

Required Inputs

Must provide: Recent tool response patterns (success/failure counts), latency percentiles (p50, p95, p99), error signatures (status codes, exception types), and a historical baseline window. Guardrail: Validate input completeness before invocation—missing latency data produces false-negative degradation assessments that miss silent slowdowns.

06

Operational Risk: False-Positive Cascades

What to watch: Overly sensitive degradation detection triggers unnecessary circuit breaks, fallback chains, and on-call alerts. Guardrail: Calibrate thresholds using a holdout dataset with known good and bad periods. Require consecutive degradation signals across multiple assessment windows before escalating to automated action.

PROMPT PLAYBOOK

Copy-Ready Prompt Template

Paste this prompt into your agent health monitor or pre-flight check system. Replace square-bracket placeholders with live telemetry data before each invocation.

This prompt template is designed to be invoked by an agent health monitor or a pre-flight check system before a critical tool execution window. Its job is to produce a structured degradation assessment from raw telemetry, not to make the final circuit-breaking decision. The output should be consumed by a downstream policy engine that compares the assessment against defined thresholds. Do not use this prompt for real-time per-call decisions where latency is critical; it is intended for periodic health checks or state transition evaluations.

text
You are an agent tool reliability analyzer. Your task is to assess the health of a specific tool based on recent telemetry data and produce a structured degradation assessment.

## INPUT DATA
- Tool Name: [TOOL_NAME]
- Current Circuit State: [CIRCUIT_STATE]
- Observation Window: [WINDOW_DURATION]
- Total Calls in Window: [TOTAL_CALLS]
- Failure Count: [FAILURE_COUNT]
- Error Signature Summary: [ERROR_SIGNATURES]
- P50 Latency: [P50_LATENCY]
- P99 Latency: [P99_LATENCY]
- Baseline P50 Latency: [BASELINE_P50]
- Baseline P99 Latency: [BASELINE_P99]
- Retry Budget Remaining: [RETRY_BUDGET_PCT]
- Dependency Health Status: [DEPENDENCY_HEALTH]

## OUTPUT SCHEMA
Return a valid JSON object with the following fields:
- "degradation_level": "healthy" | "degraded" | "unhealthy" | "unknown"
- "primary_signal": string (the single strongest indicator for the assessment)
- "evidence_summary": string (2-3 sentence summary of the telemetry patterns observed)
- "false_positive_risk": "low" | "medium" | "high" (likelihood this is a transient blip, not real degradation)
- "false_negative_risk": "low" | "medium" | "high" (likelihood real degradation is being masked)
- "recommended_action": "none" | "probe" | "degrade" | "circuit_break" | "escalate"
- "action_rationale": string (1 sentence explaining the recommended action)
- "confidence": float between 0.0 and 1.0

## CONSTRAINTS
- Do not recommend circuit_break unless failure rate exceeds 50% AND errors are non-transient (5xx, timeout, connection refused).
- A latency increase alone without errors should produce degradation_level "degraded", not "unhealthy".
- If the observation window has fewer than 10 calls, set degradation_level to "unknown" and confidence below 0.5.
- If dependency health status indicates upstream failures, note this in evidence_summary but assess the tool itself.
- Never hallucinate metrics not present in the input data.
- If error signatures are empty but latency is elevated, primary_signal must reference the latency anomaly.

## EXAMPLES
### Example 1: Clear Failure
Input: Tool=payment-api, Failures=45/100, P99=1200ms (baseline 200ms), Errors=timeout+connection_refused
Output: {"degradation_level": "unhealthy", "primary_signal": "45% failure rate with connection-refused errors", ...}

### Example 2: Latency-Only Degradation
Input: Tool=search-index, Failures=0/500, P99=800ms (baseline 150ms), Errors=none
Output: {"degradation_level": "degraded", "primary_signal": "P99 latency 5.3x baseline with zero errors", ...}

### Example 3: Low Sample Size
Input: Tool=audit-log, Failures=0/3, P99=100ms (baseline 90ms), Errors=none
Output: {"degradation_level": "unknown", "primary_signal": "insufficient sample size (3 calls)", "confidence": 0.3, ...}

Adapt this template by adjusting the thresholds in the CONSTRAINTS section to match your specific SLOs. If your tool has idempotency guarantees, add a constraint that permits retries for idempotent-safe errors. For tools with strict data freshness requirements, add a field to the INPUT DATA for [MAX_STALENESS_TOLERANCE] and include it in the assessment logic. Always test the prompt against your historical incident data to calibrate the false-positive and false-negative risk assessments before deploying to production.

IMPLEMENTATION TABLE

Prompt Variables

Each placeholder must be populated with live telemetry data before the prompt is sent. Validation notes describe what makes each variable reliable.

PlaceholderPurposeExampleValidation Notes

[TOOL_NAME]

Identifies the specific tool or endpoint under evaluation

payment-api-v2

Must match a registered tool ID in the agent registry; reject if not found in active tool manifest

[OBSERVATION_WINDOW]

Defines the lookback period for telemetry aggregation

last_15m

Must be a valid duration string parseable by the metrics store; reject if window exceeds data retention limit

[ERROR_RATE]

Current error ratio over the observation window

0.23

Must be a float between 0.0 and 1.0; reject if null when error count > 0; flag if derived from fewer than 100 requests

[LATENCY_P99]

99th percentile response latency in milliseconds

4500

Must be a positive integer; reject if negative or zero; flag if p99 exceeds 10x the p50 baseline

[ERROR_SIGNATURES]

Array of distinct error types observed with counts

["timeout:42","5xx:18","connection_refused:7"]

Must be a valid JSON array of strings; reject if empty when error rate > 0; each entry must match pattern type:count

[DEPENDENCY_GRAPH]

Upstream and downstream tool dependencies for blast radius analysis

{"upstream":["auth-svc"],"downstream":["order-svc","notification-svc"]}

Must be valid JSON with upstream and downstream arrays; reject if referencing unknown tool IDs; flag if circular dependency detected

[BASELINE_LATENCY_P50]

Historical median latency for comparison during anomaly detection

120

Must be a positive integer; reject if null or zero; must be sourced from a stable baseline period of at least 7 days

[ACTIVE_CIRCUIT_STATE]

Current circuit breaker state for the tool

closed

Must be one of closed, open, or half-open; reject if state transition timestamp is older than the observation window

PROMPT PLAYBOOK

Implementation Harness Notes

How to wire the degradation detection prompt into an agent health monitor or pre-flight check system.

This prompt is designed to be called by an agent health monitor, not directly by an end user. The typical integration point is a pre-flight check that runs before a critical tool execution, or a periodic background health assessment that feeds a circuit breaker. The harness must collect the required inputs—recent tool response patterns, latency metrics, and error signatures—from your observability stack and format them into the [TOOL_OBSERVABILITY_DATA] placeholder. Do not pass raw, unbounded log streams; the prompt expects a structured summary with a defined lookback window (e.g., last 60 seconds or last N calls).

The output is a structured degradation assessment that your application code must parse and act on. Implement a strict JSON schema validator on the model's response before accepting it. The schema should enforce the degradation_level enum (none, minor, major, critical), require a confidence score between 0.0 and 1.0, and validate that the evidence array contains at least one concrete observation. If validation fails, retry once with the validation error message appended to the prompt as additional [CONSTRAINTS]. If the second attempt also fails, default to a safe state: treat the tool as degraded and trigger a human review alert. Log every assessment—including the raw prompt, model response, validation result, and final action taken—to your agent trace store for post-incident analysis.

Calibrate the [DEGRADATION_THRESHOLDS] placeholder with values derived from your tool's historical performance baselines, not arbitrary defaults. A latency threshold that is too tight will generate false-positive degradation signals and trigger unnecessary circuit breaks; a threshold that is too loose will miss real failures. Run this prompt against a golden dataset of known-good and known-degraded tool behavior patterns before deployment. Measure precision and recall on degradation detection, and adjust thresholds until false-positive and false-negative rates are acceptable for your risk tolerance. In high-risk domains where a missed degradation could cause data loss or user harm, always require human review for major and critical assessments before automated action is taken.

IMPLEMENTATION TABLE

Expected Output Contract

The prompt must return a JSON object matching this schema. Validate every field before acting on the assessment.

Field or ElementType or FormatRequiredValidation Rule

degradation_detected

boolean

Must be true or false. If false, all other fields except evidence_summary must be null.

degradation_type

string (enum)

true if degradation_detected is true

Must be one of: 'latency_spike', 'error_rate_increase', 'partial_response', 'timeout_cluster', 'schema_drift', 'total_failure', 'intermittent_failure'. Reject unknown values.

severity

string (enum)

true if degradation_detected is true

Must be one of: 'critical', 'major', 'minor', 'cosmetic'. Must align with user_impact_estimate.

confidence_score

number (0.0-1.0)

Float between 0.0 and 1.0. If below 0.6, recommended_action must include 'human_review'.

affected_tools

array of strings

true if degradation_detected is true

Each element must match a tool name from the provided [TOOL_REGISTRY]. Array must not be empty.

evidence_summary

string

Must be 1-3 sentences. Must reference specific metrics from [METRICS_PAYLOAD]. Must not contain markdown.

recommended_action

string (enum)

Must be one of: 'circuit_breaker_open', 'switch_to_fallback', 'reduce_concurrency', 'alert_oncall', 'human_review', 'continue_observe', 'no_action'. Must be consistent with severity.

retry_recommendation

object

If present, must contain 'should_retry' (boolean) and 'max_retries' (integer >= 0). If should_retry is true, max_retries must be > 0.

PRACTICAL GUARDRAILS

Common Failure Modes

Tool degradation detection prompts fail in predictable ways when deployed in production environments. These cards cover the most common failure modes and the guardrails that prevent them from causing cascading reliability issues.

01

False-Positive Degradation Alerts

What to watch: The prompt flags a tool as degraded when it's actually healthy—often triggered by transient latency spikes, single-timeout outliers, or normal batch-processing delays. This leads to unnecessary circuit breaks and degraded-mode operation. Guardrail: Require sustained anomaly windows (e.g., 3 consecutive failures or p95 latency exceeding threshold for 5+ minutes) before triggering degradation. Calibrate thresholds against historical baseline distributions, not absolute values.

02

False-Negative Silent Failures

What to watch: The prompt misses genuine degradation because error signatures are subtle—partial responses, increasing latency within acceptable bounds, or error codes that don't match known patterns. The agent continues calling a failing tool, compounding downstream failures. Guardrail: Include multi-signal detection logic: error rate, latency drift, response completeness, and semantic quality of tool outputs. Add a 'degradation confidence score' that surfaces borderline cases for human review rather than binary pass/fail.

03

Threshold Drift Under Load Variation

What to watch: Static thresholds calibrated during low-traffic periods become useless during peak load, generating either alert storms or complete silence. The prompt lacks awareness of load context and treats all latency increases identically. Guardrail: Normalize thresholds against current request volume and concurrency. Include load-aware context in the prompt: 'Current throughput is [X] req/s; expected p95 at this load is [Y]ms.' Recalibrate baselines weekly from production telemetry.

04

Error Signature Misclassification

What to watch: The prompt misclassifies error types—treating a 429 rate limit as a backend failure, or a 503 as retryable when the service is down for maintenance. This produces wrong circuit breaker transitions and inappropriate retry behavior. Guardrail: Include a structured error taxonomy in the prompt with explicit classification rules: transient vs. permanent, client vs. server, retryable vs. fatal. Add test cases for ambiguous error codes (e.g., 502 from proxy vs. 502 from origin) and require evidence citation for each classification.

05

Context Window Contamination from Stale Metrics

What to watch: The prompt receives metrics that are minutes old due to collection lag, or mixes fresh and stale data without timestamp awareness. The agent makes degradation decisions on outdated information, breaking circuits for already-recovered tools or missing active outages. Guardrail: Require explicit timestamps on all metric inputs and include a 'data freshness' check in the prompt: discard or weight-down metrics older than [N] seconds. Add a staleness warning field in the output when any input exceeds the freshness threshold.

06

Cascading Degradation from Dependency Blindness

What to watch: The prompt assesses each tool in isolation, missing that Tool A's degradation is caused by Tool B's failure. The agent breaks circuits on healthy downstream tools while the root cause remains unaddressed. Guardrail: Include a dependency graph in the prompt context showing upstream/downstream relationships. Require the prompt to check whether observed degradation correlates with known upstream failures before recommending circuit breaks. Output a 'suspected root cause' field that traces degradation to its source.

IMPLEMENTATION TABLE

Evaluation Rubric

Test the prompt against these scenarios before deploying to production. Each scenario should produce the expected output or fall within the acceptable range.

CriterionPass StandardFailure SignalTest Method

Clear degradation signal

Output contains degradation_detected: true with confidence >= 0.8 when error rate > 5% and p95 latency > 2x baseline

Returns degradation_detected: false or confidence < 0.5 despite clear signal pattern

Run against golden dataset of 20 known-degraded tool response windows

False positive suppression

Output contains degradation_detected: false when error rate < 1% and latency within 1.2x baseline for 10 consecutive windows

Flags degradation during normal variance or single transient spike

Inject 15 normal-operation windows with minor latency jitter; verify no false alarms

Error signature classification

error_signature field matches injected error type (timeout, 5xx, connection_refused, partial_response) with >= 90% accuracy

Misclassifies timeout as 5xx or labels partial response as complete failure

Send 10 windows each with single dominant error signature; check classification accuracy

Latency anomaly detection

latency_assessment.severity is 'critical' when p95 > 5x baseline, 'warning' when 2-5x, 'normal' when < 2x

Labels 5x latency spike as 'normal' or 1.5x as 'critical'

Feed windows with controlled p95 multipliers at 1x, 2.5x, 6x baseline; verify severity mapping

Confidence calibration

Confidence score correlates with signal strength: r >= 0.7 between confidence and actual degradation severity across test set

High confidence (>= 0.9) on ambiguous windows or low confidence (< 0.3) on obvious failures

Compute Pearson correlation across 50 mixed-severity windows with ground-truth labels

Threshold boundary handling

Correctly handles edge cases at exact threshold boundaries (error rate = 5%, latency = 2x baseline) with consistent classification

Flips classification on repeated identical boundary inputs or produces null result

Send 5 identical boundary-condition windows; verify output consistency across all 5

Multi-signal correlation

When both error rate and latency are elevated, degradation_detected confidence is higher than single-signal windows

Confidence drops or stays flat when multiple signals confirm degradation

Compare confidence scores between single-signal and dual-signal degradation windows with matched severity

Empty or missing metrics handling

Returns structured output with degradation_detected: null and assessment: 'insufficient_data' when [METRICS_WINDOW] is empty or missing required fields

Hallucinates degradation status or throws unhandled format error

Send empty object, missing latency field, and null input; verify graceful insufficient-data response

ADAPTATION OPTIONS

Adapt This Prompt

How to adapt

Wrap the prompt in a harness that injects [TOOL_METRICS_WINDOW], [BASELINE_STATS], and [RECENT_ERROR_SIGNATURES] from your observability stack. Add a JSON schema validator on the output. Implement a cooldown so the same degradation signal doesn't re-trigger within [COOLDOWN_SECONDS]. Log every assessment with trace_id, tool_name, and decision for postmortems.

Watch for

  • Schema drift when the model adds or renames fields under load
  • False negatives when error signatures are novel and don't match [KNOWN_ERROR_PATTERNS]
  • Threshold calibration decay as tool performance baselines shift after deployments
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.