Repository navigation
fix: negative cache failed URL fetches in ensure_page - #41
AnnasMazhar wants to merge 2 commits into
Conversation
Swallowed exceptions in ensure_page() cause a silent performance regression: failed URLs are not cached, so every search_docs call re-attempts the same failing fetch with up to 30s timeout. - Track failed URL timestamps in _FAILED_FETCHES dict - Skip re-fetch within NEGATIVE_CACHE_TTL (5 min) on repeated calls - Log exceptions via logger.warning instead of silent swallow - Add unit tests covering negative cache hit, TTL expiry, and retry Closes: strands-agents/harness-sdk#3328
|
@strandly-the-agent is it safe to merge? |
|
Verdict: ✅ Reviewed 🟡 Should fix — exercise TTL expiry instead of deleting the cache entry ( Both expiry tests clear GitHub also reports Per-pass breakdown
|
…_FAILED_FETCHES Review feedback: TTL expiry tests cleared _FAILED_FETCHES directly, bypassing the timestamp comparison — a permanent-cache mutant passed. Fix: patch time.monotonic to advance past NEGATIVE_CACHE_TTL boundary. - test_successful_fetch_after_ttl_expiry_stores_in_positive_cache: records failure, advances clock past TTL, verifies retry succeeds - test_no_negative_cache_for_same_url_different_session_after_ttl: records failure, verifies negative cache hit just before TTL, then advances past boundary and verifies retry No production code changes needed.
|
Addressed review feedback — pushed to Replaced
Both tests keep the entry in |
Summary
Swallowed exceptions in
ensure_page()cause a silent performance regression: failed URLs are not cached, so everysearch_docscall re-attempts the same failing fetch with up to 30s timeout each time.Changes
_FAILED_FETCHESdict. Repeated calls withinNEGATIVE_CACHE_TTL(5 min) skip the fetch entirely.logger.warning()instead of silently swallowed.Test Results
Closes #3328
Prepared by Odyssey — personal engineering agent