Skip to content

Commit 9c9f6cf

Browse files
test(parity): eighth-pass §L.5 closeout — Track B B=1000, NSW+PSID-1, agent bench
- coverage_monte_carlo: add explicit-rate run_b1000.py harness; ship coverage_b1000.json with measured 95% CI coverage at B=1000 for OLS (0.952), 2x2 DiD (0.955), strong-Z IV (0.962); all inside the 99% Wilson band [0.935, 0.967] around nominal 0.95. Full slow pytest sweep at B=1000 also passes 8/8 (753.51 s). - orig_parity: add module 04b on causalsens::lalonde.psid (true Dehejia-Wahba NSW+PSID-1, 2675 obs); sp.regress + sp.psm match R bit-equal and recover the published -15,205 to rel 1.5e-05. - agent_bench: add CausalAgentBench harness (50 prompts L1/L2/L3 x 6 cells x 3 reps = 900 trials) with deterministic mock LLM, grader emitting H1-H5 directional table, and frozen OSF pre- registration protocol. Mock dry-run completes in <1 s; production run is one --mock -> --api both flag away once OSF + API budget clear. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent d34dbb1 commit 9c9f6cf

19 files changed

Lines changed: 6825 additions & 0 deletions

tests/agent_bench/README.md

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
# `tests/agent_bench/` — CausalAgentBench harness
2+
3+
This directory holds the infrastructure for the JSS plan §5.5 /
4+
manuscript §7 LLM-agent behavioural benchmark. The harness is
5+
**fully built** but the production 900-trial run (6 cells × 50
6+
prompts × 3 reps with Anthropic and OpenAI APIs) is gated on:
7+
8+
1. an OSF pre-registration deposit (the protocol is in
9+
`prompts/_protocol.md` and ready to upload),
10+
2. an API budget commitment (~$300–600), and
11+
3. a green light from the project lead.
12+
13+
Until those land, the harness runs end-to-end against a
14+
deterministic mock LLM (`runners/mock_llm.py`) so the scoring,
15+
result-aggregation, and statistical-test pipeline can be smoke-
16+
tested. The mock-LLM run produces fake transcripts and a real
17+
score table; flipping the harness to the real API is a one-line
18+
change in `runners/runner.py`.
19+
20+
## Layout
21+
22+
```
23+
tests/agent_bench/
24+
├── README.md
25+
├── prompts/
26+
│ ├── _protocol.md # OSF pre-registration text (frozen for upload)
27+
│ └── prompts.json # 50 prompts (L1 × 20, L2 × 20, L3 × 10)
28+
├── golds/
29+
│ └── golds.json # gold answers + 5-dimensional rubrics
30+
├── runners/
31+
│ ├── mock_llm.py # deterministic stub for harness smoke
32+
│ ├── runner.py # main loop: run all 900 trials
33+
│ └── grader.py # apply rubric + emit per-trial scores
34+
├── sandbox/ # per-trial scratch directories
35+
└── results/
36+
├── trials.jsonl # one line per trial: {prompt_id, cell, rep, output}
37+
├── scores.csv # per-trial 5-dimensional scores
38+
└── headline.md # H1-H5 hypothesis test outcomes
39+
```
40+
41+
## Pre-registered hypotheses
42+
43+
The OSF document freezes:
44+
- **H1**: StatsPAI cells (C1, C2) achieve task success ≥ 90% on L1,
45+
≥ 70% on L2, ≥ 50% on L3.
46+
- **H2**: StatsPAI cells exceed Pythonic-stack cells (C3, C4) on
47+
L2–L3 task success by ≥ 15 percentage points.
48+
- **H3**: StatsPAI hallucination rate < 5%; Pythonic-stack ≥ 15%.
49+
- **H4**: StatsPAI uses ≤ 60% of the tokens of Pythonic-stack at
50+
fixed prompt+model.
51+
- **H5**: R-via-MCP cells (C5, C6) match StatsPAI on task success
52+
but require ≥ 1.5× the tokens.
53+
54+
Statistical test: cluster bootstrap with prompt as the cluster,
55+
α = 0.05, Bonferroni correction across H1–H5.
56+
57+
## Six experimental cells
58+
59+
| Cell | Toolset | Agent |
60+
| --- | --- | --- |
61+
| C1 | StatsPAI + MCP | Anthropic Claude (latest) |
62+
| C2 | StatsPAI + MCP | OpenAI GPT (latest) |
63+
| C3 | Pythonic stack (statsmodels, linearmodels, DoubleML, grf-python) | Claude |
64+
| C4 | Pythonic stack | GPT |
65+
| C5 | R via MCP (radian + Jupyter R) | Claude |
66+
| C6 | R via MCP | GPT |
67+
68+
900 total trials = 50 prompts × 6 cells × 3 reps.
69+
70+
## How to run
71+
72+
Mock-LLM smoke (no API cost):
73+
74+
```bash
75+
cd tests/agent_bench
76+
python3 runners/runner.py --mock --cells C1,C3,C5 --prompts L1
77+
python3 runners/grader.py
78+
```
79+
80+
Full production run (after OSF + budget approval):
81+
82+
```bash
83+
export ANTHROPIC_API_KEY=...
84+
export OPENAI_API_KEY=...
85+
python3 runners/runner.py --cells C1,C2,C3,C4,C5,C6 --prompts all
86+
python3 runners/grader.py
87+
```

0 commit comments

Comments
 (0)