File size: 1,669 Bytes
6655381
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# Running OnCallVal from this dataset

Self-contained: the environment, scorer, generator, and runners are here.

```bash

pip install pyarrow   # only to read test.parquet; the code is stdlib-only



# 1. inspect a task

python - <<'PY'

import json, pyarrow.parquet as pq

rows = pq.read_table("../test.parquet").to_pylist()

task = rows[0]

print(task["task_id"], task["difficulty"], task["alert"])

PY



# 2. wire up an episode by hand

python - <<'PY'

import json, sys, pyarrow.parquet as pq

sys.path.insert(0, ".")

from oncallval.env import Episode

from oncallval.score import score_episode, truth_from_spec



row = pq.read_table("../test.parquet").to_pylist()[0]

task = dict(row); task["spec"] = json.loads(row["spec"])

ep = Episode(task)

print(ep.system_prompt())

ep.step({"action": "list_services"})

ep.step({"action": "submit_report", "cause": "bad_deploy:public-gw", "fix_summary": "x"})

print(score_episode(ep, truth_from_spec(task)))

PY



# 3. export to jsonl (the harness reads jsonl, not parquet), then run any

#    OpenAI-compatible endpoint

python - <<'PY'

import json, pyarrow.parquet as pq

rows = pq.read_table("../test.parquet").to_pylist()

with open("tasks.jsonl", "w", encoding="utf-8") as f:

    for r in rows:

        f.write(json.dumps(r) + "

")

PY

OPENAI_BASE_URL=https://api.openai.com/v1 OPENAI_API_KEY=sk-...   python -m oncallval.harness --tasks tasks.jsonl --agent llm --model <model> --out run.jsonl

```

Notes:
- `truth_from_spec` derives the answer key from the task spec, so there is no
  answers file to leak or lose.
- Never pass `spec` to the agent. It sees `alert` and action observations only.