Inferensys

Prompt

Agent Tool Circuit Breaker Test Prompt

A practical prompt playbook for reliability engineers to generate test scenarios that trigger circuit breaker thresholds and define expected open-circuit, half-open probing, and recovery behavior in production AI agent workflows.
Developer demonstrating multi-agent tool use, agent tool selection interface on laptop, casual tech demo moment.
PROMPT PLAYBOOK

When to Use This Prompt

Define the reliability engineering job, the required inputs, and the boundaries where this prompt stops being the right tool.

This prompt is for reliability engineers and AI platform operators who need to verify that an agent's circuit breaker logic works before a production incident forces the issue. The job-to-be-done is generating a structured test plan that exercises circuit breaker thresholds—error rates, latency spikes, and resource exhaustion—and defines the expected open-circuit behavior, half-open probing, and recovery criteria. You use this when you have a tool contract, a known degradation profile, and a circuit breaker configuration (thresholds, windows, recovery parameters) that needs systematic validation. The prompt produces a test specification, not a runtime implementation.

The ideal user brings three concrete inputs: a tool contract or API specification, the circuit breaker configuration (error threshold percentage, latency ceiling in milliseconds, evaluation window size, half-open probe limit, and cooldown period), and the agent's expected behavior contract (what the agent should do when the circuit opens—fallback to a secondary tool, return cached results, escalate to a human, or abort with a structured error). Without these inputs, the prompt will generate plausible but untethered scenarios that won't match your actual system. The prompt assumes you already have a circuit breaker implementation in place; it tests the configuration and agent response, not the breaker library itself.

Do not use this prompt when you need runtime circuit breaker monitoring, when you're designing the circuit breaker configuration from scratch without an existing agent behavior contract, or when the tool under test has irreversible side effects that can't be safely exercised in a test environment. This prompt generates test plans for pre-production validation. For production observability of circuit breaker state, use the Agent Tool Observability Log Generation Prompt Template instead. For designing degradation behavior before you have a circuit breaker, start with the Agent Tool Graceful Degradation Test Prompt. If the tool under test mutates production data, customer state, or financial records, you must pair this prompt's output with a mocked or sandboxed execution environment and require human review of the test plan before execution.

PRACTICAL GUARDRAILS

Use Case Fit

Where the Agent Tool Circuit Breaker Test Prompt delivers value and where it introduces risk. This prompt is designed for reliability engineers who need to verify that an agent's degradation guards work before production incidents expose them.

01

Good Fit: Pre-Production Resilience Testing

Use when: you are validating circuit breaker logic in a staging or test environment before an agent goes live. The prompt generates scenarios that trigger error rate thresholds, latency spikes, and resource exhaustion in a controlled way. Guardrail: always run against mocked or sandboxed tool endpoints—never point degradation tests at production APIs.

02

Bad Fit: Live Production Monitoring

Avoid when: you need real-time anomaly detection or incident response in a running system. This prompt generates test plans and scenarios, not runtime monitoring logic. Guardrail: pair this with a production observability prompt from the Tool Observability content group for runtime coverage. This prompt is a pre-flight check, not an in-flight monitor.

03

Required Input: Tool Reliability Contract

What you must provide: a clear definition of the tool's expected error rate, latency profile, throughput limits, and retry budget. Without this contract, the prompt cannot generate meaningful threshold scenarios. Guardrail: if the tool lacks a documented SLO or reliability contract, generate one first using the Tool Contract Definition prompt before attempting circuit breaker tests.

04

Operational Risk: Destructive Test Scenarios

What to watch: generated test plans may include scenarios that exhaust connection pools, trigger rate-limit bans, or corrupt stateful tool sessions if run against real endpoints. Guardrail: enforce a strict execution policy—all generated scenarios must target mock servers, shadow deployments, or isolated sandboxes. Add a human approval gate before any test touches a shared environment.

05

Operational Risk: Half-Open State Verification Gaps

