Inferensys

Prompt

Circuit Breaker State Verification Prompt

A practical prompt playbook for using Circuit Breaker State Verification Prompt in production AI workflows.
Developer doing prompt engineering on laptop, prompt variations visible on screen, casual coding session.
PROMPT PLAYBOOK

When to Use This Prompt

Defines the ideal scenario, user, and prerequisites for using the Circuit Breaker State Verification Prompt, and clarifies when it should not be used.

This prompt is designed for resilience engineers, SREs, and agent operators who need to programmatically verify the health of circuit breakers protecting downstream services before an agent executes a call. The core job-to-be-done is preventing wasted work: an agent should not attempt to call a service whose circuit breaker is already open, as this guarantees a failure, consumes resources, and can trigger cascading timeouts. The ideal user is someone integrating this check into an agent's precondition validation step, typically within a workflow engine, an agent harness, or a service mesh sidecar. You must already be collecting structured circuit breaker state data—such as failure counts, success counts, cooldown timestamps, and current state (CLOSED, OPEN, HALF_OPEN)—from your resilience library (e.g., Polly, Resilience4j, Hystrix), API gateway, or service mesh control plane. The prompt assumes this raw data is available and can be formatted as a structured input, such as a JSON object, for the model to interpret.

Concretely, use this prompt when you need a human-readable, structured summary of breaker state that an agent can reason about to decide its next action. For example, if a payment processing agent is about to call a fraud detection service, the harness should first run this prompt with the fraud service's breaker metrics. The output will tell the agent whether the circuit is open, how many failures have accumulated, when the cooldown period ends, and whether a half-open probe is advisable. This allows the agent to choose a fallback path—such as using a cached risk score or escalating for manual review—instead of failing mid-transaction. The prompt is also valuable for generating a pre-flight dashboard or log entry that gives operators visibility into why an agent chose a degraded path. However, do not use this prompt as a real-time circuit breaker itself; it does not make tripping decisions. It is a verification and summarization tool for an existing breaker mechanism, not a replacement for one. It is also not a substitute for a metrics dashboard or alerting system; its value is in providing an agent with a structured, contextualized state report at decision time.

Before implementing this prompt, ensure you have a reliable data pipeline that feeds breaker state into the prompt's [CIRCUIT_BREAKER_STATE] placeholder. The data must be fresh—stale state can cause the agent to attempt calls against a newly opened circuit or skip a service that has already recovered. If your breaker implementation does not expose a cooldown timestamp or half-open state, you should adapt the prompt template to remove those fields rather than providing null values, as the model may hallucinate a recovery timeline. Finally, recognize that this prompt is a single step in a larger resilience strategy. It should be paired with a fallback action selector prompt and a post-call result recorder to close the loop. If your agent operates in an environment where circuit breaker state changes faster than your data refresh interval, you should augment this prompt with a direct health-check probe instead of relying solely on the reported state.

PRACTICAL GUARDRAILS

Use Case Fit

Where the Circuit Breaker State Verification Prompt works and where it introduces new risks. Use this to decide whether the prompt fits your resilience architecture before wiring it into an agent harness.

01

Good Fit: Pre-Call Resilience Gates

Use when: an agent must call a downstream service protected by a circuit breaker, and you need a machine-readable state summary before attempting the call. Guardrail: run this prompt immediately before the outbound call, not at plan-generation time, so the breaker state is fresh.

02

Good Fit: Half-Open Probing Logic

Use when: the breaker is half-open and the agent needs to decide whether to send a probe request or wait for the cooldown window to close. Guardrail: pair this prompt with a harness-level probe timeout; the model should never block the probe itself.

03

Bad Fit: Real-Time Circuit Actuation

Avoid when: you need the model to open or close the circuit breaker itself. This prompt reads state; it does not command the breaker. Guardrail: keep breaker state transitions in application code, not in model output, to prevent prompt injection from flipping breakers.

04

Bad Fit: Single-Step Agent Pipelines

