Skip to main content

High-performance retry and backoff policy engine for MCP Gateway

Project description

Retry With Backoff (Rust)

High-performance retry and backoff policy engine for ContextForge and MCP Gateway.

Features

  • Rust-backed retry state tracking for tool invocations
  • Exponential backoff with optional jitter
  • Per-tool policy overrides without duplicating whole plugin configs
  • Retry decisions based on isError, structured status_code, or optional parsed text payloads
  • Automatic state eviction for stale request entries
  • Gateway ceiling enforcement for max_retries
  • Retry policy metadata returned on tool and resource hooks

Build

make install

Usage

The plugin runs on tool_post_invoke and resource_post_fetch.

Typical uses:

  • Retry transient upstream failures such as 429, 500, 502, 503, and 504
  • Clamp aggressive plugin settings to the gateway-wide retry ceiling
  • Apply stricter retry budgets to fragile or expensive tools

Configuration

Core settings

  • max_retries: maximum retry attempts before giving up
  • backoff_base_ms: base delay for exponential backoff
  • max_backoff_ms: upper bound for computed retry delays
  • retry_on_status: HTTP or structured status codes treated as retriable
  • jitter: randomize delay within the current exponential ceiling
  • check_text_content: inspect text content for JSON-encoded error payloads when structured content is absent

Per-tool overrides

Use tool_overrides to change retry behavior for a specific tool:

  • max_retries
  • backoff_base_ms
  • max_backoff_ms
  • retry_on_status
  • jitter

Behavior Notes

  • Successful responses clear retry state for the (tool, request_id) pair.
  • Retry state expires after a short TTL so abandoned request state does not accumulate indefinitely.
  • If check_text_content is disabled, the hot path uses the Rust state manager directly.
  • If check_text_content is enabled, the plugin falls back to Python-side payload inspection before applying retry policy.

Returned Metadata

Both tool and resource hooks emit retry policy metadata so downstream systems can observe the active policy:

  • max_retries
  • backoff_base_ms
  • max_backoff_ms
  • retry_on_status

Testing

# Full plugin CI
make ci

Performance

