Repository navigation
Description
What problem does this solve?
web_fetch is direct HTTPS only: no JavaScript, no browser, no readability fallback, 512 KiB cap, content-type allowlist, SSRF-guarded redirects (crates/tole-core/src/web.rs). Many real pages (JS-rendered, bot-protected) come back empty or unusable.
A comparable agent (Hermes, owner-supplied usage numbers, not independently verified) uses a scraping service about as often as search: roughly 890 scrapes versus 734 searches. So "fetch a page that needs a real browser" is as common as "search the web", and tole only covers the second (via TOLE_WEB_SEARCH_URL, #215 / #436).
Remote MCP (separate issue) could carry this, but every MCP tool is Risk::Write and asks unless pre-authorized. A page fetch is read-only; a configured fetch backend lets it stay a ReadOnly tool with the same trust model as web_search: results are model content, never executed.
Proposed solution
Config-first, no new tool: when TOLE_WEB_FETCH_URL is set, web_fetch sends the target URL to that backend and returns the backend's text. When it is unset, behavior is exactly today's (no backend, direct fetch).
- Contract (proposal): mirrors
web_search:GET {url}?url=<target>by default returning JSON with a content field;TOLE_WEB_FETCH_METHOD,TOLE_WEB_FETCH_HEADERS(e.g.Authorization=Bearer ${KEY}, sent only to the backend) andTOLE_WEB_FETCH_FIELDS(field mapping) like feat(tools): TOLE_WEB_SEARCH_URL — auth headers + response field mapping #436. A malformed value fails startup, asweb_searchdoes. The exact response shape of the intended backend (a scraping service with static, browser and reader fallbacks) still has to be verified before this is fixed. - Guards stay on the tole side: the target URL is validated first (https only, host resolves to public addresses, no credentials in the URL) so a private/loopback target is refused before anything is sent to a remote backend; the backend's response is size-capped and sanitized like any fetch result.
- Fallback: open question below.
- Docs: README tool table and env reference,
docs/threat-model.mdrow for the backend (target URLs are disclosed to the backend operator), same PR.
Open questions
- Fallback order: backend only, direct first then backend on empty/blocked, or backend first then direct on backend failure? Proposal: backend only when configured, to keep behavior predictable; revisit with data.
- Format hint: ask the backend for compact/markdown output to save tokens?
- Should the tool description tell the model a browser-capable backend is attached, so it picks it for JS-heavy pages?
Alternatives considered
- Only use the MCP route: works once the HTTP transport exists, but each call is a Write approval unless pre-authorized per server.
- Add a headless-browser tool to tole: rejected, it would be a new browser-agent surface (marked anti-DNA in the October harness research); a backend keeps the browser outside tole.
Acceptance criteria
- With
TOLE_WEB_FETCH_URLunset,web_fetchis byte-for-byte unchanged (tests). - With it set, a private/loopback/credentialed target is refused locally and never sent to the backend (tests).
- Backend headers are sent only to the backend; a test proves they are not logged or echoed.
- Response size cap and sanitization apply to backend output.
- Malformed config fails startup with a clear message.
- Docs and threat model updated in the same PR.
Activity
fix(web): fetch backend reports truncated when the character cap cuts…
feat(web): optional fetch backend for web_fetch via TOLE_WEB_FETCH_URL (