@forwardimpact/libeval 0.1.56 → 0.1.58

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.
@@ -10,6 +10,10 @@ import { createLogger } from "@forwardimpact/libtelemetry";
10
10
  import { runBenchmarkRunCommand } from "../src/commands/benchmark-run.js";
11
11
  import { runBenchmarkInvariantsCommand } from "../src/commands/benchmark-invariants.js";
12
12
  import { runBenchmarkReportCommand } from "../src/commands/benchmark-report.js";
13
+ import {
14
+ BENCHMARK_AGENT_MODEL,
15
+ LEAD_MODEL,
16
+ } from "@forwardimpact/libutil/models";
13
17
 
14
18
  export const definition = {
15
19
  name: "fit-benchmark",
@@ -38,17 +42,15 @@ export const definition = {
38
42
  },
39
43
  "agent-model": {
40
44
  type: "string",
41
- description:
42
- "Claude model for the agent-under-test (default: claude-sonnet-4-6)",
45
+ description: `Claude model for the agent-under-test (default: ${BENCHMARK_AGENT_MODEL})`,
43
46
  },
44
47
  "lead-model": {
45
48
  type: "string",
46
- description:
47
- "Claude model for the lead role (default: claude-opus-4-7)",
49
+ description: `Claude model for the lead role (default: ${LEAD_MODEL})`,
48
50
  },
49
51
  "judge-model": {
50
52
  type: "string",
51
- description: "Claude model for the judge (default: claude-opus-4-7)",
53
+ description: `Claude model for the judge (default: ${LEAD_MODEL})`,
52
54
  },
53
55
  "agent-profile": {
54
56
  type: "string",
@@ -126,7 +128,7 @@ export const definition = {
126
128
  },
127
129
  examples: [
128
130
  "fit-benchmark run --family=./families/coding",
129
- "fit-benchmark run --family=./families/coding --runs=10 --agent-model=claude-sonnet-4-6",
131
+ `fit-benchmark run --family=./families/coding --runs=10 --agent-model=${BENCHMARK_AGENT_MODEL}`,
130
132
  "fit-benchmark invariants --family=./families/coding --task=todo-api --workdir=./benchmark-runs/runs/todo-api/0",
131
133
  "fit-benchmark report --format=text",
132
134
  "fit-benchmark report --input=./runs/today --k=1,3,5 --format=text",
package/bin/fit-eval.js CHANGED
@@ -13,6 +13,7 @@ import { runSuperviseCommand } from "../src/commands/supervise.js";
13
13
  import { runFacilitateCommand } from "../src/commands/facilitate.js";
14
14
  import { runDiscussCommand } from "../src/commands/discuss.js";
15
15
  import { runCallbackCommand } from "../src/commands/callback.js";
16
+ import { AGENT_MODEL, LEAD_MODEL } from "@forwardimpact/libutil/models";
16
17
 
17
18
  const LEAD_OPTIONS = {
18
19
  "lead-profile": {
@@ -21,8 +22,7 @@ const LEAD_OPTIONS = {
21
22
  },
22
23
  "lead-model": {
23
24
  type: "string",
24
- description:
25
- "Claude model for the lead role (default: claude-opus-4-7[1m])",
25
+ description: `Claude model for the lead role (default: ${LEAD_MODEL})`,
26
26
  },
27
27
  };
28
28
 
@@ -64,8 +64,7 @@ const definition = {
64
64
  ...TASK_INPUT_OPTIONS,
65
65
  "agent-model": {
66
66
  type: "string",
67
- description:
68
- "Claude model for the agent (default: claude-opus-4-7[1m])",
67
+ description: `Claude model for the agent (default: ${AGENT_MODEL})`,
69
68
  },
70
69
  "max-turns": {
71
70
  type: "string",
@@ -102,8 +101,7 @@ const definition = {
102
101
  ...TASK_INPUT_OPTIONS,
103
102
  "agent-model": {
104
103
  type: "string",
105
- description:
106
- "Claude model for the agent (default: claude-opus-4-7[1m])",
104
+ description: `Claude model for the agent (default: ${AGENT_MODEL})`,
107
105
  },
108
106
  ...LEAD_OPTIONS,
109
107
  "max-turns": {
@@ -147,7 +145,7 @@ const definition = {
147
145
  ...TASK_INPUT_OPTIONS,
148
146
  "agent-model": {
149
147
  type: "string",
150
- description: "Claude model for agents (default: claude-opus-4-7[1m])",
148
+ description: `Claude model for agents (default: ${AGENT_MODEL})`,
151
149
  },
152
150
  ...LEAD_OPTIONS,
153
151
  "max-turns": {
@@ -184,7 +182,7 @@ const definition = {
184
182
  ...TASK_INPUT_OPTIONS,
185
183
  "agent-model": {
186
184
  type: "string",
187
- description: "Claude model for agents (default: claude-opus-4-7[1m])",
185
+ description: `Claude model for agents (default: ${AGENT_MODEL})`,
188
186
  },
189
187
  ...LEAD_OPTIONS,
190
188
  "max-turns": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forwardimpact/libeval",
3
- "version": "0.1.56",
3
+ "version": "0.1.58",
4
4
  "description": "Agent evaluation framework — prove whether agent changes improved outcomes with reproducible evidence.",
5
5
  "keywords": [
6
6
  "eval",
@@ -51,7 +51,7 @@
51
51
  "test": "bun test test/*.test.js"
52
52
  },
53
53
  "dependencies": {
54
- "@anthropic-ai/claude-agent-sdk": "0.2.112",
54
+ "@anthropic-ai/claude-agent-sdk": "0.3.170",
55
55
  "@forwardimpact/libcli": "^0.1.0",
56
56
  "@forwardimpact/libconfig": "^0.1.0",
57
57
  "@forwardimpact/libpreflight": "^0.1.0",
@@ -6,6 +6,8 @@
6
6
  * Follows OO+DI: constructor injection, factory function, tests bypass factory.
7
7
  */
8
8
 
9
+ import { AGENT_MODEL } from "@forwardimpact/libutil/models";
10
+
9
11
  const DEFAULT_ALLOWED_TOOLS = ["Bash", "Read", "Glob", "Grep", "Write", "Edit"];
10
12
 
11
13
  // fit-eval and kata-action run headless in CI/CD with no human to answer
@@ -43,7 +45,7 @@ export class AgentRunner {
43
45
  this.query = deps.query;
44
46
  this.output = deps.output;
45
47
  this.redactor = deps.redactor;
46
- this.model = deps.model ?? "claude-opus-4-7[1m]";
48
+ this.model = deps.model ?? AGENT_MODEL;
47
49
  this.maxTurns = deps.maxTurns ?? 50;
48
50
  this.allowedTools = deps.allowedTools ?? DEFAULT_ALLOWED_TOOLS;
49
51
  this.onLine = deps.onLine ?? null;
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Shared environment builder for the benchmark hook scripts (`preflight.sh` and
3
+ * `invariants.sh`). Keeping both spawns on one helper guarantees they expose the
4
+ * same variable set, so hook authors never have to wonder which vars a given
5
+ * hook receives.
6
+ *
7
+ * Path vars (TASK_DIR, FAMILY_DIR, HOOKS_DIR) let hooks reference real
8
+ * locations instead of reconstructing them from `$0`. They are paths, not
9
+ * secrets, so they need no redaction allowlist entry.
10
+ */
11
+
12
+ /**
13
+ * @param {Record<string, string>} baseEnv - Inherited env (`runtime.proc.env`).
14
+ * @param {object} vars
15
+ * @param {string} vars.cwd - Agent CWD → `$WORKDIR`.
16
+ * @param {number} vars.port - Allocated TCP port → `$PORT`.
17
+ * @param {string} vars.taskId - Task id → `$TASK_ID`.
18
+ * @param {string} vars.taskDir - Task directory on host → `$TASK_DIR`.
19
+ * @param {string} vars.hooksDir - Task `hooks/` dir on host → `$HOOKS_DIR`.
20
+ * @param {string|null} vars.familyDir - Family root on host → `$FAMILY_DIR`
21
+ * (null when the family root is unknown, e.g. a standalone task).
22
+ * @returns {Record<string, string>}
23
+ */
24
+ export function buildHookEnv(
25
+ baseEnv,
26
+ { cwd, port, taskId, taskDir, hooksDir, familyDir },
27
+ ) {
28
+ return {
29
+ ...baseEnv,
30
+ WORKDIR: cwd,
31
+ PORT: String(port),
32
+ TASK_ID: taskId,
33
+ TASK_DIR: taskDir,
34
+ HOOKS_DIR: hooksDir,
35
+ FAMILY_DIR: familyDir ?? "",
36
+ };
37
+ }
@@ -10,6 +10,8 @@
10
10
 
11
11
  import { join } from "node:path";
12
12
 
13
+ import { buildHookEnv } from "./hook-env.js";
14
+
13
15
  /**
14
16
  * @typedef {object} InvariantsResult
15
17
  * @property {"pass" | "fail"} verdict
@@ -20,7 +22,7 @@ import { join } from "node:path";
20
22
  /**
21
23
  * Run the task's invariants script.
22
24
  * @param {import("./task-family.js").Task} task
23
- * @param {{cwd: string, port: number, runDir: string}} ctx
25
+ * @param {{cwd: string, port: number, runDir: string, familyDir?: string|null}} ctx
24
26
  * @param {import("@forwardimpact/libutil/runtime").Runtime} runtime
25
27
  * @returns {Promise<InvariantsResult>}
26
28
  */
@@ -44,9 +46,14 @@ export async function runInvariants(task, ctx, runtime) {
44
46
  try {
45
47
  child = runtime.subprocess.spawn(script, [], {
46
48
  env: {
47
- ...runtime.proc.env,
48
- WORKDIR: ctx.cwd,
49
- PORT: String(ctx.port),
49
+ ...buildHookEnv(runtime.proc.env, {
50
+ cwd: ctx.cwd,
51
+ port: ctx.port,
52
+ taskId: task.id,
53
+ taskDir: task.paths.taskDir,
54
+ hooksDir: task.paths.hooks,
55
+ familyDir: ctx.familyDir,
56
+ }),
50
57
  RESULTS_FD: "3",
51
58
  },
52
59
  stdio: ["inherit", "pipe", "pipe", fd3File],
@@ -201,6 +201,7 @@ export class BenchmarkRunner {
201
201
  cwd: workdir.cwd,
202
202
  port: workdir.port,
203
203
  runDir: workdir.runDir,
204
+ familyDir: family.rootPath,
204
205
  },
205
206
  this.runtime,
206
207
  );
@@ -17,6 +17,7 @@ import { connect } from "node:net";
17
17
  import { join } from "node:path";
18
18
 
19
19
  import { loadEnv } from "./env-loader.js";
20
+ import { buildHookEnv } from "./hook-env.js";
20
21
 
21
22
  const DEFAULT_TERM_GRACE_MS = 5_000;
22
23
 
@@ -73,6 +74,24 @@ export class WorkdirManager {
73
74
  const cwd = join(runDir, "cwd");
74
75
  await fs.mkdir(cwd, { recursive: true });
75
76
 
77
+ // Family-level shared fixtures: convention-over-configuration, copied if
78
+ // present. They form the shared base; the per-task workdir/specs below
79
+ // overlay on top (fs.cp defaults to force:true, so a per-task file wins).
80
+ if (this.familyRootPath) {
81
+ await fs
82
+ .cp(join(this.familyRootPath, "workdir"), cwd, { recursive: true })
83
+ .catch((e) => {
84
+ if (e.code !== "ENOENT") throw e;
85
+ });
86
+ await fs
87
+ .cp(join(this.familyRootPath, "specs"), join(cwd, "specs"), {
88
+ recursive: true,
89
+ })
90
+ .catch((e) => {
91
+ if (e.code !== "ENOENT") throw e;
92
+ });
93
+ }
94
+
76
95
  await fs.cp(task.paths.workdir, cwd, { recursive: true }).catch((e) => {
77
96
  if (e.code !== "ENOENT") throw e;
78
97
  });
@@ -107,7 +126,12 @@ export class WorkdirManager {
107
126
  const judgeTracePath = join(runDir, "judge.ndjson");
108
127
 
109
128
  const preflight = task.paths.preflight
110
- ? await runPreflight(this.runtime, task.paths.preflight, cwd, port)
129
+ ? await runPreflight(this.runtime, task.paths.preflight, cwd, port, {
130
+ taskId: task.id,
131
+ taskDir: task.paths.taskDir,
132
+ hooksDir: task.paths.hooks,
133
+ familyDir: this.familyRootPath,
134
+ })
111
135
  : { pgid: 0 };
112
136
 
113
137
  return {
@@ -163,12 +187,13 @@ export class WorkdirManager {
163
187
  * @param {string} script
164
188
  * @param {string} cwd - Agent CWD passed via $WORKDIR.
165
189
  * @param {number} port - Free TCP port passed via $PORT.
190
+ * @param {{taskId: string, taskDir: string, hooksDir: string, familyDir: string|null}} vars - Extra hook env vars.
166
191
  * @returns {Promise<{pgid: number, error?: {phase: string, message: string, exitCode: number}}>}
167
192
  */
168
- async function runPreflight(runtime, script, cwd, port) {
193
+ async function runPreflight(runtime, script, cwd, port, vars) {
169
194
  const child = runtime.subprocess.spawn(script, [], {
170
195
  cwd,
171
- env: { ...runtime.proc.env, WORKDIR: cwd, PORT: String(port) },
196
+ env: buildHookEnv(runtime.proc.env, { cwd, port, ...vars }),
172
197
  detached: true,
173
198
  stdio: ["ignore", "pipe", "pipe"],
174
199
  });
@@ -8,6 +8,10 @@ import { resolve } from "node:path";
8
8
 
9
9
  import { createConfig } from "@forwardimpact/libconfig";
10
10
  import { createBenchmarkRunner } from "../benchmark/runner.js";
11
+ import {
12
+ BENCHMARK_AGENT_MODEL,
13
+ LEAD_MODEL,
14
+ } from "@forwardimpact/libutil/models";
11
15
 
12
16
  /**
13
17
  * @param {import("@forwardimpact/libcli").InvocationContext} ctx
@@ -54,9 +58,9 @@ function parseRunOptions(values) {
54
58
  family,
55
59
  runs,
56
60
  output: resolve(output),
57
- agentModel: values["agent-model"] ?? "claude-sonnet-4-6",
58
- supervisorModel: values["lead-model"] ?? "claude-opus-4-7",
59
- judgeModel: values["judge-model"] ?? "claude-opus-4-7",
61
+ agentModel: values["agent-model"] ?? BENCHMARK_AGENT_MODEL,
62
+ supervisorModel: values["lead-model"] ?? LEAD_MODEL,
63
+ judgeModel: values["judge-model"] ?? LEAD_MODEL,
60
64
  profiles: {
61
65
  agent: values["agent-profile"] ?? null,
62
66
  judge: values["judge-profile"] ?? null,
@@ -4,6 +4,7 @@ import { createDiscusser } from "../discusser.js";
4
4
  import { createRedactor } from "../redaction.js";
5
5
  import { createTeeWriter } from "../tee-writer.js";
6
6
  import { resolveTaskContent } from "./task-input.js";
7
+ import { AGENT_MODEL, LEAD_MODEL } from "@forwardimpact/libutil/models";
7
8
 
8
9
  function parseAgentProfiles(raw, cwd, maxTurns) {
9
10
  if (!raw) return [];
@@ -52,8 +53,8 @@ export function parseDiscussOptions(values, runtime) {
52
53
  taskAmend,
53
54
  agentConfigs,
54
55
  leadProfile: values["lead-profile"] ?? undefined,
55
- leadModel: values["lead-model"] ?? "claude-opus-4-7[1m]",
56
- agentModel: values["agent-model"] ?? "claude-opus-4-7[1m]",
56
+ leadModel: values["lead-model"] ?? LEAD_MODEL,
57
+ agentModel: values["agent-model"] ?? AGENT_MODEL,
57
58
  maxTurns,
58
59
  maxLeadTurns,
59
60
  outputPath: values.output,
@@ -4,6 +4,7 @@ import { createFacilitator } from "../facilitator.js";
4
4
  import { createRedactor } from "../redaction.js";
5
5
  import { createTeeWriter } from "../tee-writer.js";
6
6
  import { resolveTaskContent } from "./task-input.js";
7
+ import { AGENT_MODEL, LEAD_MODEL } from "@forwardimpact/libutil/models";
7
8
 
8
9
  /**
9
10
  * Parse comma-separated agent profile names into structured configs.
@@ -50,8 +51,8 @@ export function parseFacilitateOptions(values, runtime) {
50
51
  taskAmend,
51
52
  agentConfigs,
52
53
  facilitatorCwd: resolve(values["facilitator-cwd"] ?? "."),
53
- agentModel: values["agent-model"] ?? "claude-opus-4-7[1m]",
54
- facilitatorModel: values["lead-model"] ?? "claude-opus-4-7[1m]",
54
+ agentModel: values["agent-model"] ?? AGENT_MODEL,
55
+ facilitatorModel: values["lead-model"] ?? LEAD_MODEL,
55
56
  maxTurns,
56
57
  outputPath: values.output,
57
58
  facilitatorProfile: values["lead-profile"] ?? undefined,
@@ -8,6 +8,7 @@ import { createTeeWriter } from "../tee-writer.js";
8
8
  import { SequenceCounter } from "../sequence-counter.js";
9
9
  import { resolveTaskContent } from "./task-input.js";
10
10
  import { createServiceConfig } from "@forwardimpact/libconfig";
11
+ import { AGENT_MODEL } from "@forwardimpact/libutil/models";
11
12
 
12
13
  /**
13
14
  * Parse and validate run command options from parsed values.
@@ -26,7 +27,7 @@ function parseRunOptions(values, runtime) {
26
27
  taskContent,
27
28
  taskAmend,
28
29
  cwd: resolve(values.cwd ?? "."),
29
- agentModel: values["agent-model"] ?? "claude-opus-4-7[1m]",
30
+ agentModel: values["agent-model"] ?? AGENT_MODEL,
30
31
  maxTurns: maxTurnsRaw === "0" ? 0 : parseInt(maxTurnsRaw, 10),
31
32
  outputPath: values.output,
32
33
  agentProfile: values["agent-profile"] ?? undefined,
@@ -5,6 +5,7 @@ import { createRedactor } from "../redaction.js";
5
5
  import { createTeeWriter } from "../tee-writer.js";
6
6
  import { resolveTaskContent } from "./task-input.js";
7
7
  import { createServiceConfig } from "@forwardimpact/libconfig";
8
+ import { AGENT_MODEL, LEAD_MODEL } from "@forwardimpact/libutil/models";
8
9
 
9
10
  /**
10
11
  * Parse all supervise flags from parsed values into an options object.
@@ -30,8 +31,8 @@ export async function parseSuperviseOptions(values, runtime) {
30
31
  taskAmend,
31
32
  supervisorCwd: resolve(values["supervisor-cwd"] ?? "."),
32
33
  agentCwd,
33
- agentModel: values["agent-model"] ?? "claude-opus-4-7[1m]",
34
- supervisorModel: values["lead-model"] ?? "claude-opus-4-7[1m]",
34
+ agentModel: values["agent-model"] ?? AGENT_MODEL,
35
+ supervisorModel: values["lead-model"] ?? LEAD_MODEL,
35
36
  maxTurns: (() => {
36
37
  const raw = values["max-turns"] ?? "200";
37
38
  return raw === "0" ? 0 : parseInt(raw, 10);
package/src/discusser.js CHANGED
@@ -29,6 +29,7 @@ import {
29
29
  DISCUSS_AGENT_SYSTEM_PROMPT,
30
30
  } from "./discuss-tools.js";
31
31
  import { OrchestrationLoop } from "./orchestration-loop.js";
32
+ import { AGENT_MODEL, LEAD_MODEL } from "@forwardimpact/libutil/models";
32
33
 
33
34
  /** System prompt for the discuss-mode lead. L0 mechanics only per COALIGNED. */
34
35
  export const DISCUSS_SYSTEM_PROMPT =
@@ -314,7 +315,7 @@ export function createDiscusser({
314
315
  cwd: config.cwd ?? resolvedLeadCwd,
315
316
  query,
316
317
  output: devNull,
317
- model: agentModel ?? "claude-opus-4-7[1m]",
318
+ model: agentModel ?? AGENT_MODEL,
318
319
  maxTurns: config.maxTurns ?? 50,
319
320
  allowedTools: config.allowedTools,
320
321
  onLine: (line) => discusser.loop.emitLine(config.name, line),
@@ -347,7 +348,7 @@ export function createDiscusser({
347
348
  cwd: resolvedLeadCwd,
348
349
  query,
349
350
  output: devNull,
350
- model: leadModel ?? "claude-opus-4-7[1m]",
351
+ model: leadModel ?? LEAD_MODEL,
351
352
  maxTurns: maxTurns ?? 80,
352
353
  allowedTools: ["Read", "Glob", "Grep"],
353
354
  disallowedTools: defaultDisallowed,