Avoid when: the agent has no fallback path and the breaker state is the only decision point. A simple SDK check is cheaper and more reliable. Guardrail: use this prompt only when the breaker state must be combined with other contextual reasoning before choosing an action.

05

Required Input: Breaker Telemetry Snapshot

Risk: the model hallucinates breaker state if given only a service name. Guardrail: always provide a structured telemetry snapshot including failure count, last failure timestamp, cooldown seconds remaining, and current state enum. Never ask the model to infer state from logs alone.

06

Operational Risk: Stale State Decisions

Risk: the breaker transitions between the time the prompt runs and the agent acts on the recommendation. Guardrail: implement a harness-level TTL on the prompt output and re-verify breaker state at the call site. Treat the model's summary as advisory, not transactional.

PROMPT PLAYBOOK

Copy-Ready Prompt Template

A copy-paste system prompt that instructs the model to verify circuit breaker states from provided metrics and return a structured, actionable summary.

This prompt template is designed to be pasted directly into your agent's system instructions or a dedicated verification task step. It forces the model to act as a deterministic resilience checker, not a conversational assistant. The model's job is to ingest raw breaker metrics, apply explicit threshold rules, and produce a structured state summary. It must not invent metrics, guess at cooldown timers, or recommend actions without evidence from the provided [BREAKER_METRICS] payload.

code
You are a circuit breaker state verification agent. Your sole task is to analyze the provided breaker metrics and return a structured state report. Do not perform any other action, call any tool, or generate conversational text.

## INPUT
Analyze the following circuit breaker metrics payload:
[BREAKER_METRICS]

## CONSTRAINTS
- Classify each breaker's state as CLOSED, OPEN, or HALF_OPEN based *only* on the provided failure count, threshold, and cooldown fields.
- If a breaker is OPEN, calculate the remaining cooldown seconds as (cooldown_period_seconds - seconds_since_last_failure). If this value is negative, treat it as 0.
- If a breaker is HALF_OPEN, flag it as requiring a probe attempt before full recovery.
- Do not infer state from breaker names or downstream service names.
- If any required field (failure_count, threshold, cooldown_period_seconds, last_failure_timestamp) is missing for a breaker, flag its state as UNKNOWN and include a `missing_fields` list in the output.

## OUTPUT_SCHEMA
Return a valid JSON object with the following structure:
{
  "overall_status": "ALL_CLOSED" | "DEGRADED" | "OPEN_CIRCUIT",
  "breakers": [
    {
      "name": "string",
      "state": "CLOSED" | "OPEN" | "HALF_OPEN" | "UNKNOWN",
      "failure_count": number,
      "threshold": number,
      "cooldown_remaining_seconds": number | null,
      "probe_recommended": boolean,
      "missing_fields": ["string"] | null
    }
  ],
  "fallback_available": boolean,
  "summary": "A one-sentence operational summary of the overall breaker state."
}

## EXAMPLES
Input: {"breaker": "payment-api", "failure_count": 5, "threshold": 10, "cooldown_period_seconds": 60, "last_failure_timestamp": "2024-01-01T00:00:00Z"}
Output state: CLOSED

Input: {"breaker": "inventory-db", "failure_count": 12, "threshold": 10, "cooldown_period_seconds": 120, "last_failure_timestamp": "2024-01-01T00:00:30Z"}
Output state: OPEN (calculate remaining cooldown)

Input: {"breaker": "shipping-svc", "failure_count": 0, "threshold": 5, "cooldown_period_seconds": 30, "last_failure_timestamp": null}
Output state: HALF_OPEN (probe recommended)

To adapt this prompt, replace [BREAKER_METRICS] with a JSON object containing an array of breaker status objects collected from your metrics aggregator (e.g., Polly, Hystrix dashboard, or a custom collector). Ensure the timestamp fields are in ISO 8601 format for consistent parsing. The fallback_available field in the output schema should be populated by your application harness based on static configuration, not by the model, but including it in the schema ensures the model's output structure is ready for that value. If your system uses different state names or threshold logic, update the CONSTRAINTS and EXAMPLES sections accordingly before deploying.

