fix(agents): page the whole agent registry, not the first 1000 (#320) - #889
Merged
Conversation
`fetchBulkAgents()` capped its pagination loop at a hardcoded `BULK_MAX_PAGES = 10` (10 x 100 = offsets 0..999). The aibtc.com registry now holds 1049 agents, so page 10 was never requested and every agent past index 999 became permanently unresolvable in the batch path — rendering on /agents as a truncated BTC address despite the registry holding a displayName for them. Verified against production: of the 20 correspondents showing an address instead of a name, 9 have an upstream displayName, and every one sampled sits on page 10: Encrypted Zara rank 14, 239 signals Dual Cougar rank 45, 177 signals Secret Mars rank 49, 175 signals Ionic Anvil rank 155, 103 signals This also explains why the issue read as intermittent: #320's original screenshot cited Ionic Anvil and Dual Cougar as displaying *correctly* in March. They fell off the end as the registry grew past 1000 — a boundary crossing, not a race. Second-order effect: when the loop exits on the page cap, `complete` stays false, so the negative-cache write is skipped. Those addresses were re-fetched on every correspondents rebuild — 10 sequential registry pages per rebuild, all still failing — re-introducing the cold-rebuild cost that #867 set out to remove (#690). The loop now sizes itself from `pagination.total` on the first page and still stops on `hasMore`. The remaining constant is renamed to BULK_HARD_PAGE_CEILING and raised to 200 pages, documented as a runaway guard rather than a coverage limit, so registry growth can never silently truncate the fetch again. Adds a regression test covering the boundary, both sides of it in one call, positive caching past the boundary, page-count exactness, and that a genuinely-absent address is still negative-cached only on a complete fetch. 5 of the 6 fail against the pre-fix resolver. Full suite green (476). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
agent-news | 03ae77a | Jul 23 2026, 04:59 AM |
Contributor
|
Preview deployed: https://agent-news-staging.hosting-962.workers.dev This preview uses sample data — beats, signals, and streaks are seeded automatically. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #320.
Root cause
fetchBulkAgents()insrc/services/agent-resolver.tscapped its pagination loop at a hardcodedBULK_MAX_PAGES = 10:That covers offsets 0–999. The aibtc.com registry now returns
pagination.total: 1049— 11 pages. Page 10 was never requested, so every agent past index 999 was unreachable in the batch resolution path and rendered on/agentsas a truncated BTC address.Verification against production
Of the 20 correspondents currently showing an address instead of a name, 9 have an upstream
displayName(the other 11 are genuinely unnamed — correct fallback). Every one I traced sits on page 10:displayName'Encrypted Zara''Dual Cougar''Secret Mars''Ionic Anvil'This also explains why #320 read as intermittent. Its original March screenshot cited Ionic Anvil and Dual Cougar as the agents displaying correctly. They fell off the end as the registry grew past 1,000 — a boundary crossing, not the race condition the issue hypothesised.
Second-order effect
When the loop exited on the page cap,
hasMorewas still true, socompletestayedfalseand the negative-cache write at line 223 was skipped. Those addresses were therefore re-fetched on every correspondents rebuild — 10 sequential registry pages, 15s timeout each, all still failing — re-introducing exactly the cold-rebuild cost #867 set out to remove (see #690).The fix
The loop now sizes itself from
pagination.totalon the first page, and still stops onhasMore. The surviving constant is renamedBULK_HARD_PAGE_CEILINGand raised to 200 pages, documented as a runaway guard rather than a coverage limit, so registry growth can never silently truncate the fetch again.Tests
New
src/__tests__/agent-resolver-pagination.test.tscovers:5 of the 6 fail against the pre-fix resolver (verified by reverting). Full suite green: 476 passed, 48 files.
tsc --noEmitandbiome lintclean on both changed files.Deploy note
This is served by the
news-singletonDO path via/api/correspondentsand/api/init. Per prior experience the DO keep-alive can block eviction onto new code — a manualwrangler deploymay be needed for the change to take effect, and existing negative-cache entries expire within 30 minutes.