@tagma/completion-llm-judge 0.2.6 → 0.2.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +5 -6
- package/src/index.test.ts +0 -16
- package/src/index.ts +0 -279
package/dist/index.js
CHANGED
|
@@ -202,7 +202,7 @@ export const LlmJudgeCompletion = {
|
|
|
202
202
|
try {
|
|
203
203
|
const content = await callJudge(endpoint, model, apiKey, messages, timeoutMs, ctx.signal);
|
|
204
204
|
const firstLine = (content.split(/\r?\n/, 1)[0] ?? '').trim().toUpperCase();
|
|
205
|
-
const passed = firstLine
|
|
205
|
+
const passed = firstLine === 'PASS';
|
|
206
206
|
if (!passed) {
|
|
207
207
|
// Surface the judge's reasoning in logs so pipeline operators can
|
|
208
208
|
// see why an output was rejected without re-running it themselves.
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,EAAE;AACF,0EAA0E;AAC1E,2EAA2E;AAC3E,2EAA2E;AAC3E,wEAAwE;AACxE,uCAAuC;AACvC,EAAE;AACF,2EAA2E;AAC3E,uEAAuE;AACvE,qEAAqE;AACrE,uEAAuE;AACvE,sCAAsC;AACtC,EAAE;AACF,2EAA2E;AAC3E,wEAAwE;AACxE,uEAAuE;AACvE,8DAA8D;AAC9D,EAAE;AACF,0BAA0B;AAC1B,6CAA6C;AAC7C,YAAY;AACZ,eAAe;AACf,sBAAsB;AACtB,wBAAwB;AACxB,8BAA8B;AAC9B,mFAAmF;AACnF,sFAAsF;AAEtF,OAAO,EACL,iBAAiB,GAKlB,MAAM,cAAc,CAAC;AAEtB,2EAA2E;AAC3E,wEAAwE;AACxE,sEAAsE;AACtE,MAAM,gBAAgB,GAAG,4CAA4C,CAAC;AACtE,0EAA0E;AAC1E,oEAAoE;A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M,CAAC,GAAG,CAAC,CAAC;YAC7D,OAAO,CAAC,IAAI,CAAC,gEAAgE,GAAG,EAAE,CAAC,CAAC;YACpF,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;CACF,CAAC;AAEF,eAAe;IACb,IAAI,EAAE,6BAA6B;IACnC,YAAY,EAAE;QACZ,WAAW,EAAE;YACX,SAAS,EAAE,kBAAkB;SAC9B;KACF;CACoB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tagma/completion-llm-judge",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.7",
|
|
4
4
|
"description": "LLM-as-judge completion plugin for tagma-sdk pipelines",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -23,8 +23,7 @@
|
|
|
23
23
|
"./package.json": "./package.json"
|
|
24
24
|
},
|
|
25
25
|
"files": [
|
|
26
|
-
"dist"
|
|
27
|
-
"src"
|
|
26
|
+
"dist"
|
|
28
27
|
],
|
|
29
28
|
"publishConfig": {
|
|
30
29
|
"access": "public"
|
|
@@ -45,11 +44,11 @@
|
|
|
45
44
|
"type": "llm_judge"
|
|
46
45
|
},
|
|
47
46
|
"scripts": {
|
|
48
|
-
"build": "
|
|
47
|
+
"build": "node ../../scripts/build-package.mjs",
|
|
49
48
|
"test": "bun test",
|
|
50
49
|
"prepublishOnly": "bun run build"
|
|
51
50
|
},
|
|
52
|
-
"
|
|
53
|
-
"@tagma/types": "0.4.
|
|
51
|
+
"dependencies": {
|
|
52
|
+
"@tagma/types": "0.4.13"
|
|
54
53
|
}
|
|
55
54
|
}
|
package/src/index.test.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { describe, expect, test } from 'bun:test';
|
|
2
|
-
import plugin, { LlmJudgeCompletion } from './index';
|
|
3
|
-
import manifest from '../package.json' with { type: 'json' };
|
|
4
|
-
|
|
5
|
-
describe('completion-llm-judge plugin shape', () => {
|
|
6
|
-
test('default export is a capability plugin matching package manifest', () => {
|
|
7
|
-
expect(manifest.tagmaPlugin.category).toBe('completions');
|
|
8
|
-
expect(manifest.tagmaPlugin.type).toBe('llm_judge');
|
|
9
|
-
expect(plugin.name).toBe(manifest.name);
|
|
10
|
-
expect(plugin.capabilities?.completions?.[manifest.tagmaPlugin.type]).toBe(LlmJudgeCompletion);
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
test('check is a function', () => {
|
|
14
|
-
expect(typeof plugin.capabilities!.completions!.llm_judge.check).toBe('function');
|
|
15
|
-
});
|
|
16
|
-
});
|
package/src/index.ts
DELETED
|
@@ -1,279 +0,0 @@
|
|
|
1
|
-
// ═══ LLM-as-Judge Completion Plugin ═══
|
|
2
|
-
//
|
|
3
|
-
// Uses an OpenAI-compatible chat completions endpoint to verify whether a
|
|
4
|
-
// task's output satisfies a rubric. Complements the deterministic built-in
|
|
5
|
-
// completions (`exit_code`, `file_exists`, `output_check`) with AI-powered
|
|
6
|
-
// checks — useful when success is defined semantically rather than by a
|
|
7
|
-
// grep-able pattern or a file on disk.
|
|
8
|
-
//
|
|
9
|
-
// Default backend is a **local Ollama** server using its OpenAI-compatible
|
|
10
|
-
// route (`/v1/chat/completions`, available since Ollama 0.1.29+), with
|
|
11
|
-
// `qwen3:4b` as a small, cheap-to-run reasoning model. No API key is
|
|
12
|
-
// required for local Ollama; remote endpoints can set `api_key_env` to
|
|
13
|
-
// whatever header the server expects.
|
|
14
|
-
//
|
|
15
|
-
// The judge is instructed to answer PASS/FAIL on the first line. Reasoning
|
|
16
|
-
// models (qwen3, deepseek-r1, etc.) emit `<think>...</think>` blocks in
|
|
17
|
-
// their message content — we strip those before parsing, so the rubric
|
|
18
|
-
// works the same whether the judge model is a thinker or not.
|
|
19
|
-
//
|
|
20
|
-
// Usage in pipeline.yaml:
|
|
21
|
-
// plugins: ["@tagma/completion-llm-judge"]
|
|
22
|
-
// tracks:
|
|
23
|
-
// - tasks:
|
|
24
|
-
// - id: draft
|
|
25
|
-
// completion:
|
|
26
|
-
// type: llm_judge
|
|
27
|
-
// rubric: "Output must list at least 3 failing tests with file paths."
|
|
28
|
-
// # endpoint / model / api_key_env all default to local Ollama + qwen3:4b
|
|
29
|
-
|
|
30
|
-
import {
|
|
31
|
-
parseDurationSafe,
|
|
32
|
-
type TagmaPlugin,
|
|
33
|
-
type CompletionPlugin,
|
|
34
|
-
type CompletionContext,
|
|
35
|
-
type TaskResult,
|
|
36
|
-
} from '@tagma/types';
|
|
37
|
-
|
|
38
|
-
// Ollama exposes an OpenAI-compatible `/v1/chat/completions` route on port
|
|
39
|
-
// 11434 by default. Point this at any OpenAI-compatible server (OpenAI,
|
|
40
|
-
// vLLM, llama.cpp, LM Studio, Groq, Together, etc.) to swap backends.
|
|
41
|
-
const DEFAULT_ENDPOINT = 'http://localhost:11434/v1/chat/completions';
|
|
42
|
-
// qwen3:4b is a small reasoning model (~2.5 GB on disk, runs on CPU) that
|
|
43
|
-
// reliably follows the PASS/FAIL-on-first-line instruction. Swap to
|
|
44
|
-
// `qwen3:8b`, `deepseek-r1:7b`, or a hosted model for stricter judging.
|
|
45
|
-
const DEFAULT_MODEL = 'qwen3:4b';
|
|
46
|
-
const DEFAULT_TIMEOUT_MS = 120_000;
|
|
47
|
-
const DEFAULT_MAX_OUTPUT_CHARS = 8_000;
|
|
48
|
-
|
|
49
|
-
const SYSTEM_PROMPT =
|
|
50
|
-
'You are a strict quality judge for task outputs.\n' +
|
|
51
|
-
'Given the task rubric and actual output, answer on the FIRST LINE with exactly "PASS" or "FAIL".\n' +
|
|
52
|
-
'On subsequent lines you may provide a one-sentence justification.\n' +
|
|
53
|
-
'Do not use any other format. Do not wrap the answer in code fences.\n' +
|
|
54
|
-
'If you reason step-by-step internally, still put PASS or FAIL on the first line of your final answer.';
|
|
55
|
-
|
|
56
|
-
interface ChatMessage {
|
|
57
|
-
readonly role: 'system' | 'user';
|
|
58
|
-
readonly content: string;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
interface ChatCompletionResponse {
|
|
62
|
-
readonly choices?: ReadonlyArray<{
|
|
63
|
-
readonly message?: { readonly content?: string };
|
|
64
|
-
}>;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
// Head-and-tail truncation preserves the start of the output (where agents
|
|
68
|
-
// usually declare intent) and the end (where they summarize results),
|
|
69
|
-
// dropping the middle when the combined length exceeds the budget. This
|
|
70
|
-
// keeps the judge's view of the output meaningful even for very long runs.
|
|
71
|
-
function truncateForJudge(text: string, maxChars: number): string {
|
|
72
|
-
if (text.length <= maxChars) return text;
|
|
73
|
-
const marker = '\n...[truncated]...\n';
|
|
74
|
-
const budget = maxChars - marker.length;
|
|
75
|
-
if (budget <= 0) return text.slice(0, maxChars);
|
|
76
|
-
const head = Math.floor(budget * 0.7);
|
|
77
|
-
const tail = budget - head;
|
|
78
|
-
return text.slice(0, head) + marker + text.slice(-tail);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
// Strip reasoning-model thinking blocks so verdict parsing sees the real
|
|
82
|
-
// answer. Qwen3 and DeepSeek-R1 both emit `<think>...</think>` inline in
|
|
83
|
-
// message content when served via Ollama's OpenAI-compat route. We also
|
|
84
|
-
// drop the legacy `<thinking>` variant some fine-tunes use. Applied
|
|
85
|
-
// before any trimming so leading whitespace from the stripped block
|
|
86
|
-
// doesn't leak into the first line.
|
|
87
|
-
function stripThinking(content: string): string {
|
|
88
|
-
return content
|
|
89
|
-
.replace(/<think>[\s\S]*?<\/think>/gi, '')
|
|
90
|
-
.replace(/<thinking>[\s\S]*?<\/thinking>/gi, '')
|
|
91
|
-
.trim();
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
async function callJudge(
|
|
95
|
-
endpoint: string,
|
|
96
|
-
model: string,
|
|
97
|
-
apiKey: string | undefined,
|
|
98
|
-
messages: readonly ChatMessage[],
|
|
99
|
-
timeoutMs: number,
|
|
100
|
-
externalSignal: AbortSignal | undefined,
|
|
101
|
-
): Promise<string> {
|
|
102
|
-
const controller = new AbortController();
|
|
103
|
-
const timer = setTimeout(() => controller.abort(), timeoutMs);
|
|
104
|
-
|
|
105
|
-
const onExternalAbort = (): void => controller.abort();
|
|
106
|
-
if (externalSignal) {
|
|
107
|
-
if (externalSignal.aborted) {
|
|
108
|
-
controller.abort();
|
|
109
|
-
} else {
|
|
110
|
-
externalSignal.addEventListener('abort', onExternalAbort, { once: true });
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
try {
|
|
115
|
-
const headers: Record<string, string> = {
|
|
116
|
-
'content-type': 'application/json',
|
|
117
|
-
};
|
|
118
|
-
// Only send Authorization when we actually have a key — local Ollama
|
|
119
|
-
// doesn't require one, and some OpenAI-compat proxies reject bogus
|
|
120
|
-
// placeholder tokens like "ollama" with 401 instead of ignoring them.
|
|
121
|
-
if (apiKey) {
|
|
122
|
-
headers.authorization = `Bearer ${apiKey}`;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
const res = await fetch(endpoint, {
|
|
126
|
-
method: 'POST',
|
|
127
|
-
headers,
|
|
128
|
-
body: JSON.stringify({
|
|
129
|
-
model,
|
|
130
|
-
messages,
|
|
131
|
-
temperature: 0,
|
|
132
|
-
// `stream: false` is already the default but we set it explicitly
|
|
133
|
-
// because Ollama's OpenAI-compat route streams by default in some
|
|
134
|
-
// older versions.
|
|
135
|
-
stream: false,
|
|
136
|
-
}),
|
|
137
|
-
signal: controller.signal,
|
|
138
|
-
});
|
|
139
|
-
if (!res.ok) {
|
|
140
|
-
const text = await res.text().catch(() => '');
|
|
141
|
-
throw new Error(`judge endpoint ${res.status}: ${text.slice(0, 200)}`);
|
|
142
|
-
}
|
|
143
|
-
const payload = (await res.json()) as ChatCompletionResponse;
|
|
144
|
-
const content = payload.choices?.[0]?.message?.content;
|
|
145
|
-
if (typeof content !== 'string') {
|
|
146
|
-
throw new Error('judge endpoint returned no message content');
|
|
147
|
-
}
|
|
148
|
-
return stripThinking(content);
|
|
149
|
-
} finally {
|
|
150
|
-
clearTimeout(timer);
|
|
151
|
-
if (externalSignal) externalSignal.removeEventListener('abort', onExternalAbort);
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
export const LlmJudgeCompletion: CompletionPlugin = {
|
|
156
|
-
name: 'llm_judge',
|
|
157
|
-
schema: {
|
|
158
|
-
description:
|
|
159
|
-
'Use an LLM to judge whether the task output satisfies a rubric. Answers PASS/FAIL.',
|
|
160
|
-
fields: {
|
|
161
|
-
rubric: {
|
|
162
|
-
type: 'string',
|
|
163
|
-
required: true,
|
|
164
|
-
description: 'Criteria the judge should verify. Plain language.',
|
|
165
|
-
placeholder: 'Output must list at least 3 failing tests with file paths.',
|
|
166
|
-
},
|
|
167
|
-
model: {
|
|
168
|
-
type: 'string',
|
|
169
|
-
default: DEFAULT_MODEL,
|
|
170
|
-
description:
|
|
171
|
-
'Judge model name. Default is a small Ollama reasoning model (qwen3:4b). Swap for qwen3:8b, deepseek-r1:7b, or a hosted model for stricter judging.',
|
|
172
|
-
placeholder: DEFAULT_MODEL,
|
|
173
|
-
},
|
|
174
|
-
endpoint: {
|
|
175
|
-
type: 'string',
|
|
176
|
-
default: DEFAULT_ENDPOINT,
|
|
177
|
-
description:
|
|
178
|
-
'OpenAI-compatible chat completions endpoint. Defaults to local Ollama (http://localhost:11434/v1/chat/completions).',
|
|
179
|
-
placeholder: DEFAULT_ENDPOINT,
|
|
180
|
-
},
|
|
181
|
-
api_key_env: {
|
|
182
|
-
type: 'string',
|
|
183
|
-
description:
|
|
184
|
-
'Env var containing the bearer token for the judge endpoint. Leave unset for local Ollama; set to OPENAI_API_KEY etc. for hosted backends.',
|
|
185
|
-
placeholder: 'OPENAI_API_KEY',
|
|
186
|
-
},
|
|
187
|
-
timeout: {
|
|
188
|
-
type: 'duration',
|
|
189
|
-
default: '120s',
|
|
190
|
-
description:
|
|
191
|
-
'Maximum time to wait for the judge response. Reasoning models need more time than chat models.',
|
|
192
|
-
},
|
|
193
|
-
max_output_chars: {
|
|
194
|
-
type: 'number',
|
|
195
|
-
default: DEFAULT_MAX_OUTPUT_CHARS,
|
|
196
|
-
min: 500,
|
|
197
|
-
max: 200_000,
|
|
198
|
-
description: 'Truncate task stdout to this many chars before judging.',
|
|
199
|
-
},
|
|
200
|
-
},
|
|
201
|
-
},
|
|
202
|
-
|
|
203
|
-
async check(
|
|
204
|
-
config: Record<string, unknown>,
|
|
205
|
-
result: TaskResult,
|
|
206
|
-
ctx: CompletionContext,
|
|
207
|
-
): Promise<boolean> {
|
|
208
|
-
const rubric = config.rubric as string | undefined;
|
|
209
|
-
if (!rubric) throw new Error('llm_judge completion: "rubric" is required');
|
|
210
|
-
|
|
211
|
-
// api_key_env is optional — when unset we talk to the endpoint
|
|
212
|
-
// anonymously (correct for local Ollama). When the user names an env
|
|
213
|
-
// var, we require it to be populated so config errors fail loudly
|
|
214
|
-
// instead of silently stripping auth.
|
|
215
|
-
const apiKeyEnv = config.api_key_env as string | undefined;
|
|
216
|
-
let apiKey: string | undefined;
|
|
217
|
-
if (apiKeyEnv) {
|
|
218
|
-
apiKey = process.env[apiKeyEnv];
|
|
219
|
-
if (!apiKey) {
|
|
220
|
-
throw new Error(`llm_judge completion: env var ${apiKeyEnv} is not set`);
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
const model = (config.model as string | undefined) ?? DEFAULT_MODEL;
|
|
225
|
-
const endpoint = (config.endpoint as string | undefined) ?? DEFAULT_ENDPOINT;
|
|
226
|
-
const timeoutMs = parseDurationSafe(config.timeout, DEFAULT_TIMEOUT_MS);
|
|
227
|
-
const maxChars =
|
|
228
|
-
typeof config.max_output_chars === 'number' && config.max_output_chars > 0
|
|
229
|
-
? Math.floor(config.max_output_chars)
|
|
230
|
-
: DEFAULT_MAX_OUTPUT_CHARS;
|
|
231
|
-
|
|
232
|
-
// Prefer the driver-normalized text (e.g. concatenated message text
|
|
233
|
-
// from AI drivers that emit NDJSON). Feeding raw NDJSON to the judge
|
|
234
|
-
// wastes tokens and obscures the semantic output the judge is meant
|
|
235
|
-
// to grade. Command tasks and drivers without parseResult fall back
|
|
236
|
-
// to raw stdout, which for them IS the semantic output.
|
|
237
|
-
const taskOutput = result.normalizedOutput ?? result.stdout;
|
|
238
|
-
|
|
239
|
-
const userContent =
|
|
240
|
-
`[Rubric]\n${rubric}\n\n` +
|
|
241
|
-
`[Exit Code]\n${result.exitCode}\n\n` +
|
|
242
|
-
`[Task Output]\n${truncateForJudge(taskOutput, maxChars)}`;
|
|
243
|
-
|
|
244
|
-
const messages: ChatMessage[] = [
|
|
245
|
-
{ role: 'system', content: SYSTEM_PROMPT },
|
|
246
|
-
{ role: 'user', content: userContent },
|
|
247
|
-
];
|
|
248
|
-
|
|
249
|
-
try {
|
|
250
|
-
const content = await callJudge(endpoint, model, apiKey, messages, timeoutMs, ctx.signal);
|
|
251
|
-
const firstLine = (content.split(/\r?\n/, 1)[0] ?? '').trim().toUpperCase();
|
|
252
|
-
const passed = firstLine.startsWith('PASS');
|
|
253
|
-
if (!passed) {
|
|
254
|
-
// Surface the judge's reasoning in logs so pipeline operators can
|
|
255
|
-
// see why an output was rejected without re-running it themselves.
|
|
256
|
-
console.warn(
|
|
257
|
-
`[llm_judge] verdict=${firstLine || '<empty>'} — full judge response:\n${content}`,
|
|
258
|
-
);
|
|
259
|
-
}
|
|
260
|
-
return passed;
|
|
261
|
-
} catch (err) {
|
|
262
|
-
// Treat judge failures as FAIL: a completion gate that errors open
|
|
263
|
-
// is worse than one that errors closed. Operators can re-run the
|
|
264
|
-
// task once the judge endpoint is healthy again.
|
|
265
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
266
|
-
console.warn(`[llm_judge] judge call failed, marking task as not-complete: ${msg}`);
|
|
267
|
-
return false;
|
|
268
|
-
}
|
|
269
|
-
},
|
|
270
|
-
};
|
|
271
|
-
|
|
272
|
-
export default {
|
|
273
|
-
name: '@tagma/completion-llm-judge',
|
|
274
|
-
capabilities: {
|
|
275
|
-
completions: {
|
|
276
|
-
llm_judge: LlmJudgeCompletion,
|
|
277
|
-
},
|
|
278
|
-
},
|
|
279
|
-
} satisfies TagmaPlugin;
|