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.0,<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.5.tar.gz (35.5 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.5-cp311-abi3-win_amd64.whl (202.5 kB view details)

Uploaded CPython 3.11+Windows x86-64

cpex_retry_with_backoff-0.3.5-cp311-abi3-manylinux_2_34_x86_64.whl (285.5 kB view details)

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

cpex_retry_with_backoff-0.3.5-cp311-abi3-manylinux_2_34_s390x.whl (313.2 kB view details)

Uploaded CPython 3.11+manylinux: glibc 2.34+ s390x

cpex_retry_with_backoff-0.3.5-cp311-abi3-manylinux_2_34_ppc64le.whl (311.6 kB view details)

Uploaded CPython 3.11+manylinux: glibc 2.34+ ppc64le

cpex_retry_with_backoff-0.3.5-cp311-abi3-manylinux_2_34_aarch64.whl (270.1 kB view details)

Uploaded CPython 3.11+manylinux: glibc 2.34+ ARM64

cpex_retry_with_backoff-0.3.5-cp311-abi3-macosx_11_0_arm64.whl (258.4 kB view details)

Uploaded CPython 3.11+macOS 11.0+ ARM64

File details

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

File metadata

  • Download URL: cpex_retry_with_backoff-0.3.5.tar.gz
  • Upload date:
  • Size: 35.5 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.5.tar.gz
Algorithm Hash digest
SHA256 c1f93793bf2ce3325d16ea47a85bb158d4be02994bb551d7d3ae6ed86fd8d7fe
MD5 ce8584d3062cf715d89ea60048e8ab9f
BLAKE2b-256 aa2d6605280cce64353b53ffd4b2ca059e3c012d9e197c1625f4334a5bd5e42d

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for cpex_retry_with_backoff-0.3.5-cp311-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 4a2bf888db7537c77c7c794db0570068aec9e18f0ffdb2c515cb0cba6ea39eb1
MD5 924aa8c2babd4fe8f2d23065800f6f41
BLAKE2b-256 eeaf58b0d02a04ed1f86cf21601cb74ab0fd6332f9e6cf529174187f23856ac7

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for cpex_retry_with_backoff-0.3.5-cp311-abi3-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 828d84e7ff818362b845387f23248affb29f2e0769897b4685d4cb8f646935a8
MD5 90edbbac76047214b8abed43c7c12c97
BLAKE2b-256 a6e028a431d9f8c31fc3411d536b588583af259051bfdbcd2bb8f3ce988de2b9

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for cpex_retry_with_backoff-0.3.5-cp311-abi3-manylinux_2_34_s390x.whl
Algorithm Hash digest
SHA256 d3beb8e5a422e878a41442c10aab72e30c32afaf0b03b5d44469f4a38a908810
MD5 36cb9da8f86dbee91053d6deb4c90cd2
BLAKE2b-256 8667f3eab9c21c4a271e692db35b6ca58d9ed1e02787f16464e30eedf0d77d42

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for cpex_retry_with_backoff-0.3.5-cp311-abi3-manylinux_2_34_ppc64le.whl
Algorithm Hash digest
SHA256 96f04dc855dc41c66bc1578f80dfe4a09584b3085ea0940349ad38f848f976f9
MD5 a4b82232a07d527f473e07cff45c875d
BLAKE2b-256 7183a8bc08387585a5345598a183f44046b6438e4a56760989c6ce54b1fc358b

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for cpex_retry_with_backoff-0.3.5-cp311-abi3-manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 64d7cb2745bfe9bbbd1a546a4584b5e531a56b203c16766e2c48c508b4d8eec2
MD5 12dae38439765023a9dc0404d7bff0e5
BLAKE2b-256 ae5ffaee33086dec07f7ef02e0cff705d65f186e07aa748aee535cfa1a70ef65

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for cpex_retry_with_backoff-0.3.5-cp311-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 84ecff35ddb1c7f5af1b13d8743894c4976d24b3772de282d5af9b63ecc51e91
MD5 ba8a9cb5a66962bb9a2cf443f2fd536c
BLAKE2b-256 0f089dcb125d99e1d87d5325d1f1d28b88e48afe2557d2db455972fe910e4021

See more details on using hashes here.

Provenance

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