IMPLEMENTATION TABLE

Prompt Variables

Required inputs for the Circuit Breaker State Verification Prompt. Each placeholder must be populated before the prompt is assembled and sent to the model. Validation notes describe how the harness should check each value before injection.

PlaceholderPurposeExampleValidation Notes

[SERVICE_NAME]

Identifies the downstream service whose circuit breaker state is being queried

payment-gateway-primary

Must match a known service registry entry; reject if not found in allowed service catalog

[BREAKER_ID]

Unique identifier for the specific circuit breaker instance protecting the service endpoint

cb-payments-v2-us-east

Must conform to naming convention regex; reject null or empty string

[FAILURE_THRESHOLD]

Maximum consecutive or rolling-window failure count before the breaker opens

5

Must be a positive integer; warn if value exceeds configured system maximum

[COOLDOWN_SECONDS]

Duration in seconds the breaker remains open before transitioning to half-open state

30

Must be a positive integer; reject values below minimum cooldown floor

[HALF_OPEN_LIMIT]

Maximum number of probe requests allowed in half-open state before re-opening

3

Must be a positive integer; reject if greater than configured system cap

[CURRENT_STATE_METRICS]

Live metrics payload containing failure count, last failure timestamp, and current breaker state

{"failures": 4, "last_failure_ts": 1716500000, "state": "closed"}

Must be valid JSON with required fields present; validate schema before injection; reject if timestamp is stale beyond configurable window

[FALLBACK_ENDPOINTS]

List of alternative endpoints or degraded-mode paths available if the breaker is open

["payments-fallback-west", "cache-only-mode"]

Must be a JSON array; allow empty array if no fallback exists; each entry must match known endpoint registry

[AGENT_ACTION_PLANNED]

Description of the agent action that requires the downstream service call

charge_customer with amount 49.99 and payment_method_id pm_123

Must be a non-empty string; reject if action type is not in allowed action catalog for this service

PROMPT PLAYBOOK

Implementation Harness Notes

How to wire the circuit breaker state verification prompt into an agent's pre-execution guard loop.

The Circuit Breaker State Verification Prompt is not a standalone utility; it is a precondition gate that must be wired into the agent's execution harness before any downstream service call is attempted. The harness should invoke this prompt as part of a PreFlightCheck sequence, passing the target service name, the breaker's current state snapshot (from your resilience library, e.g., Polly, resilience4j, or a custom state store), and the planned action's criticality. The model's structured output—a breaker state summary with failure counts, cooldown status, and fallback availability—is then parsed by the harness to make a binary decision: proceed, wait, or fallback. Do not rely on the model's recommendation alone; the harness must enforce the decision programmatically to prevent a hallucinated "proceed" from bypassing an actually open breaker.

To integrate this into a production agent, implement a validation layer that parses the model's JSON output and cross-references it against the authoritative breaker state from your infrastructure. For example, if the model reports "state": "closed" but your circuit breaker library reports IsOpen == true, the harness must discard the model's output, log a STATE_MISMATCH error, and default to the safe path (abort or fallback). The harness should also enforce a retry policy with backoff for half-open probing: if the model recommends a probe, the harness issues a single trial request with a tight timeout, and on failure, immediately re-opens the breaker and increments the failure count. Log every decision—breaker state input, model output, harness override, and final action—into a structured audit trail for post-incident review. For high-risk services (payments, PII access, destructive operations), require a human approval step before the harness executes a fallback that could degrade the user experience or skip a critical step.

