Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
Back to tool/Back to issues
#10667·agno

[Bug] SitemapReader skips later shards when duplicate or filtered URLs exhaust max_pages

Author: lakers-abingCreated Sep 30, 2026Updated Sep 30, 2026

Description

SitemapReader stops traversing a sitemap index when the raw number of collected <loc> entries reaches max_pages, before host filtering and canonical URL deduplication. Duplicate entries, aliases such as /p1/ and /p1/index.html, or off-host entries can exhaust this budget even though fewer than max_pages eligible pages have been found. Later shards containing valid pages are then skipped.

Steps to Reproduce

This offline reproduction drives the reader's discovery generator with deterministic XML bodies. No model, API key, or network is needed:

python
from agno.knowledge.reader.sitemap_reader import SitemapReader

def urlset(*urls):
    return ("<urlset>" + "".join(f"<url><loc>{u}</loc></url>" for u in urls) + "</urlset>").encode()

root = "https://example.com/sitemap.xml"
shard1 = "https://example.com/sm1.xml"
shard2 = "https://example.com/sm2.xml"
page1 = "https://example.com/p1"
page2 = "https://example.com/p2"
bodies = {
    root: (f"<sitemapindex><sitemap><loc>{shard1}</loc></sitemap>"
           f"<sitemap><loc>{shard2}</loc></sitemap></sitemapindex>").encode(),
    shard1: urlset(page1, page1),
    shard2: urlset(page2),
}
discovery = SitemapReader(max_pages=2)._discover(root, ["example.com"])
request_url = next(discovery)
try:
    while True:
        request_url = discovery.send(bodies.get(request_url))
except StopIteration as done:
    print(done.value)

Expected Behavior

Both eligible pages are discovered, in order: ([page1, page2], root, False). Duplicates and filtered hosts should not consume a page budget.

Actual Behavior

Only the first page is discovered: ([page1], root, True). The second shard is never fetched. Substituting two off-host entries in the first shard can make the read return no pages at all despite valid pages in the second shard.

Environment

Agno main at 4db4180ad9354c3cb5cd94a1d8cfcca4170b32db (3.0.11), macOS ARM64, Python 3.12.14.

Additional Context

Reproduced through both public read() and async_read() using the existing httpx.MockTransport test harness. Ten regression cases fail on the unchanged implementation; the 52 existing sitemap tests pass. A focused fix and passing validation are prepared. Existing Issue/PR searches for sitemap, max_pages, duplicates, and budget did not find a matching fix.

This report and fix were prepared by Codex with the account holder's authorization.

Source: agno-agi/agno

View original on GitHubView discussion on GitHub