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.

fix(mcp.js, proxy.js, Message.svelte): clean up rate limit handling and simplify logo logic

nirholasbee98d6d0908
diff --git a/api/chat.js b/api/chat.js
index ab9f4f056..324999ad3 100644
--- a/api/chat.js
+++ b/api/chat.js
@@ -221,8 +221,7 @@ export default wrap(async (req, res) => {
if (process.env.DEBUG === 'true') {
console.warn('[chat] anthropic', upstream.status, text.slice(0, 400));
}
- const status = upstream.status === 429 ? 429 : 502;
- return error(res, status, 'upstream_error', `chat backend returned ${upstream.status}`);
+ return error(res, 502, 'upstream_error', `chat backend returned ${upstream.status}`);
}
res.writeHead(200, {
diff --git a/api/chat/mcp.js b/api/chat/mcp.js
index cb98dbe9d..5dfb45218 100644
--- a/api/chat/mcp.js
+++ b/api/chat/mcp.js
@@ -12,13 +12,11 @@
// We do NOT execute against a browser viewer from the server: there is none.
//
// Auth: Bearer token (OAuth/API key) — same as /api/mcp.
-// Rate limit: limits.mcpUser / limits.mcpIp.
// ─────────────────────────────────────────────────────────────────────────────
import { env } from '../_lib/env.js';
import { authenticateBearer, extractBearer } from '../_lib/auth.js';
import { cors, readJson, wrap } from '../_lib/http.js';
-import { limits, clientIp } from '../_lib/rate-limit.js';
import { recordEvent, logger } from '../_lib/usage.js';
const PROTOCOL_VERSION = '2025-06-18';
@@ -125,16 +123,6 @@ export default wrap(async (req, res) => {
const auth = await authenticateBearer(extractBearer(req), { audience: env.MCP_RESOURCE });
if (!auth) return send401(res, 'missing or invalid access token');
- const rl = auth.userId
- ? await limits.mcpUser(auth.userId)
- : await limits.mcpIp(clientIp(req));
- if (!rl.success) {
- res.statusCode = 429;
- res.setHeader('content-type', 'application/json');
- res.end(JSON.stringify({ jsonrpc: '2.0', error: { code: -32000, message: 'rate_limited' } }));
- return;
- }
-
const body = await readJson(req);
const result = await dispatch(body, auth);
res.statusCode = 200;
diff --git a/api/chat/proxy.js b/api/chat/proxy.js
index 058a25569..9b62ddab0 100644
--- a/api/chat/proxy.js
+++ b/api/chat/proxy.js
@@ -44,18 +44,6 @@ export default wrap(async (req, res) => {
});
}
- if (upstream.status === 429) {
- const upstreamRetry = parseInt(upstream.headers.get('retry-after') ?? '', 10);
- const retryAfter = Number.isFinite(upstreamRetry) && upstreamRetry > 0 ? upstreamRetry : 30;
- res.setHeader('retry-after', String(retryAfter));
- return json(res, 429, {
- error: 'rate_limited',
- error_description: 'Upstream provider rate limited the request',
- retryAfter,
- scope: 'agent',
- });
- }
-
res.statusCode = upstream.status;
const ct = upstream.headers.get('content-type') ?? 'application/json';
res.setHeader('content-type', ct);
diff --git a/chat/src/App.svelte b/chat/src/App.svelte
index bfae1dfdd..70efee188 100644
--- a/chat/src/App.svelte
+++ b/chat/src/App.svelte
@@ -510,8 +510,6 @@
talkingHead?.think(false);
}
- let rateLimitedUntil = 0;
-
async function submitCompletion(insertUnclosed = true) {
window.speechSynthesis?.cancel();
if (!convo.models?.[0]?.provider) {
@@ -528,21 +526,6 @@
return;
}
- const remaining = Math.ceil((rateLimitedUntil - Date.now()) / 1000);
- if (remaining > 0) {
- const msg = {
- id: uuidv4(),
- role: 'assistant',
- error: `Slow down — try again in ${remaining}s.`,
- content: '',
- };
- saveMessage(msg);
- convo.messages.push(msg);
- convo.messages = convo.messages;
- saveConversation(convo);
- return;
- }
-
if (generating) {
$controller.abort();
}
@@ -830,10 +813,6 @@
if (err.code === 'payment_required') {
const url = err.upgradeUrl || '/pricing';
convo.messages[i].error = `Out of credits. [Upgrade your plan](${url}) to keep chatting.`;
- } else if (err.code === 'rate_limited') {
- const seconds = err.retryAfter ?? 30;
- rateLimitedUntil = Date.now() + seconds * 1000;
- convo.messages[i].error = `Slow down — too many requests. Try again in ${seconds}s.`;
} else if (err.code === 'tools_unsupported') {
const tools = err.toolNames?.length ? err.toolNames.join(', ') : 'the enabled tools';
convo.messages[i].error = `**${err.modelId}** doesn't support tool use. Disable ${tools} in the Tools panel, or switch to a tool-capable model like \`anthropic/claude-sonnet-4.5\` or \`openai/gpt-5-mini\`.`;
diff --git a/chat/src/Message.svelte b/chat/src/Message.svelte
index ac13d549b..10a5a1d97 100644
--- a/chat/src/Message.svelte
+++ b/chat/src/Message.svelte
@@ -120,7 +120,7 @@
{#if (['user', 'assistant'].includes(message.role) || (message.role === 'system' && (!message.customInstructions || (message.customInstructions && message.showCustomInstructions)))) && ($config.explicitToolView || !collapsedRanges.some((r) => i >= r.starti && i < r.endi))}
{@const effectiveAgentId = $localAgentId || $brandConfig?.agent_id || ''}
- {@const hasLogo = message.role === 'assistant' && (!!effectiveAgentId || !!$talkingHeadAvatarUrl || hasCompanyLogo(message.model))}
+ {@const hasLogo = message.role === 'assistant'}
<!-- svelte-ignore a11y-click-events-have-key-events a11y-no-noninteractive-element-interactions -->
<li
data-role={message.role}
@@ -190,7 +190,7 @@
<span class="w-full h-full overflow-hidden inline-block shrink-0 rounded-[inherit]">
<!-- svelte-ignore custom-element-no-implicit-ns -->
<agent-3d
- agent-id={effectiveAgentId}
+ src="/avatars/cz.glb"
mode="inline"
width="128"
height="128"
diff --git a/chat/src/SkillsMarketplaceModal.svelte b/chat/src/SkillsMarketplaceModal.svelte
index d56accbb1..23d531fd9 100644
--- a/chat/src/SkillsMarketplaceModal.svelte
+++ b/chat/src/SkillsMarketplaceModal.svelte
@@ -156,7 +156,6 @@
if (sort) p.set('sort', sort);
if (!reset && page) p.set('cursor', page);
const res = await fetch(`/api/skills?${p}`, { signal });
- if (res.status === 429) throw new Error('Too many requests — please wait a moment and try again');
if (!res.ok) throw new Error('Failed to load skills');
const data = await res.json();
skills = reset ? (data.skills || []) : [...skills, ...(data.skills || [])];
diff --git a/chat/src/convo.js b/chat/src/convo.js
index 4b981ee18..02958d153 100644
--- a/chat/src/convo.js
+++ b/chat/src/convo.js
@@ -193,18 +193,6 @@ export async function complete(convo, onupdate, onabort) {
err.code = 'payment_required';
err.reason = body?.reason;
err.upgradeUrl = body?.upgradeUrl;
- } else if (response.status === 429) {
- const headerRetry = parseInt(response.headers.get('retry-after') ?? '', 10);
- err.code = 'rate_limited';
- err.retryAfter =
- body?.retryAfter ?? (Number.isFinite(headerRetry) && headerRetry > 0 ? headerRetry : 30);
- err.scope = body?.scope;
- console.warn('[rate_limited 429]', {
- retryAfter: err.retryAfter,
- scope: err.scope,
- retryAfterHeader: response.headers.get('retry-after'),
- body,
- });
} else if (activeSchema.length > 0 && /no endpoints?\s+(?:found|available)\s+that support tool/i.test(msg)) {
err.code = 'tools_unsupported';
err.modelId = model.id;