Skip to content

Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.

feat: enhance error handling for RPC rate limits in holder snapshot process

qbdza018b41529ca
diff --git a/CHANGELOG.md b/CHANGELOG.md
index bd217541d..94805489c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -13,6 +13,7 @@ Public history for [three.ws](https://three.ws), newest first. New pages come fr
- **Agent profiles show the agent's real 3D body again** — An agent page now renders the avatar the agent actually wears — including non-humanoid bodies like animals and props — instead of falling back to the default mannequin. The profile was discarding the model link returned for the agent's avatar before it reached the 3D stage, so any agent whose body came through that field silently showed the placeholder figure. The real model now flows through to the hero and fullscreen viewers, and bodies with their own built-in animation play it on the spot. `[fix]`
- **Agent Sniper is now a standalone open-source package** — The engine that lets three.ws agents snipe pump.fun launches is now its own lightweight, embeddable package: @three-ws/agent-sniper. Run it four ways — as a library, a CLI, an MCP server your AI agent can drive, or a paid x402 API that other agents pay in USDC to use. It ships with pluggable wallet, storage, RPC, and launch-feed adapters, so you can run a fully self-custodial sniper from your own keypair or a multi-tenant hosted service from one engine. Every agent gets its own wallet, its own budget and concurrency caps, a mandatory stop-loss, a price-impact circuit breaker, and a simulate-first default — plus the 3D-agent layer that puts a live trading desk on screen. Multiple agents and multiple users can snipe side by side, each embodied by its own 3D AI agent. `[sdk, feature]`
- **Agent Studio movement previews now play on the live avatar** — On the Body tab of Agent Studio, clicking a move in the Movement library — and pinning a looping idle as your resting pose — now actually animates your agent on the stage. The live avatar was loading without its shared clip library, so previews quietly did nothing and the avatar held its bind pose. The full motion library is now wired to the studio stage, so every clip plays the moment you click it and your pinned resting pose loops everywhere your agent appears. (`/agent-studio`) `[fix]`
+- **AI chat now routes around a dead provider account instead of hammering it** — When one of the AI providers behind the chat is out of credit or its account is unfunded, it answers every request with the same billing wall. The chat already fell back to a working provider, but it would keep re-trying the dead one as a last resort on the very next message — wasting a round-trip and occasionally surfacing an 'at capacity' message that didn't need to happen. Now the chat recognizes a billing or quota wall as different from a momentary rate-limit: it parks that provider for several minutes and goes straight to a healthy one, so replies come faster and the spurious capacity errors stop. Separately, when an unexpected error bubbles up in the browser, our error reporting now captures what actually went wrong instead of an opaque 'object Object', so real issues get diagnosed and fixed sooner. `[fix, improvement]`
- **Fixed several pages returning a 404** — A handful of pages were built and shipping but had no clean-URL route, so they fell through to the not-found page: the agent wallet (/agent-wallet), the viability report (/viability), and the gallery picker. All now load correctly. The agent wallet, when opened without a specific agent, also shows a clear prompt to pick or create one. (`/viability`) `[fix]`
- **Marketplace & trading viability get a dedicated page** — The two "honest signal" panels — marketplace viability (real $THREE skill GMV, take-rate, repeat buyers, trading pairs) and trading viability (real guarded coin-trade flow, cost and realized P&L on closed positions) — now live on their own page at /viability. The Money Pulse stays focused on the live event feed and links across to the full viability breakdown, so each surface does one thing well. Same real on-chain numbers, just easier to read and share. (`/viability`) `[improvement]`
- **Memory seeding no longer times out** — Building your agent's memory seed from your connected accounts could fail with an opaque error when the language model took a moment to respond — the request was being cut off before it finished and the page showed a generic failure. The synthesis step now has the time it needs to complete, automatically falls over to a backup provider if one is slow, and when it genuinely can't run it tells you plainly instead of failing silently. `[fix]`
diff --git a/api/_lib/coin/holders.js b/api/_lib/coin/holders.js
index 21c5b1728..36f05bc50 100644
--- a/api/_lib/coin/holders.js
+++ b/api/_lib/coin/holders.js
@@ -24,6 +24,63 @@ const PAGE_LIMIT = 1000;
const MAX_PAGES = 200; // hard ceiling — 200k holders before we abort, matches Helius limits
const UPSERT_CHUNK = 2000; // rows per batched upsert — keeps statements under Neon size limits
+// Per-page retry policy for the DAS walk. Helius enforces a shared requests/sec
+// rate limit; a multi-page holder scan can trip it mid-walk and the SDK throws a
+// 429. Retrying that page after a short backoff lets the limiter refill and the
+// scan complete, instead of aborting the whole snapshot tick (the production
+// failure mode behind the "[three-holders-snapshot] refresh failed: Solana error
+// #8100002" floods — #8100002 is the @solana/kit HTTP-transport wrapper carrying
+// statusCode 429). Capped well under the cron's 120s budget: at most
+// PAGE_RETRY_MAX backoffs of up to PAGE_RETRY_CAP_MS each, gated by an overall
+// SCAN_BUDGET_MS deadline so a sustained throttle degrades to a deferred tick
+// rather than a function timeout.
+const PAGE_RETRY_MAX = 4;
+const PAGE_RETRY_BASE_MS = 500;
+const PAGE_RETRY_CAP_MS = 6000;
+const SCAN_BUDGET_MS = 90_000;
+
+const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
+
+/**
+ * True when a thrown RPC error is an upstream rate limit (HTTP 429). Handles the
+ * three shapes Helius/@solana/kit produce: a SolanaError whose `context.statusCode`
+ * is 429 (the structured signal, present at runtime even when the human-readable
+ * message is stripped in prod builds), a plain error with `.status`/`.statusCode`,
+ * and the verbatim provider bodies ("429", "Too Many Requests", "max usage
+ * reached") that surface only as a message string. Exported so the snapshot cron
+ * classifies the same condition as a transient warning, not an error.
+ * @param {unknown} err
+ * @returns {boolean}
+ */
+export function isRpcRateLimited(err) {
+ if (!err || typeof err !== 'object') return false;
+ const e = /** @type {any} */ (err);
+ const ctx = e.context || {};
+ const status = Number(e.statusCode ?? e.status ?? ctx.statusCode ?? NaN);
+ if (status === 429) return true;
+ const msg = String(e.message || err);
+ return /\b429\b|too many requests|rate.?limit|max usage reached/i.test(msg);
+}
+
+// One DAS page with bounded exponential backoff on 429. Non-rate-limit errors
+// (auth, malformed mint, network reset) propagate immediately — retrying them
+// only burns the scan budget. `deadline` is the absolute epoch-ms cutoff for the
+// whole walk; once a backoff would cross it we give up so the cron never runs
+// past its function budget.
+async function getTokenAccountsPage(client, params, deadline) {
+ for (let attempt = 0; ; attempt++) {
+ try {
+ return await client.getTokenAccounts(params);
+ } catch (err) {
+ if (!isRpcRateLimited(err) || attempt >= PAGE_RETRY_MAX) throw err;
+ const backoff = Math.min(PAGE_RETRY_CAP_MS, PAGE_RETRY_BASE_MS * 2 ** attempt)
+ + Math.floor(Math.random() * 250); // small jitter so concurrent scanners desync
+ if (Date.now() + backoff > deadline) throw err;
+ await sleep(backoff);
+ }
+ }
+}
+
let _heliusMainnet = null;
let _heliusDevnet = null;
@@ -50,15 +107,16 @@ function helius(network) {
export async function fetchHolderBalances({ mint, network = 'mainnet' }) {
const client = helius(network);
const balances = new Map();
+ const deadline = Date.now() + SCAN_BUDGET_MS;
let cursor;
for (let page = 0; page < MAX_PAGES; page++) {
- const resp = await client.getTokenAccounts({
+ const resp = await getTokenAccountsPage(client, {
mint,
limit: PAGE_LIMIT,
...(cursor ? { cursor } : {}),
options: { showZeroBalance: false },
- });
+ }, deadline);
const accounts = resp?.token_accounts || [];
for (const acc of accounts) {
diff --git a/api/cron/three-holders-snapshot.js b/api/cron/three-holders-snapshot.js
index 811f96e4a..8718147b1 100644
--- a/api/cron/three-holders-snapshot.js
+++ b/api/cron/three-holders-snapshot.js
@@ -20,6 +20,7 @@ import { error, json, method, wrapCron } from '../_lib/http.js';
import { env } from '../_lib/env.js';
import { constantTimeEquals } from '../_lib/crypto.js';
import { refreshThreeHolderSnapshot } from '../_lib/coin/three-holders.js';
+import { isRpcRateLimited } from '../_lib/coin/holders.js';
import { isDbUnavailableError } from '../_lib/db.js';
// Vercel cron invokes with `Authorization: Bearer <CRON_SECRET>`; manual probes
@@ -68,8 +69,14 @@ export default wrapCron(async (req, res) => {
// operationally expected and self-heals on the next tick — classify it with
// the same isDbUnavailableError gate the rest of the platform uses so it
// warns rather than firing a per-tick error into alerting.
+ // A Helius 429 surfaces as a SolanaError whose human-readable message is
+ // stripped in prod ("Solana error #8100002; Decode this …") — it carries
+ // neither "429" nor "rate limit" as text, so the string regex alone missed
+ // it and fired a per-tick ERROR into alerting. isRpcRateLimited inspects the
+ // structured statusCode, classifying the throttle correctly as transient.
const transient = isDbUnavailableError(err)
- || /terminated|fetch failed|ECONNRESET|ETIMEDOUT|EAI_AGAIN|socket hang up|429|rate.?limit|network|password authentication failed|table unavailable/i.test(msg);
+ || isRpcRateLimited(err)
+ || /terminated|fetch failed|ECONNRESET|ETIMEDOUT|EAI_AGAIN|socket hang up|429|rate.?limit|too many requests|network|password authentication failed|table unavailable/i.test(msg);
if (transient) console.warn('[three-holders-snapshot] refresh deferred (transient upstream):', msg);
else console.error('[three-holders-snapshot] refresh failed:', msg);
return json(res, 200, { ok: false, refreshed: false, error: msg });
diff --git a/data/changelog.json b/data/changelog.json
index 61dd3e240..26964ffba 100644
--- a/data/changelog.json
+++ b/data/changelog.json
@@ -1,6 +1,15 @@
{
"$comment": "Curated changelog entries for three.ws \u2014 the editorial layer of the public changelog. New PAGE launches are tracked automatically via the `added` field in data/pages.json; this file is for everything else holders care about: improvements, fixes, SDK releases, trading/payments capabilities, security work. scripts/build-page-index.mjs merges both sources into CHANGELOG.md, public/changelog.json, and public/changelog.xml. Newest first. Allowed tags: feature, improvement, fix, sdk, infra, docs, security. `link` is optional and must be a live three.ws path.",
"entries": [
+ {
+ "date": "2026-06-30",
+ "title": "AI chat now routes around a dead provider account instead of hammering it",
+ "summary": "When one of the AI providers behind the chat is out of credit or its account is unfunded, it answers every request with the same billing wall. The chat already fell back to a working provider, but it would keep re-trying the dead one as a last resort on the very next message — wasting a round-trip and occasionally surfacing an 'at capacity' message that didn't need to happen. Now the chat recognizes a billing or quota wall as different from a momentary rate-limit: it parks that provider for several minutes and goes straight to a healthy one, so replies come faster and the spurious capacity errors stop. Separately, when an unexpected error bubbles up in the browser, our error reporting now captures what actually went wrong instead of an opaque 'object Object', so real issues get diagnosed and fixed sooner.",
+ "tags": [
+ "fix",
+ "improvement"
+ ]
+ },
{
"date": "2026-06-30",
"title": "The markets & standings pages now move like the games they are",
diff --git a/public/changelog.json b/public/changelog.json
index 779ab5972..0e2ab1919 100644
--- a/public/changelog.json
+++ b/public/changelog.json
@@ -1,5 +1,5 @@
{
- "generated_at": "2026-06-30T21:06:29.296Z",
+ "generated_at": "2026-06-30T21:07:43.783Z",
"generated_by": "scripts/build-page-index.mjs from data/pages.json + data/changelog.json",
"site": {
"name": "three.ws",
@@ -77,6 +77,17 @@
"fix"
]
},
+ {
+ "date": "2026-06-30",
+ "type": "update",
+ "title": "AI chat now routes around a dead provider account instead of hammering it",
+ "summary": "When one of the AI providers behind the chat is out of credit or its account is unfunded, it answers every request with the same billing wall. The chat already fell back to a working provider, but it would keep re-trying the dead one as a last resort on the very next message — wasting a round-trip and occasionally surfacing an 'at capacity' message that didn't need to happen. Now the chat recognizes a billing or quota wall as different from a momentary rate-limit: it parks that provider for several minutes and goes straight to a healthy one, so replies come faster and the spurious capacity errors stop. Separately, when an unexpected error bubbles up in the browser, our error reporting now captures what actually went wrong instead of an opaque 'object Object', so real issues get diagnosed and fixed sooner.",
+ "link": null,
+ "tags": [
+ "fix",
+ "improvement"
+ ]
+ },
{
"date": "2026-06-30",
"type": "update",
diff --git a/public/changelog.xml b/public/changelog.xml
index 45f616bb3..001754111 100644
--- a/public/changelog.xml
+++ b/public/changelog.xml
@@ -62,6 +62,14 @@
<category>fix</category>
<description>On the Body tab of Agent Studio, clicking a move in the Movement library — and pinning a looping idle as your resting pose — now actually animates your agent on the stage. The live avatar was loading without its shared clip library, so previews quietly did nothing and the avatar held its bind pose. The full motion library is now wired to the studio stage, so every clip plays the moment you click it and your pinned resting pose loops everywhere your agent appears.</description>
</item>
+ <item>
+ <title>AI chat now routes around a dead provider account instead of hammering it</title>
+ <link>https://three.ws/changelog</link>
+ <guid isPermaLink="false">2026-06-30:AI chat now routes around a dead provider account instead of hammering it</guid>
+ <pubDate>Tue, 30 Jun 2026 12:00:00 GMT</pubDate>
+ <category>fix</category>
+ <description>When one of the AI providers behind the chat is out of credit or its account is unfunded, it answers every request with the same billing wall. The chat already fell back to a working provider, but it would keep re-trying the dead one as a last resort on the very next message — wasting a round-trip and occasionally surfacing an 'at capacity' message that didn't need to happen. Now the chat recognizes a billing or quota wall as different from a momentary rate-limit: it parks that provider for several minutes and goes straight to a healthy one, so replies come faster and the spurious capacity errors stop. Separately, when an unexpected error bubbles up in the browser, our error reporting now captures what actually went wrong instead of an opaque 'object Object', so real issues get diagnosed and fixed sooner.</description>
+ </item>
<item>
<title>Fixed several pages returning a 404</title>
<link>https://three.ws/viability</link>
diff --git a/public/features.json b/public/features.json
index bc032eb2a..7ab48eaf3 100644
--- a/public/features.json
+++ b/public/features.json
@@ -1,5 +1,5 @@
{
- "generated_at": "2026-06-30T21:06:29.251Z",
+ "generated_at": "2026-06-30T21:07:43.756Z",
"generated_by": "scripts/build-page-index.mjs from data/pages.json",
"site": {
"name": "three.ws",