mirror of
https://github.com/garrytan/gstack.git
synced 2026-09-15 01:15:29 +02:00
* fix: default cross-model workflows to frontier models * chore: bump version and changelog (v1.82.1.0) Co-Authored-By: OpenAI Codex <noreply@openai.com> * fix: repair frontier eval budgets and workflow instructions Preserve frontier models and quality thresholds while fixing truncated judge output, ordered section expansion, consent checks, QA scoring, and ship audit gates. Add regression coverage and refresh generated docs. Co-Authored-By: OpenAI Codex <noreply@openai.com> * fix: resolve workflow gaps exposed by frontier evals Clarify plan-review ordering and fallback modes, preserve deploy readiness gates, honor configured merge methods, correct benchmark and canary contracts, and restore vendored installs on setup failure. Cover recovery with real-shell regressions. Co-Authored-By: OpenAI Codex <noreply@openai.com> * fix: use agent capture budgets for deploy evals Multi-turn deploy and benchmark sessions were incorrectly limited to the single-call judge timeout. Use the existing capture tier and leave outer-test cleanup headroom, with a free policy regression test. Keep all behavioral assertions and frontier models unchanged. Co-Authored-By: OpenAI Codex <noreply@openai.com> * fix: clarify retro workflow and evaluate compare instructions Include compare mode in the frontier judge excerpt, define metric sources and snapshot ordering, and preserve the existing prompt-size budget. Co-authored-by: OpenAI Codex <noreply@openai.com> * fix: make documentation release review and publication consistent Review before commit, clarify changelog safeguards and unavailable reviewer modes, and preserve raw PR bodies across separate shell calls. Keep title sync in one shell and add regression coverage. Co-authored-by: OpenAI Codex <noreply@openai.com> --------- Co-authored-by: OpenAI Codex <noreply@openai.com>
103 lines
3.9 KiB
TypeScript
103 lines
3.9 KiB
TypeScript
/**
|
|
* Benchmark quality judge — wraps llm-judge.ts for multi-provider scoring.
|
|
*
|
|
* The judge uses the shared frontier Claude eval default. It sees
|
|
* the prompt + N provider outputs and scores each on: correctness, completeness,
|
|
* code quality, edge case handling. 0-10 per dimension; overall = average.
|
|
*
|
|
* Judge adds ~$0.05 per benchmark run. Gated by --judge CLI flag.
|
|
*/
|
|
|
|
import type { BenchmarkReport, BenchmarkEntry } from './benchmark-runner';
|
|
import { resolveEvalModel } from '../../lib/eval-model';
|
|
|
|
export async function judgeEntries(report: BenchmarkReport): Promise<void> {
|
|
if (!process.env.ANTHROPIC_API_KEY) {
|
|
throw new Error('ANTHROPIC_API_KEY not set — judge requires Anthropic access.');
|
|
}
|
|
const { default: Anthropic } = await import('@anthropic-ai/sdk').catch(() => {
|
|
throw new Error('@anthropic-ai/sdk not installed — run `bun add @anthropic-ai/sdk` if you want the judge.');
|
|
});
|
|
const client = new (Anthropic as unknown as new (opts: { apiKey: string }) => {
|
|
messages: { create: (params: Record<string, unknown>) => Promise<{ content: Array<{ type: string; text: string }> }> };
|
|
})({ apiKey: process.env.ANTHROPIC_API_KEY! });
|
|
|
|
const successful = report.entries.filter(e => e.available && e.result && !e.result.error);
|
|
if (successful.length === 0) return;
|
|
|
|
const judgePrompt = buildJudgePrompt(report.prompt, successful);
|
|
const msg = await client.messages.create({
|
|
model: resolveEvalModel('judge'),
|
|
max_tokens: 2048,
|
|
messages: [{ role: 'user', content: judgePrompt }],
|
|
});
|
|
const textBlock = msg.content.find(c => c.type === 'text');
|
|
if (!textBlock) return;
|
|
|
|
const scores = parseScores(textBlock.text, successful.length);
|
|
for (let i = 0; i < successful.length; i++) {
|
|
const s = scores[i];
|
|
if (!s) continue;
|
|
successful[i].qualityScore = s.overall;
|
|
successful[i].qualityDetails = s.dimensions;
|
|
}
|
|
}
|
|
|
|
function buildJudgePrompt(prompt: string, entries: BenchmarkEntry[]): string {
|
|
const lines: string[] = [
|
|
'You are a strict, fair technical reviewer scoring N model outputs against the same prompt.',
|
|
'',
|
|
'--- PROMPT ---',
|
|
prompt.length > 4000 ? prompt.slice(0, 4000) + '\n[...truncated for judge budget...]' : prompt,
|
|
'',
|
|
'--- OUTPUTS ---',
|
|
];
|
|
entries.forEach((e, i) => {
|
|
const r = e.result!;
|
|
const out = r.output.length > 3000 ? r.output.slice(0, 3000) + '\n[...truncated...]' : r.output;
|
|
lines.push(`=== Output ${i + 1}: ${r.modelUsed} ===`);
|
|
lines.push(out);
|
|
lines.push('');
|
|
});
|
|
lines.push('');
|
|
lines.push('Score each output on these dimensions (0-10 per dimension):');
|
|
lines.push(' - correctness: does it solve what the prompt asked?');
|
|
lines.push(' - completeness: are edge cases and error paths addressed?');
|
|
lines.push(' - code_quality: naming, structure, explicitness');
|
|
lines.push(' - edge_cases: handling of nil/empty/invalid input');
|
|
lines.push('');
|
|
lines.push('Return JSON only, in this exact shape:');
|
|
lines.push('{"scores":[');
|
|
lines.push(' {"output":1,"correctness":N,"completeness":N,"code_quality":N,"edge_cases":N,"overall":N,"notes":"..."},');
|
|
lines.push(' ...');
|
|
lines.push(']}');
|
|
lines.push('');
|
|
lines.push('overall = rounded average of the 4 dimensions. No other commentary.');
|
|
return lines.join('\n');
|
|
}
|
|
|
|
interface ParsedScore {
|
|
overall: number;
|
|
dimensions: Record<string, number>;
|
|
}
|
|
|
|
function parseScores(raw: string, expectedCount: number): ParsedScore[] {
|
|
const match = raw.match(/\{[\s\S]*\}/);
|
|
if (!match) return [];
|
|
try {
|
|
const obj = JSON.parse(match[0]);
|
|
if (!Array.isArray(obj.scores)) return [];
|
|
return obj.scores.slice(0, expectedCount).map((s: Record<string, number>) => ({
|
|
overall: Number(s.overall ?? 0),
|
|
dimensions: {
|
|
correctness: Number(s.correctness ?? 0),
|
|
completeness: Number(s.completeness ?? 0),
|
|
code_quality: Number(s.code_quality ?? 0),
|
|
edge_cases: Number(s.edge_cases ?? 0),
|
|
},
|
|
}));
|
|
} catch {
|
|
return [];
|
|
}
|
|
}
|