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.3.tar.gz (94.4 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.3-cp311-abi3-win_amd64.whl (232.5 kB view details)

Uploaded CPython 3.11+Windows x86-64

cpex_retry_with_backoff-0.3.3-cp311-abi3-manylinux_2_34_x86_64.whl (315.8 kB view details)

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

cpex_retry_with_backoff-0.3.3-cp311-abi3-manylinux_2_34_s390x.whl (351.3 kB view details)

Uploaded CPython 3.11+manylinux: glibc 2.34+ s390x

cpex_retry_with_backoff-0.3.3-cp311-abi3-manylinux_2_34_ppc64le.whl (342.4 kB view details)

Uploaded CPython 3.11+manylinux: glibc 2.34+ ppc64le

cpex_retry_with_backoff-0.3.3-cp311-abi3-manylinux_2_34_aarch64.whl (298.7 kB view details)

Uploaded CPython 3.11+manylinux: glibc 2.34+ ARM64

cpex_retry_with_backoff-0.3.3-cp311-abi3-macosx_11_0_arm64.whl (285.7 kB view details)

Uploaded CPython 3.11+macOS 11.0+ ARM64

File details

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

File metadata

  • Download URL: cpex_retry_with_backoff-0.3.3.tar.gz
  • Upload date:
  • Size: 94.4 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.3.tar.gz
Algorithm Hash digest
SHA256 346460612b44dbfe9a61f2ad1c92799ad5bec18af77099d745cd716ab9d18f13
MD5 b330ca5a58118fa5a21c14e465663ce9
BLAKE2b-256 c1917609cae8868bf205f335707ae2ab1318169b31365617f20a36a7ba3e87dc

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for cpex_retry_with_backoff-0.3.3-cp311-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 5e7499bf47d2cf1922f0299f33348e30e023cbb6fece1c30f780d6b3fe77c10e
MD5 ab39cf0f537d9ea43b373ea9f15109d2
BLAKE2b-256 745d8c3d533c88d6933e8a77ffeb526abda75c2cd98db436d820373d680481cf

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for cpex_retry_with_backoff-0.3.3-cp311-abi3-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 5a3149363e3e13dda860a6840ffb36f672e857666d624057080dfde8f4a227ca
MD5 87712b0bbbe7c3cb4c1582c9d6d77cb3
BLAKE2b-256 2da5c247feb06c26c790302334c44170201d3b53553798abc8058e4b4ceb5737

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for cpex_retry_with_backoff-0.3.3-cp311-abi3-manylinux_2_34_s390x.whl
Algorithm Hash digest
SHA256 5e6ef2330707d1ddc0cc1a6a3f1933126c0ee94577031e680eaaf23e976dcf68
MD5 716a56fdefc5b2651d894fd7e624e5c4
BLAKE2b-256 273e387e04418bc6bf3438fe21e805e4e765146aea15b72e75f151379a91b646

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for cpex_retry_with_backoff-0.3.3-cp311-abi3-manylinux_2_34_ppc64le.whl
Algorithm Hash digest
SHA256 01ae6de7bf747e16e85e0eb55433765b8559b8f6862447be46212c7038f01587
MD5 8d102d3ffe61a50575a8b1fc9b0e2d4e
BLAKE2b-256 9fbea8373712ba42c4510b3969272e968555032c3306a47b33f6c3e9e070122c

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for cpex_retry_with_backoff-0.3.3-cp311-abi3-manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 d6eb394044e07c198616284bec45927e35aa157926d9173504a22b087effcfa0
MD5 2c364604100f9bbb194572f432c8d082
BLAKE2b-256 8fa7e55a72873bed0461f5ca01a26e40f13dc434ab84697dc43caa25e3a86f56

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for cpex_retry_with_backoff-0.3.3-cp311-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 6fe227143c2f7ad6874477fb0715f66f83bbcabff06292d7d6731807e4a44897
MD5 2663306a4272f59f5af87f3fac08ce3d
BLAKE2b-256 effdae008202a8d9de0ad7b96fc8783d715e288b570016d6d3ee6d8b14ba651c

See more details on using hashes here.

Provenance

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