What to watch: the prompt may generate recovery scenarios that assume the tool returns to healthy state cleanly, missing real-world cases where half-open probes succeed intermittently and cause flapping. Guardrail: explicitly request scenarios with probabilistic recovery, slow stabilization, and partial functionality return. Validate that the agent's half-open logic includes hysteresis to prevent rapid open-close cycling.

06

Bad Fit: Agent Logic Debugging

Avoid when: the primary goal is to debug why an agent selected the wrong tool or passed malformed arguments. This prompt focuses on degradation behavior under tool failure, not on tool selection or argument correctness. Guardrail: use the Agent Tool Selection Test Harness Prompt or Tool Argument Validation Test Prompt for routing and input validation issues. Reserve this prompt for resilience and recovery verification.

PROMPT PLAYBOOK

Copy-Ready Prompt Template

A reusable prompt that generates circuit breaker test scenarios for agent tool dependencies, including threshold definitions, expected open-circuit behavior, and recovery criteria.

This prompt template generates a structured test plan for validating that an agent's circuit breaker correctly opens, half-opens, and closes in response to tool degradation. It takes a tool contract, failure thresholds, and recovery parameters as inputs and produces executable test scenarios with pass/fail criteria. Use this before deploying any agent that depends on external tools where latency spikes, error bursts, or resource exhaustion could cascade into system-wide failure.

text
You are a reliability test engineer designing circuit breaker validation scenarios for an AI agent that calls external tools. Your output must be a structured test plan that exercises the circuit breaker's open, half-open, and closed states under controlled failure conditions.

## INPUTS
- Tool Contract: [TOOL_CONTRACT]
- Circuit Breaker Configuration: [CIRCUIT_BREAKER_CONFIG]
- Failure Thresholds: [FAILURE_THRESHOLDS]
- Recovery Parameters: [RECOVERY_PARAMETERS]
- Agent Behavior Specification: [AGENT_BEHAVIOR_SPEC]

## CIRCUIT BREAKER CONFIGURATION
[CIRCUIT_BREAKER_CONFIG] includes:
- error_threshold_percentage: the error rate that triggers the open state
- latency_threshold_ms: the maximum acceptable latency before a call is counted as degraded
- window_size_seconds: the sliding window for error rate calculation
- open_state_duration_seconds: how long the circuit stays open before transitioning to half-open
- half_open_max_requests: the number of probe requests allowed in half-open state
- success_threshold_for_close: the number of consecutive successes required to close the circuit

## OUTPUT SCHEMA
Return a JSON object with the following structure:
{
  "test_plan_id": "string",
  "circuit_breaker_under_test": "string",
  "test_scenarios": [
    {
      "scenario_id": "string",
      "scenario_name": "string",
      "trigger_condition": "string describing how to induce the failure",
      "failure_injection": {
        "method": "timeout | error_code | latency_spike | resource_exhaustion | malformed_response",
        "parameters": {},
        "duration_seconds": number
      },
      "expected_circuit_state_transition": {
        "from_state": "closed | open | half_open",
        "to_state": "closed | open | half_open",
        "transition_trigger": "string"
      },
      "expected_agent_behavior": "string describing what the agent should do",
      "pass_criteria": ["string"],
      "fail_criteria": ["string"],
      "recovery_verification": {
        "probe_expected": true,
        "probe_count": number,
        "expected_probe_outcome": "string"
      }
    }
  ],
  "edge_cases": [
    {
      "case_id": "string",
      "description": "string",
      "expected_behavior": "string",
      "risk_level": "low | medium | high"
    }
  ],
  "test_execution_order": ["scenario_id"],
  "cleanup_instructions": "string"
}

## CONSTRAINTS
- Generate at least one scenario for each circuit state transition: closed-to-open, open-to-half-open, half-open-to-closed, and half-open-back-to-open.
- Include scenarios for threshold boundary conditions: error rate exactly at threshold, latency exactly at threshold, and one request below threshold.
- Include at least one scenario where the circuit breaker should NOT open despite elevated errors within the window.
- Every scenario must include explicit pass/fail criteria that can be evaluated automatically.
- Do not generate scenarios that require destructive actions against production systems.
- All failure injection methods must be safe for test environments.
- Recovery verification must include probe request expectations.

