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.0.tar.gz (40.6 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.0-cp311-abi3-win_amd64.whl (191.5 kB view details)

Uploaded CPython 3.11+Windows x86-64

cpex_retry_with_backoff-0.2.0-cp311-abi3-manylinux_2_34_x86_64.whl (279.5 kB view details)

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

cpex_retry_with_backoff-0.2.0-cp311-abi3-manylinux_2_34_s390x.whl (319.8 kB view details)

Uploaded CPython 3.11+manylinux: glibc 2.34+ s390x

cpex_retry_with_backoff-0.2.0-cp311-abi3-manylinux_2_34_ppc64le.whl (310.1 kB view details)

Uploaded CPython 3.11+manylinux: glibc 2.34+ ppc64le

cpex_retry_with_backoff-0.2.0-cp311-abi3-manylinux_2_34_aarch64.whl (270.4 kB view details)

Uploaded CPython 3.11+manylinux: glibc 2.34+ ARM64

cpex_retry_with_backoff-0.2.0-cp311-abi3-macosx_11_0_arm64.whl (255.3 kB view details)

Uploaded CPython 3.11+macOS 11.0+ ARM64

File details

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

File metadata

  • Download URL: cpex_retry_with_backoff-0.2.0.tar.gz
  • Upload date:
  • Size: 40.6 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.0.tar.gz
Algorithm Hash digest
SHA256 b574b38f046a9adfb78771ab6457befd8389ba8b00f0e1b6025ffc9bba159b8a
MD5 5d7f1ccaa5758fbba5c79862b449e73b
BLAKE2b-256 50f8297311418b4c602e439db3dd5f2ec1aac6c0ec644236c3a225011617738d

See more details on using hashes here.

Provenance

The following attestation bundles were made for cpex_retry_with_backoff-0.2.0.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.0-cp311-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for cpex_retry_with_backoff-0.2.0-cp311-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 7e50df56658ca887c0c8ba56b2c84924512cbe50efa5610220cdc2a0a213c4a0
MD5 7dac27bbb4569d32e4b9d725d415107c
BLAKE2b-256 7882085ccc65f16728f7b2f01284066c011344116794af17515d47309e5e0ef1

See more details on using hashes here.

Provenance

The following attestation bundles were made for cpex_retry_with_backoff-0.2.0-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.0-cp311-abi3-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for cpex_retry_with_backoff-0.2.0-cp311-abi3-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 60a6873242a83b231e93e765daf9335ef4081616f35b65d07e39c89e603682e3
MD5 defab592a56df1e82ddc2634850f8b98
BLAKE2b-256 44eb78fdb874c5d41f0e1282a0a618d793ef672a219ccb5c9349199eae0b7c32

See more details on using hashes here.

Provenance

The following attestation bundles were made for cpex_retry_with_backoff-0.2.0-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.0-cp311-abi3-manylinux_2_34_s390x.whl.

File metadata

File hashes

Hashes for cpex_retry_with_backoff-0.2.0-cp311-abi3-manylinux_2_34_s390x.whl
Algorithm Hash digest
SHA256 c8cfdf9bf501e57d0991c4d1425a28bf17315854eb1baafe5bb4b1e6dea4a6de
MD5 55a0153d2eefad859f00b3388ebcdffc
BLAKE2b-256 a0079132c2ed62300f81beba272171d420b7c7a032a8c2e27e099b4ba48d46a2

See more details on using hashes here.

Provenance

The following attestation bundles were made for cpex_retry_with_backoff-0.2.0-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.0-cp311-abi3-manylinux_2_34_ppc64le.whl.

File metadata

File hashes

Hashes for cpex_retry_with_backoff-0.2.0-cp311-abi3-manylinux_2_34_ppc64le.whl
Algorithm Hash digest
SHA256 501066a091e4be4feb86b06f604e9ff5bfbcae26ad9a7520e9ae731cb7ada860
MD5 9f439da3b6e511fb137bde2521a94c2b
BLAKE2b-256 821a99b3760c82fa72cc8e83e7310a8c90a3a8360c67373f7f99fbed41185042

See more details on using hashes here.

Provenance

The following attestation bundles were made for cpex_retry_with_backoff-0.2.0-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.0-cp311-abi3-manylinux_2_34_aarch64.whl.

File metadata

File hashes

Hashes for cpex_retry_with_backoff-0.2.0-cp311-abi3-manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 2e8fecba4c3640df47ba2d7d15a6e77fb78c9d1ed4959c1d393557b6db9d0cbc
MD5 18afec347874494bcfd4fcec4310d5ed
BLAKE2b-256 ecd6377a6d9a4c8399a3fbeca89262d41e9af8b9cb7657a69945003011c4fc33

See more details on using hashes here.

Provenance

The following attestation bundles were made for cpex_retry_with_backoff-0.2.0-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.0-cp311-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for cpex_retry_with_backoff-0.2.0-cp311-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 04baed7d7d95a4a9868274a11697f7505ede7fe92f46568fce5b05d02ce71cde
MD5 cd3ec5276b20a203889f10e6ac3bb4a1
BLAKE2b-256 29aa6a64a31a5192caa838aa94a81e1da128609b6d0eb48c028cc85b877fa9ed

See more details on using hashes here.

Provenance

The following attestation bundles were made for cpex_retry_with_backoff-0.2.0-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