The retry state manager is implemented in Rust so the common retry decision path avoids Python bookkeeping overhead for normal structured tool results.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cpex_retry_with_backoff-0.2.1.tar.gz (41.2 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

cpex_retry_with_backoff-0.2.1-cp311-abi3-win_amd64.whl (192.2 kB view details)

Uploaded CPython 3.11+Windows x86-64

cpex_retry_with_backoff-0.2.1-cp311-abi3-manylinux_2_34_x86_64.whl (279.9 kB view details)

Uploaded CPython 3.11+manylinux: glibc 2.34+ x86-64

cpex_retry_with_backoff-0.2.1-cp311-abi3-manylinux_2_34_s390x.whl (320.8 kB view details)

Uploaded CPython 3.11+manylinux: glibc 2.34+ s390x

cpex_retry_with_backoff-0.2.1-cp311-abi3-manylinux_2_34_ppc64le.whl (311.0 kB view details)

Uploaded CPython 3.11+manylinux: glibc 2.34+ ppc64le

cpex_retry_with_backoff-0.2.1-cp311-abi3-manylinux_2_34_aarch64.whl (271.2 kB view details)

Uploaded CPython 3.11+manylinux: glibc 2.34+ ARM64

cpex_retry_with_backoff-0.2.1-cp311-abi3-macosx_11_0_arm64.whl (256.0 kB view details)

Uploaded CPython 3.11+macOS 11.0+ ARM64

File details

Details for the file cpex_retry_with_backoff-0.2.1.tar.gz.

File metadata

  • Download URL: cpex_retry_with_backoff-0.2.1.tar.gz
  • Upload date:
  • Size: 41.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for cpex_retry_with_backoff-0.2.1.tar.gz
Algorithm Hash digest
SHA256 f4649c65e2a48c3bbf1b1819ec6e8d23e97de911faa61017c8687f89492a4727
MD5 eaa354a1a24bf684464c6c7cec253179
BLAKE2b-256 3df8757a0f956deb12266f03d7622a7758c11981970424fbf66e50aca1ea11b5

See more details on using hashes here.

Provenance

The following attestation bundles were made for cpex_retry_with_backoff-0.2.1.tar.gz:

Publisher: release-rust-python-package.yaml on IBM/cpex-plugins

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cpex_retry_with_backoff-0.2.1-cp311-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for cpex_retry_with_backoff-0.2.1-cp311-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 67c0483a691ff6b41863e1be986534a0e1f40502d486283d3294bb0baea0b949
MD5 85e3563496bfeecca83f1a6edb9f0ebc
BLAKE2b-256 078510591e844a48a8869c88335dd6303ec992eb371e835e3ea1dc5fab4385ed

See more details on using hashes here.

Provenance

The following attestation bundles were made for cpex_retry_with_backoff-0.2.1-cp311-abi3-win_amd64.whl:

Publisher: release-rust-python-package.yaml on IBM/cpex-plugins

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cpex_retry_with_backoff-0.2.1-cp311-abi3-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for cpex_retry_with_backoff-0.2.1-cp311-abi3-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 139859b342d00273fd8db328d06f783780bf53f8e5bd46615108b837d61aa315
MD5 5c9c022c44eb5c8d0658f313fa3894e9
BLAKE2b-256 e41d76b6266c5c407677bc5c76270cb0d6162d1d8a093918cfa72b98b6a55cb5

See more details on using hashes here.

Provenance

The following attestation bundles were made for cpex_retry_with_backoff-0.2.1-cp311-abi3-manylinux_2_34_x86_64.whl:

Publisher: release-rust-python-package.yaml on IBM/cpex-plugins

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cpex_retry_with_backoff-0.2.1-cp311-abi3-manylinux_2_34_s390x.whl.

File metadata

File hashes

Hashes for cpex_retry_with_backoff-0.2.1-cp311-abi3-manylinux_2_34_s390x.whl
Algorithm Hash digest
SHA256 7c857fbee4b5c3e4d6dead46858137bb5fadb1fa6d452d3ad7cc94d2f92dc01a
MD5 8e5f0216612b01aa7a9d44005615d51b
BLAKE2b-256 d86bc1b8ece14480b8fe12e89757846aee91479111bad8a5d16ea71f99fd8313

See more details on using hashes here.

Provenance

The following attestation bundles were made for cpex_retry_with_backoff-0.2.1-cp311-abi3-manylinux_2_34_s390x.whl:

Publisher: release-rust-python-package.yaml on IBM/cpex-plugins

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cpex_retry_with_backoff-0.2.1-cp311-abi3-manylinux_2_34_ppc64le.whl.

File metadata

File hashes

Hashes for cpex_retry_with_backoff-0.2.1-cp311-abi3-manylinux_2_34_ppc64le.whl
Algorithm Hash digest
SHA256 b9deec17fde84dc1d0bef9b4141bc58801a7367f92d879558892996cdc706499
MD5 df4ecfa2919f28c9fd009681cf6e900a
BLAKE2b-256 8a3e68c7f11cbfb49820214ab434b47353afd0114d8996f8b906e198ee902a32

See more details on using hashes here.

Provenance

The following attestation bundles were made for cpex_retry_with_backoff-0.2.1-cp311-abi3-manylinux_2_34_ppc64le.whl:

Publisher: release-rust-python-package.yaml on IBM/cpex-plugins

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cpex_retry_with_backoff-0.2.1-cp311-abi3-manylinux_2_34_aarch64.whl.

File metadata

File hashes

Hashes for cpex_retry_with_backoff-0.2.1-cp311-abi3-manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 3e1637a0a10f3ede9d9ba63d0b5ca5540a3ddff6ce85b3747981c379862a9f09
MD5 6afe3949a0962aced95bcc97dc924baf
BLAKE2b-256 ba3b9a9fff60d34e4a811e9e49cbae58ef4505ef83e56fdfb857ebe85d62014e

See more details on using hashes here.

Provenance

The following attestation bundles were made for cpex_retry_with_backoff-0.2.1-cp311-abi3-manylinux_2_34_aarch64.whl:

Publisher: release-rust-python-package.yaml on IBM/cpex-plugins

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cpex_retry_with_backoff-0.2.1-cp311-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for cpex_retry_with_backoff-0.2.1-cp311-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4d0e4b18c3cf8cf9116325b80cf8b2dd1f8aa02d311577684554cb28b2a3f467
MD5 befde0a5fa288d14da66ace964d96dda
BLAKE2b-256 5dc225a41c9339aa78637858a7ad509689d040bdaaaad721ce76b900759c1ad4

See more details on using hashes here.

Provenance

The following attestation bundles were made for cpex_retry_with_backoff-0.2.1-cp311-abi3-macosx_11_0_arm64.whl:

Publisher: release-rust-python-package.yaml on IBM/cpex-plugins

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page