## EXAMPLES
Example failure injection methods:
- "timeout": configure the mock to delay response beyond latency_threshold_ms
- "error_code": configure the mock to return 503 for a specified percentage of requests
- "latency_spike": configure the mock to add progressive delay across requests
- "resource_exhaustion": configure the mock to return 429 rate limit responses

## RISK LEVEL
[RISK_LEVEL] is [high | medium | low]. If high, add a human_review_required flag to each scenario and include escalation criteria.

Generate the complete test plan now.

Adaptation guidance: Replace [TOOL_CONTRACT] with the full OpenAPI spec, MCP tool definition, or function schema for the tool under test. [CIRCUIT_BREAKER_CONFIG] should contain the actual threshold values from your resilience configuration—do not use defaults. [FAILURE_THRESHOLDS] can be a subset of the circuit breaker config if you want to test specific boundary conditions. [RECOVERY_PARAMETERS] should include your half-open probe strategy and any cooldown periods. [AGENT_BEHAVIOR_SPEC] should describe what the agent is expected to do when the circuit is open: fallback to a cached response, escalate to a human, use a degraded alternative tool, or abort the workflow. Set [RISK_LEVEL] to high for tools that affect financial transactions, patient data, or infrastructure changes—this will add human review gates to every scenario. For lower-risk tools, medium or low will produce scenarios suitable for fully automated CI pipelines.

After copying the template, validate that your circuit breaker configuration values are consistent with the failure injection parameters you can actually produce in your test harness. A common mistake is defining thresholds that your mocking infrastructure cannot simulate precisely—for example, sub-millisecond latency thresholds when your mock framework only supports whole-millisecond resolution. Adjust either the thresholds or the injection method before generating scenarios. Run the generated test plan through your existing eval framework and flag any scenario where the pass/fail criteria cannot be evaluated programmatically; those scenarios need manual review criteria added.

IMPLEMENTATION TABLE

Prompt Variables

Placeholders required by the Agent Tool Circuit Breaker Test Prompt. Each variable shapes the test scenario generation and expected behavior definition. Validate inputs before running the prompt to prevent ambiguous or untestable outputs.

PlaceholderPurposeExampleValidation Notes

[TOOL_NAME]

Identifies the target tool under circuit breaker test

payment_gateway_api

Must match a registered tool name in the agent registry; reject empty or whitespace-only values

[TOOL_CONTRACT]

Full tool schema including endpoint, arguments, output shape, and error codes

{"endpoint": "POST /charge", "args": {"amount": "number"}, "errors": ["TIMEOUT", "503"]}

Must be valid JSON; validate against the tool registry schema before prompt assembly

[CIRCUIT_BREAKER_CONFIG]

Thresholds that define circuit state transitions: error rate, latency ceiling, consecutive failures, half-open probe count

{"error_rate_threshold": 0.5, "latency_threshold_ms": 2000, "consecutive_failures": 5, "half_open_probes": 3, "recovery_timeout_s": 30}

All numeric fields must be positive; error_rate_threshold must be between 0.0 and 1.0; reject if half_open_probes is 0

[DEGRADATION_MODE]

Expected fallback behavior when circuit is open: cached response, static default, user escalation, or abort

return_cached_result with max_age_seconds=300

Must be one of the enumerated degradation strategies defined in the agent's tool policy; reject unrecognized modes

[FAILURE_CATALOG]

List of failure types to inject during testing with their expected frequency or trigger conditions

["TIMEOUT", "HTTP_503", "MALFORMED_JSON", "AUTH_EXPIRED"]

Each entry must match an error code declared in [TOOL_CONTRACT]; empty catalog is valid only if testing baseline behavior

[RECOVERY_CRITERIA]

Conditions that must be met for the circuit to transition from open to half-open or closed

{"probe_success_count": 2, "probe_max_latency_ms": 1000, "probe_success_rate": 1.0}

All numeric fields must be positive; probe_success_rate must be between 0.0 and 1.0; probe_success_count must not exceed [CIRCUIT_BREAKER_CONFIG].half_open_probes

