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.
JavaScript 3d-generationai-agentsanimationavatardigital-humangenerative-aiglbgltfimage-to-3dllmmcpmcp-servermodel-context-protocolsolanatext-to-3dthreejsweb-componentswebglwebxrx402
sniper: page ops when the named LLM judges stop answering
nirholas85a6abc0820e
diff --git a/api/_lib/sniper-loops-health.js b/api/_lib/sniper-loops-health.jsindex 32886d72f..ca2dd62aa 100644--- a/api/_lib/sniper-loops-health.js+++ b/api/_lib/sniper-loops-health.js@@ -120,6 +120,31 @@ export function findWalletlessArms(rows) {return out;}+/**+ * Named-model routing health. The July 2026 audit note "the failover chain+ * answering most calls muddied the model-vs-model comparison" turned out to be+ * an OpenRouter account sitting at zero credits for weeks: the key stayed+ * valid, every completion 402'd, the free chain silently absorbed the traffic,+ * and no check anywhere measured it. This one does: given the last hour's+ * verdict counts, alarm when fallbacks answered nearly everything. Pure.+ *+ * @param {{ total:number, fallback:number }} counts verdicts in the window+ * @param {{ minSample?:number, maxShare?:number }} [opts]+ * @returns {{ degraded:boolean, share:number|null, detail:string }}+ */+export function classifyLlmRouting(counts, { minSample = 20, maxShare = 0.9 } = {}) {+ const total = Number(counts?.total) || 0;+ const fallback = Number(counts?.fallback) || 0;+ if (total < minSample) return { degraded: false, share: null, detail: `only ${total} verdicts in window (need ${minSample})` };+ const share = fallback / total;+ return {+ degraded: share >= maxShare,+ share: Number(share.toFixed(3)),+ detail: `${fallback}/${total} verdicts answered by fallback models (${Math.round(share * 100)}%). ` ++ 'The named models are not answering: check OpenRouter credits/keys. Strict arms are paused until this clears; verdicts still record for calibration.',+ };+}+/** Human line for one stale loop, used in the ops alert body. */export function describeStale(entry) {const age = entry.ageMs === Infinitydiff --git a/api/cron/sniper-loops-health.js b/api/cron/sniper-loops-health.jsindex c7909ca12..173bb7674 100644--- a/api/cron/sniper-loops-health.js+++ b/api/cron/sniper-loops-health.js@@ -18,7 +18,7 @@ import { env } from '../_lib/env.js';import { constantTimeEquals } from '../_lib/crypto.js';import { sql } from '../_lib/db.js';import { sendOpsAlert } from '../_lib/alerts.js';-import { LOOPS, classifyLoopHealth, describeStale, findWalletlessArms } from '../_lib/sniper-loops-health.js';+import { LOOPS, classifyLlmRouting, classifyLoopHealth, describeStale, findWalletlessArms } from '../_lib/sniper-loops-health.js';const NETWORK = 'mainnet';@@ -81,6 +81,30 @@ export default wrapCron(async (req, res) => {)).catch(() => {});}+ // Named-model routing: are the arms' named models actually answering, or is+ // the free fallback chain absorbing everything (as it silently did for weeks+ // on a zero-credit OpenRouter account)? answered_by records who really+ // replied; the fallback tag is set by the judge at answer time.+ let routing = { degraded: false, share: null, detail: 'not probed' };+ try {+ const [row] = await sql`+ select count(*)::int as total,+ count(*) filter (where answered_by ilike 'fallback:%' or model ilike 'fallback:%')::int as fallback+ from sniper_llm_verdicts+ where network = ${NETWORK} and created_at > now() - interval '1 hour'+ `;+ routing = classifyLlmRouting(row || {});+ } catch (err) {+ broken.push({ name: 'llm-routing', probeError: err?.message || 'query failed' });+ }+ if (routing.degraded) {+ await Promise.resolve(sendOpsAlert(+ '🎯 agent-sniper — named LLM judges are NOT answering (fallback chain absorbing calls)',+ routing.detail,+ { signature: 'sniper:llm-routing-degraded' },+ )).catch(() => {});+ }+if (stale.length) {// One alert per run covering every stale loop, deduped hourly on a stable// signature so a dead loop pages once an hour until it produces rows again.@@ -100,11 +124,12 @@ export default wrapCron(async (req, res) => {}return json(res, 200, {- ok: stale.length === 0 && broken.length === 0 && zombies.length === 0,+ ok: stale.length === 0 && broken.length === 0 && zombies.length === 0 && !routing.degraded,checked: probes.length,stale: stale.map((s) => ({ name: s.name, last_at: s.lastAt, age_h: s.ageMs === Infinity ? null : Math.round(s.ageMs / 3600_000 * 10) / 10 })),healthy: ok.map((s) => s.name),walletless_arms: zombies.map((z) => z.label),+ llm_routing: routing,probe_errors: broken.map((b) => ({ name: b.name, error: b.probeError })),});});diff --git a/tests/sniper-postmortem-fixes.test.js b/tests/sniper-postmortem-fixes.test.jsindex 96daa4659..275fe4dcc 100644--- a/tests/sniper-postmortem-fixes.test.js+++ b/tests/sniper-postmortem-fixes.test.js@@ -14,7 +14,7 @@import { describe, expect, it } from 'vitest';import { llmVerdictGate } from '../workers/agent-sniper/llm-judge.js';import { decideLiquidityDecay, updateStaleClock } from '../workers/agent-sniper/exit-logic.js';-import { LOOPS, classifyLoopHealth, describeStale, findWalletlessArms } from '../api/_lib/sniper-loops-health.js';+import { LOOPS, classifyLlmRouting, classifyLoopHealth, describeStale, findWalletlessArms } from '../api/_lib/sniper-loops-health.js';describe('llmVerdictGate', () => {const strat = { llm_min_confidence: 0.65, llm_max_confidence: 0.9, llm_strict_model: false };@@ -144,6 +144,35 @@ describe('classifyLoopHealth (count rows, not status codes)', () => {});});+describe('classifyLlmRouting (the zero-credit OpenRouter outage class)', () => {+ it('alarms when fallbacks absorb nearly all verdicts', () => {+ const r = classifyLlmRouting({ total: 100, fallback: 98 });+ expect(r.degraded).toBe(true);+ expect(r.share).toBeCloseTo(0.98);+ expect(r.detail).toMatch(/OpenRouter credits/);+ });++ it('stays quiet on a healthy mix', () => {+ expect(classifyLlmRouting({ total: 100, fallback: 20 }).degraded).toBe(false);+ });++ it('never alarms on a thin sample', () => {+ const r = classifyLlmRouting({ total: 5, fallback: 5 });+ expect(r.degraded).toBe(false);+ expect(r.share).toBe(null);+ });++ it('sits exactly on the 90% line', () => {+ expect(classifyLlmRouting({ total: 100, fallback: 90 }).degraded).toBe(true);+ expect(classifyLlmRouting({ total: 100, fallback: 89 }).degraded).toBe(false);+ });++ it('survives missing input', () => {+ expect(classifyLlmRouting(null).degraded).toBe(false);+ expect(classifyLlmRouting({}).degraded).toBe(false);+ });+});+describe('findWalletlessArms (the oracle-strict zombie class)', () => {const arm = (over) => ({strategy_id: 'S1', label: 'oracle-strict', enabled: true,