diff --git a/apps/insights/src/prompts.ts b/apps/insights/src/prompts.ts index 23d1a3458..e243cdd61 100644 --- a/apps/insights/src/prompts.ts +++ b/apps/insights/src/prompts.ts @@ -96,13 +96,11 @@ export async function fetchInsightHistory( .select({ title: analyticsInsights.title, description: analyticsInsights.description, - type: analyticsInsights.type, severity: analyticsInsights.severity, rootCause: analyticsInsights.rootCause, changePercent: analyticsInsights.changePercent, subjectKey: analyticsInsights.subjectKey, createdAt: analyticsInsights.createdAt, - runId: analyticsInsights.runId, }) .from(analyticsInsights) .where( @@ -113,7 +111,7 @@ export async function fetchInsightHistory( ) ) .orderBy(desc(analyticsInsights.createdAt)) - .limit(RECENT_INSIGHTS_PROMPT_LIMIT); + .limit(50); if (rows.length === 0) { return ""; @@ -121,22 +119,24 @@ export async function fetchInsightHistory( const subjectCounts = new Map(); for (const row of rows) { - subjectCounts.set( - row.subjectKey, - (subjectCounts.get(row.subjectKey) ?? 0) + 1 - ); + const key = row.subjectKey || row.title; + subjectCounts.set(key, (subjectCounts.get(key) ?? 0) + 1); } const seen = new Set(); const lines: string[] = []; for (const row of rows) { - if (seen.has(row.subjectKey)) { + if (lines.length >= RECENT_INSIGHTS_PROMPT_LIMIT) { + break; + } + const key = row.subjectKey || row.title; + if (seen.has(key)) { continue; } - seen.add(row.subjectKey); + seen.add(key); const date = dayjs(row.createdAt).format("YYYY-MM-DD"); - const recurrence = subjectCounts.get(row.subjectKey) ?? 1; + const recurrence = subjectCounts.get(key) ?? 1; const recurring = recurrence > 1 ? ` (reported ${recurrence}x)` : ""; const change = row.changePercent === null diff --git a/packages/evals/ui/index.html b/packages/evals/ui/index.html index 38dd3c06a..bdc50fe4c 100644 --- a/packages/evals/ui/index.html +++ b/packages/evals/ui/index.html @@ -794,16 +794,16 @@

Latest model board

const id = escapeHtml(c.id); const cost = (c.metrics?.costUsd || 0) + (c.metrics?.judgeCostUsd || 0); return ` -
${id}
- ${escapeHtml(c.category || "case")} - ${c.passed ? "Pass" : "Fail"} - ${c.scores?.tool_routing ?? "--"} - ${c.scores?.quality ?? "--"} - ${((c.metrics?.latencyMs || 0) / 1000).toFixed(1)}s - ${c.metrics?.steps ?? "--"} - ${money(cost)} - -
${detail(c)}
`; +
${id}
+ ${escapeHtml(c.category || "case")} + ${c.passed ? "Pass" : "Fail"} + ${c.scores?.tool_routing ?? "--"} + ${c.scores?.quality ?? "--"} + ${((c.metrics?.latencyMs || 0) / 1000).toFixed(1)}s + ${c.metrics?.steps ?? "--"} + ${money(cost)} + +
${detail(c)}
`; } function detail(c) { @@ -815,7 +815,7 @@

Latest model board

.map((t) => `${escapeHtml(t)}`) .join("") || 'No tools called'; return `

Response

${escapeHtml(c.response || "No response captured.")}
-

Failures

    ${failures}

Tools

${tools}
`; +

Failures

    ${failures}

Tools

${tools}
`; } function toggle(id) {