feat(tools): NVD rate-limit resilience — retry/back-off + NVD_API_KEY support#91
Merged
Merged
Conversation
This was referenced Jul 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
NVD's public API enforces a rate limit of 5 requests per 30 seconds for
unauthenticated callers. Before this PR a single 429 or transient server
error was fatal — the tool returned an error immediately with no retry.
This PR adds production-grade resilience to
get_nvd_data(the most-calledtool in every
manus-agent analyzepipeline) and toobtain_cves(whichalso paginating-polls the same NVD endpoint):
Changes
src/manus_agent/tools/get_nvd_data.py_build_nvd_headers()NVD_API_KEYenv var asapiKeyheader when set; returns empty dict otherwise. Key is never logged._nvd_get_with_retry(url)NVD_MAX_RETRIES(default 3) retries with exponential back-off (NVD_RETRY_BASE_DELAY * 2^n, default 2 s / 4 s / 8 s) on HTTP 429, 500, 502, 503, 504. Non-retryable 4xx errors fail immediately. Connection/timeout errors are also retried. All constants are env-var-overridable for testing (setNVD_RETRY_BASE_DELAY=0).get_nvd_data()_nvd_get_with_retry()instead of barerequests.get().src/manus_agent/tools/obtain_cves.py_get_all_cves_from_nvd()(the pagination loop that calls the same NVDendpoint) now imports and uses
_nvd_get_with_retryfor the same resiliencebenefit, replacing the bare
requests.get+raise_for_status()combo.tests/test_nvd_retry.py— 37 new tests (902 → 939)TestBuildNvdHeadersapiKeyheader, blank/whitespace not injectedTestNvdGetWithRetryTestGetNvdDataToolTestObtainCvesNvdRetryTestRetryableStatusSetTestModuleConstantsAll tests 100% mocked — no real HTTP calls.
Back-off schedule
Optional API key
Test run
Open PRs checked for overlap (none duplicate this work)
#51, #53, #54, #58, #60, #64, #65, #67, #74, #75, #76, #77, #78, #79,
#80, #82, #83, #85, #86, #87, #88, #89, #90 — none cover NVD retry/backoff
or
NVD_API_KEYsupport.