[OUTPUT_SCHEMA]

Expected structure of the generated test plan: scenario list, assertions per scenario, pass/fail criteria

{"scenarios": [{"name": "string", "injected_failure": "string", "expected_circuit_state": "OPEN|HALF_OPEN|CLOSED", "expected_agent_behavior": "string", "assertions": ["string"]}]}

Must be valid JSON Schema or a concrete example object; reject schemas that omit expected_circuit_state or assertions fields

PROMPT PLAYBOOK

Implementation Harness Notes

How to wire the circuit breaker test prompt into a reliability testing pipeline with validation, logging, and model selection.

This prompt is designed to be called programmatically as part of a pre-deployment reliability gate or a scheduled chaos engineering run. It should not be used as a one-off chat interaction. The harness must supply a structured tool contract, known failure thresholds, and the expected recovery policy. The prompt returns a test plan—a set of scenarios—that your test runner then executes against the actual agent and tool infrastructure. The prompt does not execute tests; it generates the specification for them.

Wire the prompt into a test orchestration pipeline (e.g., a CI/CD stage or a reliability workflow in Temporal, Airflow, or a custom test harness). The caller must provide: [TOOL_CONTRACT] (the full tool schema, description, and endpoint metadata), [CIRCUIT_BREAKER_CONFIG] (error rate threshold, latency p95 threshold, concurrency limit, half-open probe count, recovery timeout), and [DEGRADED_BEHAVIOR_POLICY] (the expected agent fallback: use stale cache, escalate to human, skip tool, or abort). The output is a JSON array of test scenarios. Validate the output before execution: each scenario must have a unique scenario_id, a trigger block (how to induce the failure), an expected_circuit_state (open, half-open, closed), and assertions (specific agent behaviors to check). Reject any scenario that lacks these fields or that proposes destructive actions against production endpoints. Use a strict JSON schema validator in your harness.

For model choice, prefer Claude 3.5 Sonnet or GPT-4o for their strong instruction-following on structured generation tasks. Avoid smaller models (e.g., GPT-3.5, Claude Haiku) for this prompt because they tend to conflate test scenario structure or omit required assertion fields. Set temperature=0.1 to minimize creative drift in scenario design. Implement a retry wrapper with up to 2 attempts if the output fails JSON schema validation; on the second retry, append the validation error to the prompt as [PREVIOUS_VALIDATION_ERROR]. Log every generated test plan to your observability stack (e.g., a tool_circuit_breaker_test_generation span) with the prompt version, model, input config hash, and validation pass/fail status. This trace is essential for debugging when generated scenarios are too permissive or miss failure modes.

Do not run the generated test scenarios directly against production tool endpoints without a safety review. The prompt may suggest latency injection or error simulation that requires a mocking layer (e.g., WireMock, a service mesh fault injection rule, or a dedicated test sandbox). If your tool has irreversible side effects (writes, sends, deletes), the test harness must route all generated scenarios through a read-only mock or a shadow endpoint. For high-risk tools, insert a human approval step: the generated test plan is reviewed by an on-call reliability engineer before the harness executes it. The prompt is a planning tool, not an autonomous test executor.

IMPLEMENTATION TABLE

Expected Output Contract

Fields, format, and validation rules for the Agent Tool Circuit Breaker Test Prompt output. Each row defines a required or optional element of the generated test plan, its expected type, whether it must be present, and the concrete validation rule to apply before the output is accepted into a test harness.

Field or ElementType or FormatRequiredValidation Rule

test_plan_id

string (slug)

Must match pattern ^cb-test-[a-z0-9-]+$. Reject if missing or non-matching.

circuit_breaker_name

string

Must be a non-empty string matching the target circuit breaker identifier provided in [CIRCUIT_BREAKER_ID]. Reject if empty or mismatched.

scenarios

array of objects

Must be a non-empty array. Each object must contain 'scenario_id', 'trigger_condition', 'expected_state', and 'recovery_criteria' fields. Reject if array is empty or any required field is missing.

scenarios[].scenario_id

