profileShare

rasmusjy / roundtable

Read-only snapshot

No repository description.

main default branch 181 files Expires Sep 13, 2026, 9:06 AM
convergence.ts 1,965 bytes
1 import type { AnonymizedPeer } from '../anonymize';
2 import type { LlmMessage } from '../llm-client';
3 import { jsonInstruction, ROUNDTABLE_PREAMBLE } from './index';
4
5 const CONVERGENCE_SHAPE = `{
6 "score": 72, // 0-100: how substantively converged the answers are
7 "disagreements": [
8 {
9 "topic": "short label for the contested point",
10 "summary": "what the disagreement is about",
11 "positions": [
12 { "label": "A", "stance": "what response A holds on this point" },
13 { "label": "C", "stance": "what response C holds on this point" }
14 ]
15 }
16 ]
17 }`;
18
19 /**
20 * Convergence check (runs after each round, on a cheap/fast model).
21 *
22 * Judges *substantive* agreement, not surface wording: two answers that reach the
23 * same conclusion by different phrasing are converged; two that share boilerplate
24 * but differ on the key claim are not. Returns a 0-100 score plus the concrete
25 * points still in dispute, which feed both the early-stop decision and the
26 * chairman's dissent report.
27 */
28 export function buildConvergencePrompt(question: string, answers: AnonymizedPeer[]): LlmMessage[] {
29 const block = answers.map((a) => `--- Response ${a.label} ---\n${a.content}`).join('\n\n');
30
31 return [
32 {
33 role: 'system',
34 content:
35 `${ROUNDTABLE_PREAMBLE}\n\n` +
36 'You are the neutral convergence assessor. Read the current answers and judge ' +
37 'how much they substantively agree on the points that matter for the question. ' +
38 'Ignore stylistic differences. A score of 100 means they would give the reader ' +
39 'the same practical conclusion; a low score means they still disagree on ' +
40 'substance. List every material remaining disagreement.\n\n' +
41 jsonInstruction(CONVERGENCE_SHAPE),
42 },
43 {
44 role: 'user',
45 content: `Question:\n${question}\n\nCurrent answers:\n\n${block}\n\nReturn your JSON assessment now.`,
46 },
47 ];
48 }
49