perf(agent): cache scraped pages and retry failed fetches

Adds a disk-backed scrape cache under workspace/web_cache keyed by
the SHA-256 of the URL, honoring WEB_SEARCH_SCRAPE_CACHE_TTL so
repeated lookups within the window skip the network entirely.

Fetches now retry twice with exponential backoff before giving up,
and URLs are screened against SCRAPING_BLOCKED_EXTENSIONS and
SCRAPING_BLOCKED_DOMAINS to avoid downloading binaries or
denylisted hosts.

New scraping knobs (enable flag, max chars, cache TTL, blocklists)
are exposed via .env, alongside a provider switch to stepfun with
the step-3.7-flash default model.
This commit is contained in:
2026-10-26 17:01:50 -03:00
parent 723ca1506b
commit 5697cd0c40
4 changed files with 216 additions and 81 deletions
+9 -2
View File
@@ -5,10 +5,10 @@ TELEGRAM_CHAT_ID=7889499475
# AI Provider (openrouter | stepfun | qwencloud | llamacpp)
AI_PROVIDER=openrouter
AI_PROVIDER=stepfun
# Default AI Model
DEFAULT_MODEL=xiaomi/mimo-v2.6-flash
DEFAULT_MODEL=step-3.7-flash
@@ -39,6 +39,13 @@ MAX_HISTORY_LENGTH=50
WEB_SEARCH_ENABLED=true
WEB_SEARCH_MAX_RESULTS=5
# Scraping configuration
WEB_SEARCH_SCRAPE_ENABLED=true
WEB_SEARCH_SCRAPE_MAX_CHARS=2500
WEB_SEARCH_SCRAPE_CACHE_TTL=3600
SCRAPING_BLOCKED_DOMAINS=
SCRAPING_BLOCKED_EXTENSIONS=.pdf,.jpg,.jpeg,.png,.gif,.svg,.zip,.rar,.exe,.dmg,.bin
# Vision / image analysis model
VISION_MODEL=meta-llama/llama-4-maverick-17b-128e-instruct
VISION_PROVIDER=openrouter