string (slug)

Must be unique within the array and match pattern ^scenario-[a-z0-9-]+$. Reject on duplicate or invalid format.

scenarios[].trigger_condition

object

Must contain exactly one of: 'error_rate_threshold', 'latency_threshold_ms', or 'resource_exhaustion_signal'. Reject if missing, empty, or contains multiple trigger types.

scenarios[].expected_state

string (enum)

Must be one of: 'OPEN', 'HALF_OPEN', 'CLOSED'. Reject if value is outside this enum.

scenarios[].recovery_criteria

object

Must contain 'probe_success_threshold' (integer >= 1) and 'probe_interval_ms' (integer >= 0). Reject if fields are missing or out of range.

global_assertions

array of strings

If present, each string must be a non-empty assertion statement. Null allowed. Reject if array contains empty strings.

PRACTICAL GUARDRAILS

Common Failure Modes

Circuit breaker tests fail silently when the prompt doesn't define thresholds, recovery behavior, or the difference between transient and systemic failures. These cards cover the most common failure modes and how to prevent them before production deployment.

01

Undefined Thresholds Cause Flapping

What to watch: The prompt describes circuit breaker logic but omits concrete numeric thresholds for error rate, latency, or consecutive failures. The agent either never trips the breaker or trips it on the first transient glitch. Guardrail: Require explicit threshold parameters in the prompt template—error rate percentage, latency p95 in milliseconds, and minimum sample window size—so the test scenario generator produces measurable pass/fail conditions.

02

Half-Open Probing Without Rate Limiting

What to watch: The prompt instructs the agent to probe a half-open circuit but doesn't cap probe frequency. The agent floods the degraded tool with probe requests, turning a recovery test into a self-inflicted denial-of-service. Guardrail: Add a max_probe_rate constraint and a probe_cooldown_seconds parameter. The test scenario must verify that probe volume stays within the defined budget during half-open state.

03

Recovery Criteria Confuse Transient and Systemic Failures

What to watch: The prompt treats all failures identically. A 503 after one retry trips the breaker permanently, or a persistent dependency outage is retried indefinitely because the error type isn't classified. Guardrail: Define separate failure taxonomies—transient (timeout, 429, 503) versus systemic (auth failure, 400, contract mismatch)—with distinct thresholds and recovery paths. The test scenario generator must produce both classes and verify differentiated behavior.

04

Missing State Persistence Across Test Steps

What to watch: The prompt generates test scenarios that reset circuit state between steps. A breaker that should remain open after step 3 is magically closed at step 4 because the test harness doesn't carry state forward. Guardrail: Include explicit state-passing instructions in the prompt: circuit state, failure count, last failure timestamp, and probe outcome must persist across all steps in the scenario. Validate that state transitions match the declared breaker logic.

05

Degraded-Mode Behavior Is Left Implicit

What to watch: The prompt tests whether the circuit opens but never defines what the agent should do while the circuit is open. The agent either halts entirely or hallucinates tool results to keep the workflow moving. Guardrail: Require a degraded_action field in the test scenario output—fallback tool, cached result, user escalation, or graceful abort—and verify that the agent executes it correctly during the open-circuit window.

06

Test Scenarios Don't Exercise Boundary Conditions

What to watch: The prompt generates only happy-path degradation tests—exactly N failures, clean recovery. It misses boundary cases: error rate exactly at threshold, latency exactly at p95 cutoff, concurrent failures across multiple tool instances, or recovery during the first probe. Guardrail: Add a boundary_coverage requirement to the prompt that forces generation of at-threshold, just-below-threshold, and just-above-threshold scenarios. Validate that the output includes at least one scenario per boundary class.

IMPLEMENTATION TABLE

Evaluation Rubric

Use this rubric to evaluate the quality of test scenarios generated by the Agent Tool Circuit Breaker Test Prompt. Each criterion maps to a pass standard, a failure signal, and a concrete test method that can be automated or reviewed manually before the test plan is executed.

CriterionPass StandardFailure SignalTest Method

Threshold Definition

