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.

Sniper judgment ledger: every LLM verdict persisted and scored against coin outcomes

nirholascef872768411
diff --git a/api/_lib/migrations/20260719160000_sniper_llm_verdicts.sql b/api/_lib/migrations/20260719160000_sniper_llm_verdicts.sql
new file mode 100644
index 000000000..837e25d02
--- /dev/null
+++ b/api/_lib/migrations/20260719160000_sniper_llm_verdicts.sql
@@ -0,0 +1,28 @@
+-- LLM judgment ledger for the sniper experiment fleet.
+--
+-- Every verdict an LLM arm renders on a launch is persisted, buys AND skips,
+-- so each model's judgment can be scored against what the coin actually did
+-- (pump_coin_outcomes) even while the fleet trades tiny sizes or runs in
+-- simulate mode. Trades measure execution; this ledger measures judgment,
+-- including the counterfactuals ("the coins it passed on that later pumped").
+--
+-- One row per (mint, model): agents sharing a model share one verdict call, so
+-- the ledger mirrors that dedupe. Written fire-and-forget by
+-- workers/agent-sniper/llm-judge.js; read by /api/sniper/experiments.
+--
+-- Additive and idempotent, safe to re-run.
+CREATE TABLE IF NOT EXISTS sniper_llm_verdicts (
+ mint TEXT NOT NULL,
+ network TEXT NOT NULL DEFAULT 'mainnet',
+ model TEXT NOT NULL,
+ buy BOOLEAN NOT NULL,
+ confidence NUMERIC NOT NULL,
+ thesis TEXT,
+ latency_ms INTEGER,
+ answered_by TEXT,
+ created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
+ PRIMARY KEY (mint, network, model)
+);
+
+CREATE INDEX IF NOT EXISTS sniper_llm_verdicts_model_time
+ ON sniper_llm_verdicts (network, model, created_at DESC);
diff --git a/api/sniper/experiments.js b/api/sniper/experiments.js
index 97168607a..a7f13365e 100644
--- a/api/sniper/experiments.js
+++ b/api/sniper/experiments.js
@@ -138,10 +138,58 @@ export default wrap(async (req, res) => {
};
});
+ // Judgment ledger: every LLM verdict (buys AND skips) scored against what the
+ // coin actually did. This measures a model's CALLS, independent of trade size
+ // or simulate mode; `scored` counts verdicts whose coin has an outcome label
+ // (pump_coin_outcomes lags launches by an hour by design). A "hit" for a buy
+ // call, and a "missed winner" for a skip, is a coin that pumped 3x or
+ // graduated after the verdict.
+ const judgment = await sql`
+ select
+ v.model,
+ count(*) as verdicts,
+ count(*) filter (where v.buy) as buy_calls,
+ avg(v.confidence) as avg_confidence,
+ avg(v.latency_ms) as avg_latency_ms,
+ count(o.mint) as scored,
+ count(*) filter (where v.buy and o.mint is not null) as buys_scored,
+ count(*) filter (where v.buy and o.outcome in ('pumped','graduated')) as buy_hits,
+ count(*) filter (where not v.buy and o.mint is not null) as skips_scored,
+ count(*) filter (where not v.buy and o.outcome in ('pumped','graduated')) as missed_winners,
+ max(v.created_at) as last_verdict_at
+ from sniper_llm_verdicts v
+ left join pump_coin_outcomes o on o.mint = v.mint
+ where v.network = ${network}
+ and (${interval}::text is null or v.created_at > now() - (${interval}::text)::interval)
+ group by v.model
+ order by verdicts desc
+ `.catch(() => []);
+
+ const judgmentOut = judgment.map((j) => {
+ const buysScored = Number(j.buys_scored) || 0;
+ const skipsScored = Number(j.skips_scored) || 0;
+ return {
+ model: j.model,
+ verdicts: Number(j.verdicts) || 0,
+ buy_calls: Number(j.buy_calls) || 0,
+ avg_confidence: j.avg_confidence != null ? Number(Number(j.avg_confidence).toFixed(3)) : null,
+ avg_latency_ms: j.avg_latency_ms != null ? Math.round(Number(j.avg_latency_ms)) : null,
+ scored: Number(j.scored) || 0,
+ buys_scored: buysScored,
+ buy_hits: Number(j.buy_hits) || 0,
+ buy_precision_pct: buysScored > 0 ? Math.round((Number(j.buy_hits) / buysScored) * 100) : null,
+ skips_scored: skipsScored,
+ missed_winners: Number(j.missed_winners) || 0,
+ missed_winner_pct: skipsScored > 0 ? Math.round((Number(j.missed_winners) / skipsScored) * 100) : null,
+ last_verdict_at: j.last_verdict_at || null,
+ };
+ });
+
return json(res, 200, {
network,
window,
experiments,
+ judgment: judgmentOut,
t: Date.now(),
}, { 'cache-control': 'public, max-age=15, s-maxage=30' });
});
diff --git a/pages/sniper-experiments.html b/pages/sniper-experiments.html
index 0fdf0fbdf..7e9e29136 100644
--- a/pages/sniper-experiments.html
+++ b/pages/sniper-experiments.html
@@ -85,6 +85,9 @@
<!-- The comparison board. Hydrated by src/sniper-experiments.js. -->
<section id="xp-board" class="cv-section" aria-label="Strategy comparison"></section>
+ <!-- LLM judgment ledger: verdicts scored against real coin outcomes. -->
+ <section id="xp-judgment" class="cv-section" aria-label="LLM judgment ledger"></section>
+
<p class="cv-updated" id="xp-updated"></p>
</main>
diff --git a/src/sniper-experiments.js b/src/sniper-experiments.js
index 9ec7bad59..c17950261 100644
--- a/src/sniper-experiments.js
+++ b/src/sniper-experiments.js
@@ -150,11 +150,51 @@ function renderBoard(experiments) {
</div>`;
}
+function renderJudgment(judgment) {
+ const el = $('xp-judgment');
+ if (!el) return;
+ if (!judgment || !judgment.length) {
+ el.innerHTML = '';
+ return;
+ }
+ const rows = judgment
+ .map((j) => `
+ <tr>
+ <td class="xp-label">${esc(j.model.split('/').pop())}<div class="xp-cond-sub">${esc(j.model)}</div></td>
+ <td>${j.verdicts}</td>
+ <td>${j.verdicts > 0 ? Math.round((j.buy_calls / j.verdicts) * 100) + '%' : '·'} <span class="xp-cond-sub" style="display:inline">(${j.buy_calls})</span></td>
+ <td>${j.avg_confidence != null ? Math.round(j.avg_confidence * 100) + '%' : '·'}</td>
+ <td class="${j.buy_precision_pct != null ? (j.buy_precision_pct >= 50 ? 'xp-pos' : 'xp-neg') : ''}">${j.buy_precision_pct != null ? j.buy_precision_pct + '%' : 'awaiting outcomes'} <span class="xp-cond-sub" style="display:inline">${j.buys_scored ? `(${j.buy_hits}/${j.buys_scored})` : ''}</span></td>
+ <td>${j.missed_winner_pct != null ? j.missed_winner_pct + '%' : '·'} <span class="xp-cond-sub" style="display:inline">${j.skips_scored ? `(${j.missed_winners}/${j.skips_scored})` : ''}</span></td>
+ <td>${j.avg_latency_ms != null ? (j.avg_latency_ms / 1000).toFixed(1) + 's' : '·'}</td>
+ </tr>`)
+ .join('');
+ el.innerHTML = `
+ <h2 class="cv-h2">Judgment ledger</h2>
+ <p style="margin:4px 0 12px;color:var(--cv-text-3);font-size:13px">
+ Every verdict the LLM judges render is recorded, buys and skips alike, then scored
+ against what the coin actually did an hour later. This measures each model's calls
+ independent of position size: a "hit" is a coin that pumped 3x or graduated.
+ </p>
+ <div class="cv-card" style="overflow-x:auto">
+ <table class="cv-table xp-table" style="min-width:720px">
+ <thead>
+ <tr>
+ <th>Model</th><th>Verdicts</th><th>Buy rate</th><th>Avg conf</th>
+ <th>Buy precision</th><th>Missed winners</th><th>Latency</th>
+ </tr>
+ </thead>
+ <tbody>${rows}</tbody>
+ </table>
+ </div>`;
+}
+
async function refresh() {
try {
const data = await getJson(`/api/sniper/experiments?network=mainnet&window=${encodeURIComponent(windowKey)}`);
renderSummary(data.experiments);
renderBoard(data.experiments);
+ renderJudgment(data.judgment);
$('xp-updated').textContent = `Updated ${new Date(data.t).toLocaleTimeString()} · real on-chain fills only`;
} catch (err) {
$('xp-board').innerHTML = `
diff --git a/workers/agent-sniper/README.md b/workers/agent-sniper/README.md
index fab6922d3..8b742991e 100644
--- a/workers/agent-sniper/README.md
+++ b/workers/agent-sniper/README.md
@@ -118,6 +118,13 @@ on a coin younger than `SNIPER_ORACLE_MATURITY_S` (default 900 s) is treated as
on thin data, which used to disqualify every `min_oracle_score` strategy from
ever sniping a launch.
+**Judgment ledger.** Every LLM verdict, buys AND skips, is persisted to
+`sniper_llm_verdicts` (one row per mint+model; fire-and-forget) and scored
+against `pump_coin_outcomes` an hour later: buy precision (advised buys that
+pumped 3x or graduated) and missed winners (advised skips that did). This
+measures each model's calls independent of position size or simulate mode; the
+scoreboard renders it as the "Judgment ledger" section on /sniper/experiments.
+
## Environment
| Var | Required | Default | Notes |
diff --git a/workers/agent-sniper/llm-judge.js b/workers/agent-sniper/llm-judge.js
index 7327f4f74..8cf8cb71f 100644
--- a/workers/agent-sniper/llm-judge.js
+++ b/workers/agent-sniper/llm-judge.js
@@ -18,6 +18,7 @@
// the verdict is tagged with the model that actually answered.
import { log } from './log.js';
+import { sql } from '../../api/_lib/db.js';
import { llmComplete } from '../../api/_lib/llm.js';
const OPENROUTER_URL = 'https://openrouter.ai/api/v1/chat/completions';
@@ -119,7 +120,7 @@ async function judge(mint, model) {
try {
const text = await askOpenRouter({ model, user });
const verdict = parseVerdict(text);
- if (verdict) return { ...verdict, model, latencyMs: Date.now() - t0 };
+ if (verdict) return { ...verdict, model, answeredBy: model, latencyMs: Date.now() - t0 };
throw new Error('unparseable verdict');
} catch (err) {
// Free-first platform chain as the backstop, the experiment arm keeps
@@ -128,10 +129,24 @@ async function judge(mint, model) {
const res = await llmComplete({ system: SYSTEM_PROMPT, user, maxTokens: 200, timeoutMs: TIMEOUT_MS });
const verdict = parseVerdict(res?.text ?? res);
if (!verdict) return null;
- return { ...verdict, model: `fallback:${res?.provider || 'free-chain'}`, latencyMs: Date.now() - t0 };
+ return { ...verdict, model: `fallback:${res?.provider || 'free-chain'}`, answeredBy: res?.model || res?.provider || 'free-chain', latencyMs: Date.now() - t0 };
}
}
+// Persist a verdict into the judgment ledger, buys AND skips, so each model's
+// calls can later be scored against pump_coin_outcomes (the counterfactuals a
+// trade record can't capture). Fire-and-forget: a ledger hiccup never delays
+// or blocks the buy path. Keyed by the REQUESTED model (the experiment arm's
+// identity); answered_by records who actually replied when the chain fell back.
+function recordVerdict({ mint, network, requestedModel, verdict }) {
+ sql`
+ insert into sniper_llm_verdicts (mint, network, model, buy, confidence, thesis, latency_ms, answered_by)
+ values (${mint}, ${network}, ${requestedModel}, ${verdict.buy}, ${verdict.confidence},
+ ${verdict.thesis || null}, ${verdict.latencyMs ?? null}, ${verdict.answeredBy || null})
+ on conflict (mint, network, model) do nothing
+ `.catch((err) => log.warn('llm verdict record failed', { mint, model: requestedModel, err: err?.message }));
+}
+
/**
* Judge one launch for one strategy. Returns a verdict
* `{ buy, confidence, thesis, model, latencyMs }` or null (saturated / failed,
@@ -150,6 +165,10 @@ export async function judgeLaunch(mint, strat) {
}
_active++;
const promise = judge(mint, model)
+ .then((verdict) => {
+ if (verdict) recordVerdict({ mint: mint.mint, network: strat.network || 'mainnet', requestedModel: model, verdict });
+ return verdict;
+ })
.catch((err) => {
log.warn('llm judge failed', { mint: mint.mint, model, err: err?.message });
return null;