When wiring this into an agent framework like LangChain, CrewAI, or a custom orchestrator, treat the prompt as a tool with a required pre-check contract. The tool's function signature should accept service_name, breaker_state_snapshot, and action_criticality, and return a typed BreakerDecision object. The orchestrator's planning loop should call this tool before every gated action, not just at the start of the plan, because breaker states can change mid-execution. Avoid the common mistake of caching the breaker decision for the entire agent run; instead, re-verify before each distinct downstream call. If the model's output fails schema validation after a configurable number of retries, the harness must escalate to the on-call channel and halt the agent to prevent silent failures in production.

IMPLEMENTATION TABLE

Expected Output Contract

Define the exact structure, types, and validation rules for the circuit breaker state verification output. Use this contract to build a parser that rejects malformed responses before the agent acts on breaker state.

Field or ElementType or FormatRequiredValidation Rule

breaker_name

string

Must match a known breaker identifier from the provided [BREAKER_REGISTRY] list. Reject if unknown.

current_state

enum: CLOSED | OPEN | HALF_OPEN

Must be one of the three allowed enum values. Reject any other string or null.

failure_count

integer >= 0

Must be a non-negative integer. If state is CLOSED and failure_count > 0, flag as anomaly for operator review.

failure_threshold

integer >= 1

Must be a positive integer. If failure_count >= failure_threshold and state is CLOSED, flag as inconsistent state.

cooldown_seconds_remaining

integer >= 0 | null

Required when state is OPEN. Must be null when state is CLOSED. If HALF_OPEN, value must be 0.

last_failure_timestamp

ISO 8601 string | null

Must be valid ISO 8601 if present. Required when failure_count > 0. Null allowed only when failure_count is 0.

fallback_available

boolean

Must be true or false. If true, [FALLBACK_STRATEGY] field must also be present and non-null in the response.

recommended_action

enum: PROCEED | FALLBACK | WAIT | ABORT

Must be one of the four allowed actions. If PROCEED and state is OPEN, reject as unsafe recommendation.

PRACTICAL GUARDRAILS

Common Failure Modes

Circuit breaker verification prompts fail in predictable ways when state data is stale, half-open probing is mishandled, or fallback paths are untested. These cards cover the most common production failure patterns and how to guard against them.

01

Stale Breaker State

What to watch: The prompt reports breaker state from cached or outdated metrics, causing the agent to proceed with calls to a service that has since tripped open. Guardrail: Require a freshness timestamp on all breaker state inputs and reject state older than the configured evaluation window. Add a harness-level check that compares the reported state timestamp against the current time before allowing the agent to act on it.

02

Half-Open Probing Without Backoff

What to watch: The prompt recommends a half-open probe but fails to specify a maximum probe count or backoff strategy, leading to thundering-herd retries that keep the downstream service degraded. Guardrail: Include explicit constraints in the prompt template for max concurrent probes, probe interval, and a hard limit on total probe attempts before forcing fallback. Validate these constraints in eval suites with simulated half-open scenarios.

03

Fallback Path Not Verified

What to watch: The prompt correctly identifies an open breaker and recommends a fallback, but the fallback itself is unavailable or has its own breaker tripped, causing cascading failures. Guardrail: Extend the prompt to require a recursive breaker check on the fallback path before recommending it. Include a harness rule that if the fallback breaker is also open, the agent must escalate rather than attempt the call.

04

Failure Count Threshold Misinterpretation

What to watch: The prompt misinterprets failure count semantics—treating consecutive failures as total failures, or ignoring the reset window—producing an incorrect open/closed recommendation. Guardrail: Explicitly define failure count semantics in the prompt's [CONSTRAINTS] block: consecutive vs. sliding-window, reset interval, and minimum request volume before tripping. Add eval cases that test boundary conditions just below and above the threshold.

05

Silent Success on Missing Inputs

What to watch: The prompt produces a breaker state summary even when required inputs—such as failure counts or cooldown timestamps—are missing or null, defaulting to 'closed' without warning. Guardrail: Add a precondition check in the prompt that requires all mandatory fields to be present and non-null before producing a recommendation. If inputs are incomplete, the output must be a structured 'insufficient data' response with missing fields enumerated.

06

Cooldown Window Race Condition

