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, structuredstatus_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, and504 - 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 upbackoff_base_ms: base delay for exponential backoffmax_backoff_ms: upper bound for computed retry delaysretry_on_status: HTTP or structured status codes treated as retriablejitter: randomize delay within the current exponential ceilingcheck_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_retriesbackoff_base_msmax_backoff_msretry_on_statusjitter
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_contentis disabled, the hot path uses the Rust state manager directly. - If
check_text_contentis 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_retriesbackoff_base_msmax_backoff_msretry_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
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b2ecce98d944c766084a6153b7ec51298f60336254b2224bd2664596cc47364c
|
|
| MD5 |
2adcc9565ec137a2a42bd58881db0acd
|
|
| BLAKE2b-256 |
e28a639a8548ca29df8a33f37a08f7494fa43ee13586ba56ca426398adc74728
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
cpex_retry_with_backoff-0.3.1.tar.gz -
Subject digest:
b2ecce98d944c766084a6153b7ec51298f60336254b2224bd2664596cc47364c - Sigstore transparency entry: 1473136897
- Sigstore integration time:
-
Permalink:
IBM/cpex-plugins@cfe70874c994740923fc2246f2682ba7b91046fd -
Branch / Tag:
refs/heads/main - Owner: https://github.com/IBM
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-rust-python-package.yaml@cfe70874c994740923fc2246f2682ba7b91046fd -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file cpex_retry_with_backoff-0.3.1-cp311-abi3-win_amd64.whl.
File metadata
- Download URL: cpex_retry_with_backoff-0.3.1-cp311-abi3-win_amd64.whl
- Upload date:
- Size: 191.6 kB
- Tags: CPython 3.11+, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
377f08e2c076ba462154518f4845d723c10d601737618b0328859b42f1a51cd1
|
|
| MD5 |
a3739f6074491004a5a4d373a878ee13
|
|
| BLAKE2b-256 |
da3b43122eebc57ce062c0df2dfb17f08f441b4b546c4eb1ec653f1495d49d53
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
cpex_retry_with_backoff-0.3.1-cp311-abi3-win_amd64.whl -
Subject digest:
377f08e2c076ba462154518f4845d723c10d601737618b0328859b42f1a51cd1 - Sigstore transparency entry: 1473137074
- Sigstore integration time:
-
Permalink:
IBM/cpex-plugins@cfe70874c994740923fc2246f2682ba7b91046fd -
Branch / Tag:
refs/heads/main - Owner: https://github.com/IBM
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-rust-python-package.yaml@cfe70874c994740923fc2246f2682ba7b91046fd -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file cpex_retry_with_backoff-0.3.1-cp311-abi3-manylinux_2_34_x86_64.whl.
File metadata
- Download URL: cpex_retry_with_backoff-0.3.1-cp311-abi3-manylinux_2_34_x86_64.whl
- Upload date:
- Size: 280.0 kB
- Tags: CPython 3.11+, manylinux: glibc 2.34+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
670fc43949cc3187e72f8d22e9ef2b7089e81455cdd28c6fe274a57fb4f93610
|
|
| MD5 |
66bf422d1caba8020ce673fc5a72649f
|
|
| BLAKE2b-256 |
04226f090ef8694fd3b21108c5b1ddb5a49273712289d6c8f56f42fbca5f88b3
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
cpex_retry_with_backoff-0.3.1-cp311-abi3-manylinux_2_34_x86_64.whl -
Subject digest:
670fc43949cc3187e72f8d22e9ef2b7089e81455cdd28c6fe274a57fb4f93610 - Sigstore transparency entry: 1473136972
- Sigstore integration time:
-
Permalink:
IBM/cpex-plugins@cfe70874c994740923fc2246f2682ba7b91046fd -
Branch / Tag:
refs/heads/main - Owner: https://github.com/IBM
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-rust-python-package.yaml@cfe70874c994740923fc2246f2682ba7b91046fd -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file cpex_retry_with_backoff-0.3.1-cp311-abi3-manylinux_2_34_s390x.whl.
File metadata
- Download URL: cpex_retry_with_backoff-0.3.1-cp311-abi3-manylinux_2_34_s390x.whl
- Upload date:
- Size: 320.9 kB
- Tags: CPython 3.11+, manylinux: glibc 2.34+ s390x
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2fc0166929b7a8658ef256559119a2af3612a8d36d522bd822310a0f3c8cf4ee
|
|
| MD5 |
4781b2017f9047564e075986a9f1828c
|
|
| BLAKE2b-256 |
7a2554075570705ce228306da3ec4771e9f6b114b8baccba8896811813781328
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
cpex_retry_with_backoff-0.3.1-cp311-abi3-manylinux_2_34_s390x.whl -
Subject digest:
2fc0166929b7a8658ef256559119a2af3612a8d36d522bd822310a0f3c8cf4ee - Sigstore transparency entry: 1473137173
- Sigstore integration time:
-
Permalink:
IBM/cpex-plugins@cfe70874c994740923fc2246f2682ba7b91046fd -
Branch / Tag:
refs/heads/main - Owner: https://github.com/IBM
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-rust-python-package.yaml@cfe70874c994740923fc2246f2682ba7b91046fd -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file cpex_retry_with_backoff-0.3.1-cp311-abi3-manylinux_2_34_ppc64le.whl.
File metadata
- Download URL: cpex_retry_with_backoff-0.3.1-cp311-abi3-manylinux_2_34_ppc64le.whl
- Upload date:
- Size: 311.1 kB
- Tags: CPython 3.11+, manylinux: glibc 2.34+ ppc64le
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
71b573b25f1d4b3bf2fa29198cef634acfeb52ac147f78c647e23430226bd754
|
|
| MD5 |
ac18b6d28be807ebe28e6022a41efaf5
|
|
| BLAKE2b-256 |
1d4a1993c9d08e5b9ace7476dd3cc6fef7fc2f49c09ba720f445a33d6a5c8bea
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
cpex_retry_with_backoff-0.3.1-cp311-abi3-manylinux_2_34_ppc64le.whl -
Subject digest:
71b573b25f1d4b3bf2fa29198cef634acfeb52ac147f78c647e23430226bd754 - Sigstore transparency entry: 1473137282
- Sigstore integration time:
-
Permalink:
IBM/cpex-plugins@cfe70874c994740923fc2246f2682ba7b91046fd -
Branch / Tag:
refs/heads/main - Owner: https://github.com/IBM
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-rust-python-package.yaml@cfe70874c994740923fc2246f2682ba7b91046fd -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file cpex_retry_with_backoff-0.3.1-cp311-abi3-manylinux_2_34_aarch64.whl.
File metadata
- Download URL: cpex_retry_with_backoff-0.3.1-cp311-abi3-manylinux_2_34_aarch64.whl
- Upload date:
- Size: 271.3 kB
- Tags: CPython 3.11+, manylinux: glibc 2.34+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
41b008b966de5f5bd3cb2eac40293eba4f6e937e67bd029af731734a7df9da9d
|
|
| MD5 |
41e61e71864a6f7676bed0d0d17f342d
|
|
| BLAKE2b-256 |
1dff193127f68fa0fac3c004c4632bd1a74fec7314a86ab660d6b9b59b546175
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
cpex_retry_with_backoff-0.3.1-cp311-abi3-manylinux_2_34_aarch64.whl -
Subject digest:
41b008b966de5f5bd3cb2eac40293eba4f6e937e67bd029af731734a7df9da9d - Sigstore transparency entry: 1473137229
- Sigstore integration time:
-
Permalink:
IBM/cpex-plugins@cfe70874c994740923fc2246f2682ba7b91046fd -
Branch / Tag:
refs/heads/main - Owner: https://github.com/IBM
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-rust-python-package.yaml@cfe70874c994740923fc2246f2682ba7b91046fd -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file cpex_retry_with_backoff-0.3.1-cp311-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: cpex_retry_with_backoff-0.3.1-cp311-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 255.7 kB
- Tags: CPython 3.11+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
405a5e9868eaadbb86938f582d6847c32bb441dff3980753f87a1987869f0416
|
|
| MD5 |
258924c7eed871d6d559f90bfd0c69c2
|
|
| BLAKE2b-256 |
d8ecd8cae2a9ff167d27cfacb280c5029f9528ae62431d9e1a0605237058ab62
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
cpex_retry_with_backoff-0.3.1-cp311-abi3-macosx_11_0_arm64.whl -
Subject digest:
405a5e9868eaadbb86938f582d6847c32bb441dff3980753f87a1987869f0416 - Sigstore transparency entry: 1473137010
- Sigstore integration time:
-
Permalink:
IBM/cpex-plugins@cfe70874c994740923fc2246f2682ba7b91046fd -
Branch / Tag:
refs/heads/main - Owner: https://github.com/IBM
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-rust-python-package.yaml@cfe70874c994740923fc2246f2682ba7b91046fd -
Trigger Event:
workflow_dispatch
-
Statement type: