agora.fleet.web_fetch
Safe HTTPS fetcher for the fetch_url inner tool.
Design constraints locked with the user:
HTTPS only. Reject everything else (http, file, data, ftp, …).
SSRF guard. Resolve the hostname before the request, and refuse any IP that is loopback, link-local, private (RFC 1918 / 4193), or the cloud metadata address (169.254.169.254). Re-check the resolved IP at request time.
Size-bounded. Cap the raw HTML body at
max_bytesand the extracted text atmax_text_bytesso a 7B model’s context window doesn’t overflow.Text extraction. Use
trafilaturato strip nav/sidebar/footer and return just the main content.Non-blocking. All IO via
aiohttpunder an explicitClientTimeout.Caching. A
FetchCachelets callers share a cache across agents so the architect and implementer don’t re-fetch the same Discord page.
Raises SSRFError on disallowed URLs and FetchError on any
other fetch/extraction failure. Both inherit from
AgoraError.
Functions
|
Build an |
|
Fetch a URL, convert to clean text, return the text (truncated). |
|
Parse, scheme-check, and DNS-resolve |
Classes
Per-project in-memory cache: |
Exceptions
Generic failure in |
|
The URL was rejected by the SSRF guard. |
- class agora.fleet.web_fetch.FetchCache[source]
Bases:
objectPer-project in-memory cache:
{url: extracted_text}.- __init__(entries=<factory>)
- exception agora.fleet.web_fetch.FetchError[source]
Bases:
AgoraErrorGeneric failure in
safe_fetch()— network, HTTP, or extraction.
- exception agora.fleet.web_fetch.SSRFError[source]
Bases:
AgoraErrorThe URL was rejected by the SSRF guard.
- agora.fleet.web_fetch.make_fetcher(*, cache, timeout_seconds=30.0, max_bytes=1048576, max_text_bytes=16384)[source]
Build an
async def fetch(url) -> strbound to a shared cache.
- async agora.fleet.web_fetch.safe_fetch(url, *, timeout_seconds=30.0, max_bytes=1048576, max_text_bytes=16384, cache=None, user_agent='agora-bot/0.1 (+https://github.com/fabs133/manifold)')[source]
Fetch a URL, convert to clean text, return the text (truncated).
Retries once on transient errors (timeout, 429, 5xx, connection reset) with a short backoff. Non-transient failures (SSRF, 4xx other than 429, malformed content) raise immediately.
Never blocks the event loop. Always raises on any policy violation.