Repository navigation
Description
Overview
There are two agent evals today — scripts/routing-eval.ts (skill-routing accuracy) and scripts/aichat-matrix.ts (end-to-end tool-call behavior) — exposed as eval:routing and eval:agent. They already share a convention: same env-var contract, same <label> [out.json] argv, same results-JSON shape, same summary table, same non-zero exit, both support a baseline env var. That convention is good. It is also copy-pasted, and neither harness can tell a real result from a broken environment.
More evals are expected. Two harnesses is the last cheap moment to factor the shared parts out; at three the duplication is load-bearing.
What's duplicated
Both scripts independently implement:
- the
NS_BIN/NODESPACED_SOCKET/NS_LOG/NS_MODEL/NS_TIMEOUT_MScontract - "the daemon, socket, and DB are managed by the caller; skills must be seeded" as a doc comment rather than a check
<label> [out.json]parsing and the/tmp/<name>-<label>-<ts>.jsondefault- results-JSON assembly, the summary table, and the exit code
- baseline comparison with NEW / REGRESSION / FIXED (
ROUTING_BASELINE,AICHAT_MATRIX_BASELINE)
What actually differs per eval is only the scenario list and how a turn is scored.
The gap that matters: an eval can score a broken environment
A recent aichat-matrix run reported Scenarios 1 and 2 as passing while the daemon was fundamentally broken. Both assert "no tools called"; every turn was failing with Context window exceeded before inference ran, and a timed-out turn calls no tools. The run produced a plausible-looking partial result from an environment where nothing worked. It took reading daemon logs to notice.
This is the same failure mode as the unverifiable "12/12" claim ADR-056 was written to correct: a number that outlived the conditions that produced it. An eval that can silently score a broken environment is worse than no eval, because its output gets cited.
Proposal
1. scripts/eval/runner.ts — shared harness. Owns the env contract, argv, results JSON, summary table, baseline comparison, and exit code. Each eval becomes a fixture module exporting its scenarios plus an assertion function. A new eval is then a fixture file, not another copy of the plumbing.
2. Preflight gate (the load-bearing part). Before scoring anything, assert the environment can actually produce a valid result, and abort with a distinct exit code if not:
- daemon reachable on the socket
- the requested model is loaded
- the granted context window exceeds the eval's own system prompt — this is what would have caught the run above in ~2s instead of ~8min
Environment failure must be reported as environment failure, never as scenario results.
3. Committed baselines, used by default. Both harnesses support baseline comparison; neither has a committed baseline. scripts/results-e4b.json (gemma-4-e4b-q4km, 11/12) is now committed and can serve as eval:agent's default. Add the routing equivalent. Comparing should be the default behavior, not an env var you must remember.
4. Provenance in every results file. Record model ID, timestamp, host memory, and the granted n_ctx alongside the scores, so a cited number carries the conditions that produced it.
5. scripts/aichat-matrix.test.ts should run in CI. It unit-tests assertExpectation — the function that decides pass/fail — in ~105ms with no model or daemon. It currently runs nowhere: bun run test scopes to packages/desktop-app/src/tests/**, and it can't run under vitest because it imports bun:test. Add a test:scripts script (bun test scripts/) and include it in test:all. Note this is a legitimate exception to the "never use bun test" rule, which exists to stop DOM tests bypassing the Happy-DOM vitest config — not applicable to a standalone script test.
Explicitly out of scope
The evals themselves stay out of test:all. They need a multi-GB GGUF, a running daemon, and minutes of real inference; they are manual or scheduled, not part of a push gate. Only the scoring-logic unit test joins the suite. A nondeterministic model in a blocking gate trains people to reach for --no-verify.
Acceptance Criteria
- A shared runner exists; both existing evals are ported onto it with no behavior change to their scenarios or scoring
- A run against an unreachable daemon, an unloaded model, or a context window too small for the system prompt aborts with a clear environment error and a distinct exit code — never partial scenario results
- Adding a new eval requires only a fixture module (scenarios + assertion), not new plumbing
- Both evals compare against a committed baseline by default and report NEW / REGRESSION / FIXED
- Results files record model, date, host memory, and granted
n_ctx -
bun run test:allrunsscripts/aichat-matrix.test.ts - Eval setup (build, daemon launch, model load, skill seeding) is documented in
nodespace-docs
Related cleanup
scripts/aichat-1329-trial.md is documentation living in the code repo, which the documentation standard prohibits. Its reproduce steps are currently the best written record of eval setup — they should move into nodespace-docs as part of the setup documentation above, and the file deleted.
Dependency
Running the agent eval end-to-end on a normal machine is currently blocked by the context-floor bug (compute_effective_n_ctx floors n_ctx to 4096, below the ~6,600-token agent system prompt). The preflight gate proposed here detects that condition rather than fixing it — the two are independent, and the gate is worth having regardless since it converts a silent wrong result into a loud, immediate one.
Activity
malibio commentedon Jul 28, 2026
Correction: the matrix's current job is prompt tuning, not model comparison
Filing note — the issue above frames the harness around its original purpose (A/B-ing candidate models: E4B vs 12B vs 31B) because that is what the code is shaped for. Now that Gemma 4 E4B is locked, the matrix is being used for something different: iterating on prompts and agent guidance against one fixed model. Two things in the proposal need adjusting, and two are missing.
The harness records the wrong variable
<label>tags which model produced a run ("e4b" / "12b" / "31b"), and the results file storeslabel+model. Nothing records the prompt/guidance version — which is now the input actually being varied. Consecutive runs against the same model with different prompts are indistinguishable except by filename and timestamp.This is the same defect that made ADR-046's "12/12" unreproducible: the number outlived the conditions that produced it. For prompt tuning it bites immediately, because every run has a different input and none of them say so.
Wanted: capture the prompt/guidance identity in the results file — a git SHA of the guidance source, or a hash of the assembled system prompt (the daemon already logs
system_prompt_len; the content is available at the same point). "Which prompt produced this score" must be answerable from the artifact alone.Baselines are rolling, not fixed
The issue proposes committing
results-e4b.jsonas the baseline. That is right for model comparison — a stable target to measure candidates against — and wrong for prompt tuning, where the intended behavior is to improve the baseline repeatedly. A fixed committed baseline would show a permanent green diff while you are trying to see movement.Wanted: treat the committed file as "last known good," explicitly re-recorded when a prompt change improves the score, rather than as a fixture. The NEW / REGRESSION / FIXED comparison is still exactly the right output shape — it is the only thing that answers "did fixing scenario 6 break scenario 4," which is the central risk when tuning prompts.
Missing: scenario filtering
Tuning currently targets one scenario (6), but every iteration runs all 12 at ~4 minutes, nearly all of it irrelevant. A
--only <scenario>/--only 6filter would make the loop ~35s.This is probably the single highest-value change for the current workflow, and it is independent of the shared-runner refactor.
Missing: run-to-run variance is unknown
Prompt tuning compares scores across runs, but nobody has measured whether a scenario is stable across repeats of the same prompt. If Scenario 6 flips occasionally on identical input, a single passing run after a prompt tweak proves nothing. Worth an
--repeat Nflag, or at minimum measuring current variance once so the noise floor is known before conclusions are drawn from single runs.Note on the current Scenario 6 failure
Under the tuning lens, the most actionable half of that failure is prompt-shaped, not code-shaped: the model called
resolve_query(node_type="invoice")when the registered type wasinvoice_tracker. It only ever sees a truncated schema summary, so the wrong type name is a plausible guidance/prompt problem and worth testing before assumingresolve_queryneeds code hardening. (The second half — the schema having no typed fields at all — is not prompt-fixable.)malibio commentedon Jul 28, 2026
Eval runs should capture prompts by default
Adding a concrete lesson from diagnosing the Scenario 6 failure.
The agent already supports
NODESPACE_PROMPT_DUMP=<path>(packages/agent/src/local_agent/prompt_dump.rs), which writes the exact assembled system prompt, messages, offered tools, and raw model response per ReAct iteration — withscripts/prompt-dump.tsas a reader. The daemon log records onlysystem_prompt_lenand a short preview, which is not enough to diagnose anything.Neither eval harness enables it. A full 12-scenario matrix run therefore produces scores with no record of what was actually sent to the model — and when a scenario fails, the run has to be repeated with dumping on to learn anything. That happened here: an initial matrix run showed Scenario 6 failing, and two competing explanations (schema not injected vs. model ignoring injected context) could not be distinguished from the results file or the daemon log at all. Re-running with the dump on settled it in one turn, and revealed a root cause neither hypothesis predicted — the guidance's own worked example hardcodes the wrong
node_type.This matters more given the harness's current use is prompt tuning. An eval that records a score but not the prompt that produced it cannot support the workflow it is being used for.
Wanted: the shared runner sets
NODESPACE_PROMPT_DUMPto a run-scoped path by default and records that path in the results file, so every score has its prompts alongside it. Cost is a JSONL file per run; the diagnostic value is the difference between "scenario 6 failed" and "here is the exact instruction the model followed."This also strengthens the provenance item already listed above — capturing the assembled prompt is a superset of capturing a prompt-version hash, and needs no new plumbing since the capability is already built.
Record the honest post-decontamination baseline (9/12)
malibio commentedon Jul 28, 2026
Heads-up for AC-3 (committed baselines):
scripts/results-e4b.jsonis now committed by PR #1763 — but the number is 9/12, not the 11/12 this issue assumes. The 11/12 was measured with eval prompts planted in the agent's guidance (#1760); it also never existed as a committed file, only as a scratch artifact.Also relevant to the preflight gate (AC-2), a failure mode worth adding to the checks: the eval silently measures stale guidance if the DB isn't purged and the daemon isn't rebuilt. Seeding skips existing nodes, so a reused database keeps the old prompt/skill nodes, and guidance lives in compiled-in Rust constants so a stale binary reseeds stale text. Two of my runs were invalid this way and looked completely normal — same pass/fail shape, plausible numbers. I only caught it by querying the seeded DB for the old example text.
Cheap checks that would have caught it: assert the seed reported
skipped=0, and/or record the guidance commit in the results file and compare it to HEAD. This is the same class as the context-window failure — an environment problem that scores as scenario results.Close the remaining review suggestions on the baseline artifact
Agent guidance contains verbatim aichat-matrix prompts — the eval is …
malibio commentedon Jul 28, 2026
Baseline (worktree issue-1759-eval-runner, branched from main @ 1d43c23): Frontend: 4096 passed across 169 test files, 0 failed. Note: fresh worktree needed a one-time
bun run --cwd packages/desktop-app sync(svelte-kit sync) before vitest could resolve tsconfig.Shared eval runner with a preflight gate (closes #1759)
Shared eval runner with a preflight gate: stop scoring scenarios when…