What to watch: The prompt evaluates breaker state at time T, but by the time the agent acts at T+N, the cooldown has expired and the breaker has transitioned, invalidating the original recommendation. Guardrail: Include a 'valid-until' timestamp in the prompt output schema. The harness must check this timestamp before executing the action and re-evaluate if it has expired. For short cooldown windows, reduce the evaluation-to-action latency budget.

IMPLEMENTATION TABLE

Evaluation Rubric

Use this rubric to test the Circuit Breaker State Verification Prompt before production deployment. Each criterion targets a specific failure mode observed in resilience-checking prompts.

CriterionPass StandardFailure SignalTest Method

Breaker state classification accuracy

Correctly identifies open, closed, or half-open state for each named breaker in [BREAKER_LIST]

Misclassifies a closed breaker as open, causing unnecessary fallback activation

Run against 20 known breaker state snapshots with ground-truth labels; require 100% accuracy on closed vs. open distinction

Failure count and threshold reporting

Reports current failure count and configured threshold for each breaker when available in [BREAKER_METRICS]

Omits failure count, reports stale values, or confuses count with threshold

Parse output fields failure_count and threshold per breaker; assert both are integers and failure_count <= threshold when state is closed

Cooldown timer accuracy

Reports remaining cooldown seconds when breaker is open, derived from last-failure timestamp and cooldown duration in [BREAKER_CONFIG]

Reports negative cooldown, omits cooldown for open breakers, or reports cooldown for closed breakers

Inject timestamps with known offsets; assert cooldown_remaining_seconds >= 0 for open breakers and null for closed breakers

Half-open probe recommendation

When state is half-open, output includes probe_allowed: true and recommended_probe_timeout_ms from [BREAKER_CONFIG]

Recommends probe when breaker is open, omits probe recommendation for half-open, or suggests probe without timeout

Test with half-open fixture; assert probe_allowed is true and recommended_probe_timeout_ms is a positive integer

Fallback availability assessment

For each open breaker, reports whether a fallback is configured and its degradation mode from [FALLBACK_MAP]

Claims fallback exists when none is configured, or marks fallback as unavailable when it is present

Provide [FALLBACK_MAP] with known entries; assert fallback_available matches map presence and degradation_mode matches configured value

Graceful degradation path enumeration

Lists at least one actionable degradation path per open breaker when fallback is unavailable, drawn from [DEGRADATION_PATHS]

Returns empty degradation list for open breakers, suggests paths that require the broken dependency, or hallucinates unavailable services

Supply [DEGRADATION_PATHS] with 3 known paths; assert output paths are a subset of provided paths and non-empty when fallback_available is false

Go/no-go summary correctness

Outputs overall_go: false when any breaker in [CRITICAL_BREAKERS] is open; outputs overall_go: true only when all critical breakers are closed or have confirmed fallbacks

Returns overall_go: true when a critical breaker is open without fallback, or false when all critical paths are healthy

Test with 10 scenarios mixing critical and non-critical breaker states; require 100% accuracy on overall_go against expected decision table

Schema compliance and field completeness

Output matches [OUTPUT_SCHEMA] exactly: all required fields present, no extra top-level keys, correct types per field

Missing breaker_id, null state for known breaker, extra fields leaking internal config, or string where integer expected

Validate output against JSON Schema; assert no missing required fields, no additional properties, and type conformance for all fields

ADAPTATION OPTIONS

Adapt This Prompt

How to adapt

Add strict JSON schema validation in your harness, not just in the prompt. Wrap the model call with a retry loop that catches schema mismatches. Add structured logging for every breaker state check including timestamp, model version, and raw response. Use the [OUTPUT_SCHEMA] placeholder to enforce exact field types and enums. Add an eval suite with known breaker states to catch regression.

Watch for

  • Silent format drift when model versions change
  • The model reporting stale state because it doesn't have access to real-time metrics
  • Missing human review escalation when a breaker is unexpectedly open in production
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.