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

Runtime Requirements

This plugin depends on cpex>=0.1.0rc1,<0.2 and imports hook models from cpex.framework. The compiled Rust extension is mandatory; there is no Python fallback implementation.

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, Python-side payload inspection supplements the Rust state manager 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.3.1.tar.gz (87.0 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.3.1-cp311-abi3-win_amd64.whl (191.6 kB view details)

Uploaded CPython 3.11+Windows x86-64

cpex_retry_with_backoff-0.3.1-cp311-abi3-manylinux_2_34_x86_64.whl (280.0 kB view details)

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

cpex_retry_with_backoff-0.3.1-cp311-abi3-manylinux_2_34_s390x.whl (320.9 kB view details)

Uploaded CPython 3.11+manylinux: glibc 2.34+ s390x

cpex_retry_with_backoff-0.3.1-cp311-abi3-manylinux_2_34_ppc64le.whl (311.1 kB view details)

Uploaded CPython 3.11+manylinux: glibc 2.34+ ppc64le

cpex_retry_with_backoff-0.3.1-cp311-abi3-manylinux_2_34_aarch64.whl (271.3 kB view details)

Uploaded CPython 3.11+manylinux: glibc 2.34+ ARM64

cpex_retry_with_backoff-0.3.1-cp311-abi3-macosx_11_0_arm64.whl (255.7 kB view details)

Uploaded CPython 3.11+macOS 11.0+ ARM64

File details

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

File metadata

  • Download URL: cpex_retry_with_backoff-0.3.1.tar.gz
  • Upload date:
  • Size: 87.0 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.3.1.tar.gz
Algorithm Hash digest
SHA256 b2ecce98d944c766084a6153b7ec51298f60336254b2224bd2664596cc47364c
MD5 2adcc9565ec137a2a42bd58881db0acd
BLAKE2b-256 e28a639a8548ca29df8a33f37a08f7494fa43ee13586ba56ca426398adc74728

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for cpex_retry_with_backoff-0.3.1-cp311-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 377f08e2c076ba462154518f4845d723c10d601737618b0328859b42f1a51cd1
MD5 a3739f6074491004a5a4d373a878ee13
BLAKE2b-256 da3b43122eebc57ce062c0df2dfb17f08f441b4b546c4eb1ec653f1495d49d53

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for cpex_retry_with_backoff-0.3.1-cp311-abi3-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 670fc43949cc3187e72f8d22e9ef2b7089e81455cdd28c6fe274a57fb4f93610
MD5 66bf422d1caba8020ce673fc5a72649f
BLAKE2b-256 04226f090ef8694fd3b21108c5b1ddb5a49273712289d6c8f56f42fbca5f88b3

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for cpex_retry_with_backoff-0.3.1-cp311-abi3-manylinux_2_34_s390x.whl
Algorithm Hash digest
SHA256 2fc0166929b7a8658ef256559119a2af3612a8d36d522bd822310a0f3c8cf4ee
MD5 4781b2017f9047564e075986a9f1828c
BLAKE2b-256 7a2554075570705ce228306da3ec4771e9f6b114b8baccba8896811813781328

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for cpex_retry_with_backoff-0.3.1-cp311-abi3-manylinux_2_34_ppc64le.whl
Algorithm Hash digest
SHA256 71b573b25f1d4b3bf2fa29198cef634acfeb52ac147f78c647e23430226bd754
MD5 ac18b6d28be807ebe28e6022a41efaf5
BLAKE2b-256 1d4a1993c9d08e5b9ace7476dd3cc6fef7fc2f49c09ba720f445a33d6a5c8bea

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for cpex_retry_with_backoff-0.3.1-cp311-abi3-manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 41b008b966de5f5bd3cb2eac40293eba4f6e937e67bd029af731734a7df9da9d
MD5 41e61e71864a6f7676bed0d0d17f342d
BLAKE2b-256 1dff193127f68fa0fac3c004c4632bd1a74fec7314a86ab660d6b9b59b546175

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for cpex_retry_with_backoff-0.3.1-cp311-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 405a5e9868eaadbb86938f582d6847c32bb441dff3980753f87a1987869f0416
MD5 258924c7eed871d6d559f90bfd0c69c2
BLAKE2b-256 d8ecd8cae2a9ff167d27cfacb280c5029f9528ae62431d9e1a0605237058ab62

See more details on using hashes here.

Provenance

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