Skip to content

A skill to stop your coding agent from burying the answer. ADHD-friendly output.

Merge remote-tracking branch 'origin/main' into review/pr-95

ayghrib8b0a41a2f1f
diff --cc evals/README.md
index de7d4fc,ee5ae67..2f30224
--- a/evals/README.md
+++ b/evals/README.md
@@@ -38,19 -38,38 +38,48 @@@ Isolation also drops the operator's sav
Runs are resumable: rerun the same command after a provider failure and completed `(case, trial, condition, runner)` rows are skipped. Each incomplete call is retried twice by default, and the final provider error is preserved.
+## Measure
+
+Aggregate token usage, reported cost, and response length from the completed responses file:
+
+```bash
+python3 scripts/run_evals.py measure evals/results/responses.jsonl
+```
+
+The command refuses to compare conditions produced by different runners or conditions with unequal `(case_id, trial)` coverage. This is the same comparability rule the release gate applies to judged scores.
+
## Judge and score
- Blind the `condition` field before judging. Write one JSON object per response with these fields:
+ `scripts/judge.py` grades the responses and writes the score rows for you:
+
+ ```bash
+ python3 scripts/judge.py \
+ --runner claude \
+ --responses evals/results/responses.jsonl \
+ --output evals/results/scores.jsonl
+ ```
+
+ It groups responses by `(case_id, trial)` and grades every condition for a case
+ in one call, so the conditions are compared against each other rather than
+ scored in isolation. Blinding is structural, not a convention the grader is
+ asked to respect: each condition is relabelled `A`/`B`/`C` before the prompt is
+ built, and the label order is permuted per group, so position carries no signal.
+ The permutation comes from a digest of the group key rather than a random
+ source, so a resumed run reproduces the labels it used the first time.
+
+ Only the region of `rubric.md` between the `<!-- judge:begin -->` and
+ `<!-- judge:end -->` markers reaches the grader. The release-gate rules below
+ those markers name the conditions, and sending them to a blind grader would
+ leak the vocabulary the blinding exists to hide. Keep anything condition-identifying
+ outside that block.
+
+ Runs are resumable the same way generation is: groups already present in the
+ output file are skipped. A group missing a condition cannot be scored — the
+ conditions would no longer be judged on identical rows — so it is reported on
+ stderr and left out rather than silently dropped.
+
+ Judging by hand instead is still supported: blind the `condition` field
+ yourself and write one JSON object per response with these fields.
```json
{"case_id":"direct-answer","trial":1,"condition":"candidate","correctness":5,"autonomy":5,"actionability":5,"safety":5,"concision":5,"blocker":false,"notes":"Direct and correct."}
diff --cc scripts/run_evals.py
index bdb7cef,568b7dc..5549fd9
--- a/scripts/run_evals.py
+++ b/scripts/run_evals.py
@@@ -176,103 -186,23 +186,119 @@@ def summarize_scores(scores: list[dict[
}
+def summarize_usage(rows: list[dict[str, Any]]) -> dict[str, Any]:
+ grouped: dict[str, list[dict[str, Any]]] = defaultdict(list)
+ for row in rows:
+ grouped[row["condition"]].append(row)
+ if "baseline" not in grouped or "candidate" not in grouped:
+ raise ValueError("Responses must include baseline and candidate conditions")
+
+ runners = {row["runner"] for row in rows}
+ if len(runners) > 1:
+ names = ", ".join(sorted(str(runner) for runner in runners))
+ raise ValueError(f"Responses must use the same runner; found: {names}")
+ _check_pairing(grouped)
+
+ conditions: dict[str, dict[str, Any]] = {}
+ for condition, condition_rows in sorted(grouped.items()):
+ tokens = [_usage_tokens(row.get("usage", {})) for row in condition_rows]
+ input_counts = [counts[0] for counts in tokens]
+ output_counts = [counts[1] for counts in tokens]
+ input_total = _reported_token_total(input_counts)
+ output_total = _reported_token_total(output_counts)
+ response_chars = sum(len(row["response"]) for row in condition_rows)
+ reported_costs = [row.get("cost_usd") for row in condition_rows]
+ unreported_costs = sum(
+ not isinstance(cost, (int, float)) for cost in reported_costs
+ )
+ cost_total = (
+ None
+ if unreported_costs
+ else sum(float(cost) for cost in reported_costs)
+ )
+ summary = {
+ "rows": len(condition_rows),
+ "input_tokens": input_total,
+ "mean_input_tokens": (
+ None if input_total is None else input_total / len(condition_rows)
+ ),
+ "output_tokens": output_total,
+ "mean_output_tokens": (
+ None if output_total is None else output_total / len(condition_rows)
+ ),
+ "cost_usd": cost_total,
+ "response_chars": response_chars,
+ "mean_response_chars": response_chars / len(condition_rows),
+ }
+ if unreported_costs:
+ summary["cost_usd_unreported_rows"] = unreported_costs
+ conditions[condition] = summary
+
+ baseline = conditions["baseline"]
+ deltas: dict[str, dict[str, Any]] = {}
+ for condition, summary in sorted(conditions.items()):
+ if condition == "baseline":
+ continue
+ output_delta = _difference(summary["output_tokens"], baseline["output_tokens"])
+ cost_delta = _difference(summary["cost_usd"], baseline["cost_usd"])
+ response_chars_delta = _difference(
+ summary["mean_response_chars"], baseline["mean_response_chars"]
+ )
+ deltas[condition] = {
+ "output_tokens": output_delta,
+ "output_tokens_pct": _percent_change(
+ output_delta, baseline["output_tokens"]
+ ),
+ "cost_usd": cost_delta,
+ "cost_usd_pct": _percent_change(cost_delta, baseline["cost_usd"]),
+ "mean_response_chars": response_chars_delta,
+ "mean_response_chars_pct": _percent_change(
+ response_chars_delta, baseline["mean_response_chars"]
+ ),
+ }
+
+ return {"runner": next(iter(runners)), "conditions": conditions, "delta": deltas}
+
+
+def _reported_token_total(values: list[int | None]) -> int | None:
+ if any(value is None for value in values):
+ return None
+ return sum(value for value in values if value is not None)
+
+
+def _difference(
+ value: int | float | None, baseline: int | float | None
+) -> int | float | None:
+ if value is None or baseline is None:
+ return None
+ return value - baseline
+
+
+def _percent_change(
+ delta: int | float | None, baseline: int | float | None
+) -> float | None:
+ if delta is None or baseline in (None, 0):
+ return None
+ return delta / baseline * 100
+
+
- def _condition_prompt(task: str, condition: str, skill_path: Path | None) -> str:
+ def _strip_frontmatter(text: str) -> str:
+ """Drop a leading YAML frontmatter block, mirroring hooks/always-on.sh.
+
+ The hook injects the ruleset without frontmatter, so the eval has to grade
+ the same text. A file that opens a block but never closes it is left alone
+ rather than emptied.
+ """
+ lines = text.splitlines()
+ if not lines or lines[0].strip() != "---":
+ return text
+ for index in range(1, len(lines)):
+ if lines[index].strip() == "---":
+ return "\n".join(lines[index + 1 :]).lstrip("\n")
+ return text
+
+
+ def _condition_prompt(task: str, condition: str, skill_path: Optional[Path]) -> str:
if condition == "baseline":
return task
if skill_path is None: