AI agent skill that researches any topic across Reddit, X, YouTube, HN, Polymarket, and the web - then synthesizes a grounded summary
Fix Amazon Review Budget by Starting at Search Time
Date: 2026-08-14
Status: Implemented
Problem (measured 2026-08-14 Bentgo run)
- Full multi-source run. Amazon search listings returned (12 products, stars, rating counts).
- Review lane logged: "pulling up to 50 reviews for 3 products (budget 11s)"
- "lane deadline 11s hit; dropped 3 straggling pull(s)"
- Bright Data timed out after 11s x3. Zero review bodies. Credits spent.
- Isolated Amazon-only re-run got the full 180s, finished in 124s, reviews landed.
- Cause:
_remaining_lane_budget= min(LANE_DEADLINE=180, max(0, FOREGROUND_CONTRACT=300 - elapsed - RENDER_MARGIN=20)). Enrichment runs after all other sources. Elapsed ~269s → 11s.
Why the floor-up fix was wrong
max(120, leftover) at elapsed=269 means the run goes to ~389–449s. The host Bash contract is 300s (SKILL.md 300000ms). That kills the whole report. Do not do that.
The measured failure is when the review lane starts, not pull quality. Isolated Amazon-only already finishes in 124s of 180s. On a full run, search has already landed products, then reviews wait through every other source plus Phase 2/2b, then get 11s.
What to build
Start
enrich_with_reviewswhen Amazon search returns, inside_retrieve_stream(amazon branch ~4284), overlapping other source futures. Pass realelapsed = time.monotonic() - run_started(threadrun_startedinto retrieve). After a 30–90s search, leftover is 190–250s → clamp to 180. Isolated Amazon-only unchanged.Keep finalize (
_finalize_items_by_source~2956) as attach-if-missing only.enrich_source_itemsalready no-ops iftop_commentsis set. Do not make finalize the only start. Do not enrich inline on the collect loop (that serializes other sources for 124s).Leftover below a useful floor → budget 0, skip the lane. Do not fire doomed 11s pulls (Bright Data
cli_timeout = max(5, timeout-10)so budget 11s → CLI timeout 1s, still spends 3 credits). SuggestedMIN_USEFUL_REVIEW_BUDGET = 90. Crumbs are a skip, not a short timeout.If the lane is skipped or all pulls drop: Amazon
source_statusPARTIAL with detail likereview lane timed out/review lane skipped (budget 0s). Listings stay. Do not flip the whole source totimeout(search succeeded). Footer already shows ⚠ when state != ok — do not change render.py.depth=quickstill 0 pulls.mock=Truestill skips. No env knob. No raising LANE_DEADLINE or FOREGROUND_CONTRACT.
Out of scope
- Do NOT change footer/render.py.
- Do NOT change X search or Grok auth.
- Do NOT add an env knob.
- Do NOT reorder the whole source schedule (deferred).
Implementation
amazon.py
- Added
MIN_USEFUL_REVIEW_BUDGET = 90 - Changed
_remaining_lane_budgetto return 0 when below floor (not floor up) - Changed
enrich_with_reviewsto return(products, status_detail)tuple where status_detail is:Nonefor normal success"review lane skipped (budget 0s)"when budget is below floor"review lane timed out"when all pulls dropped
pipeline.py
- Added
run_startedparameter to_retrieve_stream,_retrieve_stream_impl, and_retry_thin_sources - Updated all call sites to pass
run_started - In the Amazon branch of
_retrieve_stream_impl:- Run search as before
- Calculate
elapsed = time.monotonic() - run_started - Call
enrich_with_reviewsimmediately after search returns - If enrichment reports a degraded status, add
_source_outcomewithstate=PARTIALto the artifact
- Updated finalize comments to note it's now attach-if-missing only
Tests (test_amazon.py)
Retargeted existing tests:
test_lane_budget_shrinks_as_the_run_clock_advances— now tests floor behaviortest_dropped_straggler_keeps_its_product_with_search_stats— uses patched short LANE_DEADLINEtest_exhausted_wall_clock_skips_the_lane_entirely— unchanged
New tests:
test_lane_budget_floor_prevents_doomed_pulls— verifies elapsed=269 returns 0test_lane_budget_constants_are_sane— guards against constant drifttest_crumb_budget_skips_not_fires_doomed_pulls— regression test for the Bentgo bugtest_early_elapsed_gets_full_budget— verifies elapsed=40 gets 180s timeouttest_all_pulls_dropped_reports_timed_out_status— verifies PARTIAL status on all-dropped