Each test scenario specifies a concrete numeric threshold (error rate, latency ms, resource %) that triggers the circuit breaker.

Scenario uses vague language like 'high error rate' or 'slow response' without a measurable value.

Regex scan for numeric values adjacent to threshold keywords; manual review for threshold-context pairing.

State Transition Completeness

Scenario defines the expected state transition sequence: CLOSED → OPEN → HALF_OPEN → CLOSED (or escalation).

Scenario omits one or more states, or describes an impossible transition (e.g., OPEN → CLOSED without HALF_OPEN).

State machine validation: parse output for state labels and verify the directed graph matches the circuit breaker pattern.

Probing Behavior Specification

Scenario defines the half-open probe: how many requests, what success criteria, and the timeout before retrying.

Scenario mentions 'half-open' or 'probing' without specifying probe count, success threshold, or probe interval.

Schema check for [PROBE_COUNT], [PROBE_SUCCESS_THRESHOLD], and [PROBE_INTERVAL_MS] fields; null check on each.

Recovery Criteria

Scenario defines explicit conditions for transitioning from OPEN to HALF_OPEN (e.g., cooldown duration elapsed) and from HALF_OPEN to CLOSED (e.g., probe success rate).

Scenario assumes automatic recovery without defining the cooldown timer or probe success threshold.

Assert that [COOLDOWN_DURATION_MS] and [RECOVERY_SUCCESS_RATE] are present and non-null for each scenario.

Escalation Path

Scenario defines what happens when recovery fails: escalation to human operator, fallback to degraded mode, or permanent circuit trip.

Scenario loops indefinitely or ends with 'circuit remains open' without specifying next action.

Check for presence of [ESCALATION_ACTION] field with a value from the allowed enum: HUMAN_REVIEW, DEGRADED_MODE, PERMANENT_TRIP.

Tool Call Isolation

Each scenario targets a single tool or tool group; the circuit breaker scope is explicit (per-tool, per-endpoint, per-tool-group).

Scenario mixes multiple unrelated tools in one circuit breaker definition without clarifying scope.

Validate that [TOOL_IDENTIFIER] or [TOOL_GROUP] is present and maps to a tool defined in the input [TOOL_REGISTRY].

Idempotency and Retry Safety

Scenario specifies whether retries and probes use idempotency keys and verifies that duplicate side effects are prevented.

Scenario describes retries or probes without mentioning idempotency for non-idempotent tools.

Assert that [IDEMPOTENCY_REQUIRED] is true for any tool marked non-idempotent in [TOOL_REGISTRY]; check for [IDEMPOTENCY_KEY_SOURCE].

Observability Assertions

Scenario defines the expected log fields, metrics, or trace spans emitted when the circuit breaker changes state.

Scenario has no observability assertions, making it impossible to verify circuit breaker behavior in production.

Schema check for [EXPECTED_LOG_FIELDS] or [EXPECTED_METRICS] array with at least one entry per state transition.

ADAPTATION OPTIONS

Adapt This Prompt

How to adapt

Add the full contract: error budget, latency percentiles, concurrency limits, and half-open probe rules. Require structured output with explicit pass/fail assertions per scenario. Wire the output into a test runner.

code
Generate circuit breaker test scenarios for [TOOL_NAME].

Circuit config:
- Error rate threshold: [ERROR_RATE]% over [WINDOW_SECONDS]s
- Latency threshold: p[PERCENTILE] > [LATENCY_MS]ms
- Max concurrent calls: [MAX_CONCURRENCY]
- Half-open probe count: [PROBE_COUNT]
- Recovery criteria: [RECOVERY_RULES]

Output schema:
{
  "scenarios": [
    {
      "id": "string",
      "trigger": "error_rate | latency | concurrency | compound",
      "precondition": "string",
      "expected_state": "OPEN | HALF_OPEN | CLOSED",
      "expected_agent_behavior": "string",
      "assertions": ["string"]
    }
  ]
}

Watch for

  • Missing edge cases around state transitions
  • Half-open probe logic that doesn't match your recovery rules
  • Scenarios that don't exercise concurrency limits
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.