reliable

v0.1.5
io.github.GravityWell8/reliable Checked 4 days ago Published 9 days ago

Resilient LLM/Agent calls via MCP: circuit breakers, timeout, jitter backoff, retry-storm guard.

These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.

create_breaker

Register or replace a named circuit breaker. Use one breaker per downstream dependency (e.g. one per LLM provider). The breaker lives in the server process for its lifetime. Args: name: unique breaker id, e.g. "openai", "local-llm". failure_rate: trip when the sliding-window failure rate >= this (0..1). window: number of recent calls in the sliding window. cooldown: seconds the breaker stays OPEN before probing. probe: consecutive HALF_OPEN successes required to close. Example: create_breaker("openai", failure_rate=0.5, window=…

ParameterTypeDescription
name *string
cooldownnumber
failure_ratenumber
probeinteger
windowinteger

get_breaker_state

Return the current state and stats of a named breaker. Args: name: breaker id previously created with create_breaker. Returns state (closed/open/half_open), failure-rate threshold, window stats, cooldown and probe config. Example: get_breaker_state("openai") -> {"name": "openai", "state": "open", "window_failure_rate": 0.8, "window_total": 20, "window_failures": 16, "opened_at": 1731000000.0, ...} get_breaker_state("nope") -> {"name": "nope", "error": "unknown breaker: nope"}

ParameterTypeDescription
name *string

compute_backoff

Compute the exponential backoff delay for a retry attempt (pure). No side effects — handy to preview retry pacing before committing config. Args: attempt: 1-based retry index. base_delay: initial delay in seconds. factor: growth multiplier per attempt. jitter: +/- fraction of randomness (0 disables it). Example: compute_backoff(3, base_delay=0.2, factor=2.0, jitter=0.0) -> {"attempt": 3, "delay": 0.8} compute_backoff(5, base_delay=0.5, factor=2.0, jitter=0.0) -> {"attempt": 5, "delay": 8.0}

ParameterTypeDescription
attempt *integer
base_delaynumber
factornumber
jitternumber

reliable_http_call

Call an HTTP endpoint through a named circuit breaker. The breaker is auto-created with default config if the name is new. On breaker OPEN the call short-circuits and returns `fallback` (or an error) instead of hammering the downstream — that is the retry-storm guard this library exists for. Args: breaker: breaker id (auto-created if absent). url: target URL. method: HTTP method (default POST). headers: JSON string of request headers. body: request body as string/JSON. timeout: per-attempt timeout in seconds. max_a…

ParameterTypeDescription
breaker *string
url *string
base_delaynumber
body
factornumber
fallback
headers
jitternumber
max_attemptsinteger
methodstring
timeoutnumber