Skip to content

Never stop coding. Free MIT AI gateway: one endpoint, 375 providers (150+ free), 1,400+ models Kimi, Claude, GPT, Gemini, GLM, DeepSeek, MiniMax. Works with Claude Code, Codex, Cursor, OpenCode, Cline & Copilot. Quota-aware auto-fallback, RTK+Caveman compression saves 15-95% tokens, MCP/A2A, Desktop/PWA. Built by 900+ contributors

1.3 KB
Raw Blame
// ABOUTME: buildJudgePrompt must license the judge to use its own knowledge and override
// ABOUTME: the panel — not just synthesize within it — while still embedding panel responses.
import test from "node:test";
import assert from "node:assert/strict";

import { buildJudgePrompt } from "../../open-sse/services/fusion.ts";

test("judge prompt embeds all panel answers, anonymized by source", () => {
  const prompt = buildJudgePrompt([
    { text: "answer-alpha" },
    { text: "answer-beta" },
  ]);
  assert.match(prompt, /\[Source 1\]/);
  assert.match(prompt, /\[Source 2\]/);
  assert.match(prompt, /answer-alpha/);
  assert.match(prompt, /answer-beta/);
  assert.match(prompt, /2 expert models/);
});

test("judge is licensed to use its own intelligence and override the panel", () => {
  const prompt = buildJudgePrompt([{ text: "x" }]);
  // Must NOT cap the judge at panel content ("grounded in that analysis" was the old ceiling).
  assert.doesNotMatch(prompt, /grounded in that analysis/);
  // Must explicitly grant own-reasoning + override authority.
  assert.match(prompt, /OWN reasoning and knowledge/);
  assert.match(prompt, /override/i);
  assert.match(prompt, /not a vote-counter/i);
  // Must keep the honesty guard so it doesn't fabricate.
  assert.match(prompt, /not confident about/i);
});