agent-eval-dashboard 0.1.0__tar.gz

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.
@@ -0,0 +1,321 @@
1
+ Metadata-Version: 2.4
2
+ Name: agent-eval-dashboard
3
+ Version: 0.1.0
4
+ Summary: Test your AI agent on many cases, models and repeats, and see what passes, fails or is flaky on a local dashboard.
5
+ License-Expression: MIT
6
+ Requires-Python: >=3.11
7
+ Description-Content-Type: text/markdown
8
+
9
+ # agent-eval-dashboard
10
+
11
+ [![tests](https://github.com/Daniel1Maymon/agent-eval-dashboard/actions/workflows/tests.yml/badge.svg)](https://github.com/Daniel1Maymon/agent-eval-dashboard/actions/workflows/tests.yml)
12
+
13
+ Test your AI agent on a set of cases, many times each, and see on one page
14
+ what passes, what fails, and what is flaky — across models and changes.
15
+ Built-in check: did it call the right tools. Or write your own check.
16
+
17
+ ![The page: the run list on the left, the table of cases × models, and an open panel with one model's runs for one case](https://raw.githubusercontent.com/Daniel1Maymon/agent-eval-dashboard/main/docs/screenshot.png)
18
+
19
+ Lightweight, local and zero-dependency: only the Python standard library (Python 3.11 or newer). Built for tens of cases, a few models and a few repeats.
20
+
21
+ ## Install
22
+
23
+ ```
24
+ pip install agent-eval-dashboard
25
+ ```
26
+
27
+ or, in a uv project:
28
+
29
+ ```
30
+ uv add agent-eval-dashboard
31
+ ```
32
+
33
+ ## Quick start
34
+
35
+ A full real example, with a Claude Agent SDK agent: [`examples/claude-agent-sdk/`](examples/claude-agent-sdk/).
36
+
37
+ ### 1. Your cases: `cases.json`
38
+
39
+ ```json
40
+ [
41
+ {"case_id": "c01", "input": "Where is my order 1003?", "expected_tools": ["get_order"]},
42
+ {"case_id": "c02", "input": "Hi, how are you?", "expected_tools": []}
43
+ ]
44
+ ```
45
+
46
+ - `case_id`: a unique name for the case.
47
+ - `input`: the text your agent gets. The key is `input`, not `question`.
48
+ - `expected_tools`: the tools the agent should call. `[]` means "no tool fits", so calling nothing is right.
49
+ - Extra keys are fine. They are not saved, but your own check gets the whole case.
50
+ - You can also pass a Python list instead of a file path.
51
+
52
+ ### 2. Your agent: `my_agent(input, model)`
53
+
54
+ It calls your own agent and returns an `AgentResult`. It can be a normal function or an `async def` function.
55
+
56
+ ```python
57
+ from agent_eval_dashboard import AgentResult
58
+
59
+ def my_agent(input, model):
60
+ out = run_my_agent(input, model) # your own agent (a sketch: these fields are yours)
61
+ return AgentResult(
62
+ calls=[{"tool": t.name, "args": t.args} for t in out.tool_calls], # required
63
+ answer=out.text, # required
64
+ tokens=out.input_tokens + out.output_tokens, # optional
65
+ turns=out.turns, # optional
66
+ # prices in $ per million tokens; see the provider's price page
67
+ cost_usd=(out.input_tokens * 1.00 + out.output_tokens * 5.00) / 1_000_000, # optional
68
+ )
69
+ ```
70
+
71
+ To try the library first, a stand-in that always returns the same thing:
72
+
73
+ ```python
74
+ def my_agent(input, model):
75
+ return AgentResult(calls=[{"tool": "get_order", "args": {"order_id": "1003"}}],
76
+ answer="Your order 1003 has shipped.", tokens=2040, turns=2, cost_usd=0.0021)
77
+ ```
78
+
79
+ ### 3. Run it: `run_eval`
80
+
81
+ ```python
82
+ from agent_eval_dashboard import run_eval
83
+
84
+ summary = run_eval(
85
+ experiment="exp03-tool-choice",
86
+ label="clear tools",
87
+ cases="cases.json",
88
+ agent=my_agent,
89
+ models=["claude-haiku-5-5", "claude-sonnet-5-5"],
90
+ repeats=3,
91
+ tools=[{"name": "get_order", "description": "Look up one order by its ID."}],
92
+ harness="claude-agent-sdk",
93
+ system_prompt="You are a shop support assistant.", # optional
94
+ db="evals.db", # optional, this is the default
95
+ check=None, # optional, None = the built-in check
96
+ )
97
+ ```
98
+
99
+ ```text
100
+ models=["haiku", "sonnet"], repeats=3, 2 cases
101
+
102
+ haiku run 1: c01 c02 sonnet run 1: c01 c02
103
+ run 2: c01 c02 run 2: c01 c02
104
+ run 3: c01 c02 run 3: c01 c02
105
+
106
+ = 6 runs, 12 cases saved in evals.db, all in ONE batch
107
+ ```
108
+
109
+ It prints one line per case, then one line per model:
110
+
111
+ ```text
112
+ [claude-haiku-5-5 · run 1/3] c01 PASS 3.2 s
113
+ [claude-haiku-5-5 · run 1/3] c02 FAIL 2.8 s — Extra tools: [get_order]
114
+ ...
115
+ claude-haiku-5-5: 3 passed, 3 failed, 0 error
116
+ claude-sonnet-5-5: 3 passed, 3 failed, 0 error
117
+ ```
118
+
119
+ It returns `{"db": "evals.db", "models": {"claude-haiku-5-5": {"passed": 3, "failed": 3, "error": 0}, ...}}`.
120
+
121
+ ### 4. See it
122
+
123
+ ```
124
+ agent-eval-dashboard evals.db
125
+ ```
126
+
127
+ - Opens your browser at `http://localhost:8000` (or a free port if 8000 is busy). The real address is printed.
128
+ - **Refresh the browser to see new runs.** You can leave it running while `run_eval` works.
129
+ - Ctrl+C stops it.
130
+
131
+ | Flag | What it does |
132
+ |---|---|
133
+ | `--experiment exp03-tool-choice` | Show only that experiment. Without it: every run in the file. |
134
+ | `--no-browser` | Start the server, but do not open a browser. |
135
+ | `-o report.html` | No server. Write one offline HTML file instead. Double-click it; it needs no internet. |
136
+
137
+ ## How it works
138
+
139
+ ```text
140
+ cases.json + my_agent(input, model)
141
+ │
142
+ ▼
143
+ run_eval ── runs every case × model × repeat
144
+ │ calls your agent, times it, catches crashes,
145
+ │ runs the check (built-in or yours)
146
+ ▼
147
+ EvalLog ── writes evals.db
148
+ │ one batch per run_eval call
149
+ ▼
150
+ agent-eval-dashboard evals.db ── reads it, read-only
151
+ │
152
+ ▼
153
+ the page
154
+ ┌──────────────────┬──────────────────────────────────────┐
155
+ │ run list │ table: cases × models │
156
+ │ one entry per │ c01 PASS STABLE │
157
+ │ run_eval call, │ c02 FAIL FLAKY ◀── click │
158
+ │ newest first │ └─ panel: that model's runs │
159
+ └──────────────────┴──────────────────────────────────────┘
160
+ ```
161
+
162
+ **What a box in the table says:**
163
+
164
+ | Runs of that model in this batch | Box |
165
+ |---|---|
166
+ | 1 run | `PASS` or `FAIL` |
167
+ | several, all passed | `STABLE` |
168
+ | several, some passed | `FLAKY` (with the count, for example `1/2`) |
169
+ | several, none passed | `ALWAYS FAILS` |
170
+ | it crashed | grey `ERROR`, left out of the pass rate |
171
+
172
+ - Under the word: averages, for example `2.0k tok · 1.5 turns · 3.5 s`.
173
+ - Above the table: one card per model with score, cost per run, tokens per run and average time per case.
174
+ - **Click a box** to see the input, the expected tools, and every run of that model: its calls (expected tools shown in green), PASS/FAIL with the reason, cost, tokens, turns, time and answer.
175
+
176
+ **A batch never mixes with another batch.** So `run_eval(repeats=1)` called 3 times gives 3 entries with `PASS`/`FAIL`, never `FLAKY`. To check stability, use `repeats=3` in one call.
177
+
178
+ ## Architecture
179
+
180
+ ```text
181
+ src/agent_eval_dashboard/
182
+ runner.py run_eval + AgentResult: the loop, timing, crash handling,
183
+ cleaning the calls, the built-in check
184
+ recorder.py EvalLog: writes runs and cases into evals.db
185
+ report.py reads evals.db, groups runs into batches, works out every
186
+ word, score and average (all the logic)
187
+ template.html the page: plain HTML/CSS/JS, only draws, no logic
188
+ server.py the local server: one page at "/", made again on every refresh
189
+ cli.py the agent-eval-dashboard command: server, or -o file
190
+ ```
191
+
192
+ **evals.db** has 2 tables:
193
+
194
+ ```text
195
+ runs (one row per model × repeat) cases (one row per case, per run)
196
+ ───────────────────────────────── ─────────────────────────────────
197
+ run_id ◀────────────────────────────── run_id
198
+ batch_id (one per run_eval call) case_id, input, expected_tools
199
+ created_at called (tool calls, JSON)
200
+ experiment, model, label, harness verdict PASS / FAIL / ERROR
201
+ system_prompt, tools (JSON) reason, answer
202
+ cost_usd, tokens, turns, seconds
203
+ saved_at (for "last case saved … ago")
204
+ ```
205
+
206
+ **The rules:**
207
+
208
+ - **Standard library only.** Installing it adds nothing else to your project.
209
+ - **The viewer never writes the file.** It opens `evals.db` read-only.
210
+ - **Localhost only.** The server listens on `127.0.0.1`, serves only `/`, and answers only `GET`.
211
+ - **The page is rebuilt on every refresh.** The server and the `-o` file show the exact same page.
212
+
213
+ ## Your own check
214
+
215
+ Pass `check=` to decide PASS or FAIL yourself:
216
+
217
+ ```python
218
+ def check(case, result):
219
+ """case: the case dict, with any extra keys. result: the AgentResult, calls already cleaned."""
220
+ called = [c["tool"] for c in result.calls]
221
+ if called != case["expected_tools"]:
222
+ return False, f"called {called}"
223
+ if "1003" not in result.answer:
224
+ return False, "answer has no order number"
225
+ return True, "right tools, right answer"
226
+
227
+ run_eval(..., check=check) # sketch: the other arguments as in Quick start
228
+ ```
229
+
230
+ - It must return `(passed, reason)`: `passed` is `True` or `False`, `reason` is non-empty text.
231
+ - Use it for args, answer text, tool order, cost, or an AI judge.
232
+ - **The built-in check:** PASS when the set of called tool names equals the set of `expected_tools`. Order and duplicates are ignored. It does not look at the answer. Its reason is `All expected tools called`, `No tool needed, none called`, or for a FAIL `Missing tools: …` and/or `Extra tools: …`, one per line. The console prints a reason on one line, with ` · ` between its lines.
233
+
234
+ ## Details for `my_agent`
235
+
236
+ **Tokens:** count every token read or written.
237
+ - Anthropic: `input_tokens + cache_creation_input_tokens + cache_read_input_tokens + output_tokens`.
238
+ - OpenAI / LangChain: `total_tokens`.
239
+
240
+ **Turns:** the number of model calls in the case.
241
+
242
+ **Cost:** shown only when you give it. There is no price table.
243
+ - Claude Agent SDK: `total_cost_usd` from the result message.
244
+ - Others: work it out from tokens and your own prices, as in Quick start.
245
+
246
+ **Tools:** each item in `tools` needs `name` and `description`. Add `shown_name` when the model sees a different name than the one your code runs.
247
+
248
+ **The calls get cleaned** before the check and before saving:
249
+ - An `mcp__<server>__` prefix is removed: `mcp__shop__get_order` is saved as `get_order`.
250
+ - Args given as JSON text are parsed: `'{"order_id": "1003"}'` becomes `{"order_id": "1003"}`.
251
+
252
+ ## The other way in: `EvalLog` (your own loop)
253
+
254
+ Write the loop yourself. You run the agent, time it, and decide PASS or FAIL. One `EvalLog` is one run (one model, one pass over the cases).
255
+
256
+ ```python
257
+ import time
258
+ from agent_eval_dashboard import EvalLog
259
+
260
+ log = EvalLog(db="evals.db", experiment="exp03-tool-choice", model="claude-haiku-5-5",
261
+ harness="my-own-loop", label="clear tools",
262
+ tools=[{"name": "get_order", "description": "Look up one order by its ID."}])
263
+
264
+ for case in cases: # sketch: cases and run_my_agent are your own
265
+ start = time.perf_counter()
266
+ try:
267
+ calls, answer = run_my_agent(case["input"])
268
+ passed = {c["tool"] for c in calls} == set(case["expected_tools"])
269
+ log.case(case["case_id"], case["input"], case["expected_tools"], calls,
270
+ passed=passed, reason="same as expected" if passed else "different tools",
271
+ answer=answer, seconds=time.perf_counter() - start)
272
+ except Exception as e:
273
+ log.error(case["case_id"], case["input"], case["expected_tools"],
274
+ reason=f"{type(e).__name__}: {e}", seconds=time.perf_counter() - start)
275
+
276
+ log.close()
277
+ ```
278
+
279
+ - `log.case` also takes `cost_usd`, `tokens` and `turns`. All optional.
280
+ - `EvalLog` does not clean the calls. Pass real tool names and args as dicts.
281
+ - A missing or wrong value raises a `ValueError` at once, naming the value.
282
+ - **`batch=`:** each `EvalLog` is its own entry in the run list. To show several as one entry, give them the same text:
283
+
284
+ ```python
285
+ for model in MODELS:
286
+ log = EvalLog(db="evals.db", ..., model=model, batch="my-batch-1")
287
+ ```
288
+
289
+ ## FAQ
290
+
291
+ **What if something goes wrong in `run_eval`?**
292
+
293
+ | What happens | Result |
294
+ |---|---|
295
+ | A bad case or setting (missing key, duplicate `case_id`, empty `models`, `repeats` below 1) | Stops before any agent call. The message names the case or setting. |
296
+ | `my_agent` raises (for example a network error) | That case is `ERROR`, reason `"ExcType: message"`. The run goes on. |
297
+ | Args text is not valid JSON (the model cut off its output) | That case is `FAIL`, reason `args not valid JSON: ...`. The run goes on. |
298
+ | `my_agent` returns something that is not a valid `AgentResult` | Stops at once. The message names the case. |
299
+ | Your `check` raises | Stops at once. The message names the case. |
300
+ | Every case in a run is `ERROR` | Prints a warning: "check my_agent". |
301
+ | Ctrl+C | Stops. Cases finished so far are kept. |
302
+
303
+ When a run stops because of a bug in your code, nothing from that run is saved, so a half run never shows up on the page.
304
+
305
+ **Can I use it in Jupyter?** A normal (sync) agent works. An `async` agent inside an event loop that is already running is not supported yet: `run_eval` raises a clear error.
306
+
307
+ **My `evals.db` is old.** A file from before tokens, turns and seconds stops with "old evals.db, delete it". There is no migration. A file from before batches still works: its old runs are grouped into batches by experiment + label + harness.
308
+
309
+ **How do I compare 2 setups of the same model** (for example clear vs vague tool descriptions)? Call `run_eval` twice with 2 labels.
310
+
311
+ **What is not supported yet?**
312
+ - Grading answer text or an AI judge built in. Do it in your own `check=`.
313
+ - Per-agent detail for multi-agent workflows. A workflow is saved as one run, with all calls in one list.
314
+ - A built-in price table, or ready helpers for each agent framework.
315
+ - Hosting, logins, or history over months. Tools like Langfuse, Braintrust or LangSmith do that.
316
+
317
+ ## Run the tests
318
+
319
+ ```
320
+ uv run pytest
321
+ ```
@@ -0,0 +1,313 @@
1
+ # agent-eval-dashboard
2
+
3
+ [![tests](https://github.com/Daniel1Maymon/agent-eval-dashboard/actions/workflows/tests.yml/badge.svg)](https://github.com/Daniel1Maymon/agent-eval-dashboard/actions/workflows/tests.yml)
4
+
5
+ Test your AI agent on a set of cases, many times each, and see on one page
6
+ what passes, what fails, and what is flaky — across models and changes.
7
+ Built-in check: did it call the right tools. Or write your own check.
8
+
9
+ ![The page: the run list on the left, the table of cases × models, and an open panel with one model's runs for one case](https://raw.githubusercontent.com/Daniel1Maymon/agent-eval-dashboard/main/docs/screenshot.png)
10
+
11
+ Lightweight, local and zero-dependency: only the Python standard library (Python 3.11 or newer). Built for tens of cases, a few models and a few repeats.
12
+
13
+ ## Install
14
+
15
+ ```
16
+ pip install agent-eval-dashboard
17
+ ```
18
+
19
+ or, in a uv project:
20
+
21
+ ```
22
+ uv add agent-eval-dashboard
23
+ ```
24
+
25
+ ## Quick start
26
+
27
+ A full real example, with a Claude Agent SDK agent: [`examples/claude-agent-sdk/`](examples/claude-agent-sdk/).
28
+
29
+ ### 1. Your cases: `cases.json`
30
+
31
+ ```json
32
+ [
33
+ {"case_id": "c01", "input": "Where is my order 1003?", "expected_tools": ["get_order"]},
34
+ {"case_id": "c02", "input": "Hi, how are you?", "expected_tools": []}
35
+ ]
36
+ ```
37
+
38
+ - `case_id`: a unique name for the case.
39
+ - `input`: the text your agent gets. The key is `input`, not `question`.
40
+ - `expected_tools`: the tools the agent should call. `[]` means "no tool fits", so calling nothing is right.
41
+ - Extra keys are fine. They are not saved, but your own check gets the whole case.
42
+ - You can also pass a Python list instead of a file path.
43
+
44
+ ### 2. Your agent: `my_agent(input, model)`
45
+
46
+ It calls your own agent and returns an `AgentResult`. It can be a normal function or an `async def` function.
47
+
48
+ ```python
49
+ from agent_eval_dashboard import AgentResult
50
+
51
+ def my_agent(input, model):
52
+ out = run_my_agent(input, model) # your own agent (a sketch: these fields are yours)
53
+ return AgentResult(
54
+ calls=[{"tool": t.name, "args": t.args} for t in out.tool_calls], # required
55
+ answer=out.text, # required
56
+ tokens=out.input_tokens + out.output_tokens, # optional
57
+ turns=out.turns, # optional
58
+ # prices in $ per million tokens; see the provider's price page
59
+ cost_usd=(out.input_tokens * 1.00 + out.output_tokens * 5.00) / 1_000_000, # optional
60
+ )
61
+ ```
62
+
63
+ To try the library first, a stand-in that always returns the same thing:
64
+
65
+ ```python
66
+ def my_agent(input, model):
67
+ return AgentResult(calls=[{"tool": "get_order", "args": {"order_id": "1003"}}],
68
+ answer="Your order 1003 has shipped.", tokens=2040, turns=2, cost_usd=0.0021)
69
+ ```
70
+
71
+ ### 3. Run it: `run_eval`
72
+
73
+ ```python
74
+ from agent_eval_dashboard import run_eval
75
+
76
+ summary = run_eval(
77
+ experiment="exp03-tool-choice",
78
+ label="clear tools",
79
+ cases="cases.json",
80
+ agent=my_agent,
81
+ models=["claude-haiku-5-5", "claude-sonnet-5-5"],
82
+ repeats=3,
83
+ tools=[{"name": "get_order", "description": "Look up one order by its ID."}],
84
+ harness="claude-agent-sdk",
85
+ system_prompt="You are a shop support assistant.", # optional
86
+ db="evals.db", # optional, this is the default
87
+ check=None, # optional, None = the built-in check
88
+ )
89
+ ```
90
+
91
+ ```text
92
+ models=["haiku", "sonnet"], repeats=3, 2 cases
93
+
94
+ haiku run 1: c01 c02 sonnet run 1: c01 c02
95
+ run 2: c01 c02 run 2: c01 c02
96
+ run 3: c01 c02 run 3: c01 c02
97
+
98
+ = 6 runs, 12 cases saved in evals.db, all in ONE batch
99
+ ```
100
+
101
+ It prints one line per case, then one line per model:
102
+
103
+ ```text
104
+ [claude-haiku-5-5 · run 1/3] c01 PASS 3.2 s
105
+ [claude-haiku-5-5 · run 1/3] c02 FAIL 2.8 s — Extra tools: [get_order]
106
+ ...
107
+ claude-haiku-5-5: 3 passed, 3 failed, 0 error
108
+ claude-sonnet-5-5: 3 passed, 3 failed, 0 error
109
+ ```
110
+
111
+ It returns `{"db": "evals.db", "models": {"claude-haiku-5-5": {"passed": 3, "failed": 3, "error": 0}, ...}}`.
112
+
113
+ ### 4. See it
114
+
115
+ ```
116
+ agent-eval-dashboard evals.db
117
+ ```
118
+
119
+ - Opens your browser at `http://localhost:8000` (or a free port if 8000 is busy). The real address is printed.
120
+ - **Refresh the browser to see new runs.** You can leave it running while `run_eval` works.
121
+ - Ctrl+C stops it.
122
+
123
+ | Flag | What it does |
124
+ |---|---|
125
+ | `--experiment exp03-tool-choice` | Show only that experiment. Without it: every run in the file. |
126
+ | `--no-browser` | Start the server, but do not open a browser. |
127
+ | `-o report.html` | No server. Write one offline HTML file instead. Double-click it; it needs no internet. |
128
+
129
+ ## How it works
130
+
131
+ ```text
132
+ cases.json + my_agent(input, model)
133
+ │
134
+ ▼
135
+ run_eval ── runs every case × model × repeat
136
+ │ calls your agent, times it, catches crashes,
137
+ │ runs the check (built-in or yours)
138
+ ▼
139
+ EvalLog ── writes evals.db
140
+ │ one batch per run_eval call
141
+ ▼
142
+ agent-eval-dashboard evals.db ── reads it, read-only
143
+ │
144
+ ▼
145
+ the page
146
+ ┌──────────────────┬──────────────────────────────────────┐
147
+ │ run list │ table: cases × models │
148
+ │ one entry per │ c01 PASS STABLE │
149
+ │ run_eval call, │ c02 FAIL FLAKY ◀── click │
150
+ │ newest first │ └─ panel: that model's runs │
151
+ └──────────────────┴──────────────────────────────────────┘
152
+ ```
153
+
154
+ **What a box in the table says:**
155
+
156
+ | Runs of that model in this batch | Box |
157
+ |---|---|
158
+ | 1 run | `PASS` or `FAIL` |
159
+ | several, all passed | `STABLE` |
160
+ | several, some passed | `FLAKY` (with the count, for example `1/2`) |
161
+ | several, none passed | `ALWAYS FAILS` |
162
+ | it crashed | grey `ERROR`, left out of the pass rate |
163
+
164
+ - Under the word: averages, for example `2.0k tok · 1.5 turns · 3.5 s`.
165
+ - Above the table: one card per model with score, cost per run, tokens per run and average time per case.
166
+ - **Click a box** to see the input, the expected tools, and every run of that model: its calls (expected tools shown in green), PASS/FAIL with the reason, cost, tokens, turns, time and answer.
167
+
168
+ **A batch never mixes with another batch.** So `run_eval(repeats=1)` called 3 times gives 3 entries with `PASS`/`FAIL`, never `FLAKY`. To check stability, use `repeats=3` in one call.
169
+
170
+ ## Architecture
171
+
172
+ ```text
173
+ src/agent_eval_dashboard/
174
+ runner.py run_eval + AgentResult: the loop, timing, crash handling,
175
+ cleaning the calls, the built-in check
176
+ recorder.py EvalLog: writes runs and cases into evals.db
177
+ report.py reads evals.db, groups runs into batches, works out every
178
+ word, score and average (all the logic)
179
+ template.html the page: plain HTML/CSS/JS, only draws, no logic
180
+ server.py the local server: one page at "/", made again on every refresh
181
+ cli.py the agent-eval-dashboard command: server, or -o file
182
+ ```
183
+
184
+ **evals.db** has 2 tables:
185
+
186
+ ```text
187
+ runs (one row per model × repeat) cases (one row per case, per run)
188
+ ───────────────────────────────── ─────────────────────────────────
189
+ run_id ◀────────────────────────────── run_id
190
+ batch_id (one per run_eval call) case_id, input, expected_tools
191
+ created_at called (tool calls, JSON)
192
+ experiment, model, label, harness verdict PASS / FAIL / ERROR
193
+ system_prompt, tools (JSON) reason, answer
194
+ cost_usd, tokens, turns, seconds
195
+ saved_at (for "last case saved … ago")
196
+ ```
197
+
198
+ **The rules:**
199
+
200
+ - **Standard library only.** Installing it adds nothing else to your project.
201
+ - **The viewer never writes the file.** It opens `evals.db` read-only.
202
+ - **Localhost only.** The server listens on `127.0.0.1`, serves only `/`, and answers only `GET`.
203
+ - **The page is rebuilt on every refresh.** The server and the `-o` file show the exact same page.
204
+
205
+ ## Your own check
206
+
207
+ Pass `check=` to decide PASS or FAIL yourself:
208
+
209
+ ```python
210
+ def check(case, result):
211
+ """case: the case dict, with any extra keys. result: the AgentResult, calls already cleaned."""
212
+ called = [c["tool"] for c in result.calls]
213
+ if called != case["expected_tools"]:
214
+ return False, f"called {called}"
215
+ if "1003" not in result.answer:
216
+ return False, "answer has no order number"
217
+ return True, "right tools, right answer"
218
+
219
+ run_eval(..., check=check) # sketch: the other arguments as in Quick start
220
+ ```
221
+
222
+ - It must return `(passed, reason)`: `passed` is `True` or `False`, `reason` is non-empty text.
223
+ - Use it for args, answer text, tool order, cost, or an AI judge.
224
+ - **The built-in check:** PASS when the set of called tool names equals the set of `expected_tools`. Order and duplicates are ignored. It does not look at the answer. Its reason is `All expected tools called`, `No tool needed, none called`, or for a FAIL `Missing tools: …` and/or `Extra tools: …`, one per line. The console prints a reason on one line, with ` · ` between its lines.
225
+
226
+ ## Details for `my_agent`
227
+
228
+ **Tokens:** count every token read or written.
229
+ - Anthropic: `input_tokens + cache_creation_input_tokens + cache_read_input_tokens + output_tokens`.
230
+ - OpenAI / LangChain: `total_tokens`.
231
+
232
+ **Turns:** the number of model calls in the case.
233
+
234
+ **Cost:** shown only when you give it. There is no price table.
235
+ - Claude Agent SDK: `total_cost_usd` from the result message.
236
+ - Others: work it out from tokens and your own prices, as in Quick start.
237
+
238
+ **Tools:** each item in `tools` needs `name` and `description`. Add `shown_name` when the model sees a different name than the one your code runs.
239
+
240
+ **The calls get cleaned** before the check and before saving:
241
+ - An `mcp__<server>__` prefix is removed: `mcp__shop__get_order` is saved as `get_order`.
242
+ - Args given as JSON text are parsed: `'{"order_id": "1003"}'` becomes `{"order_id": "1003"}`.
243
+
244
+ ## The other way in: `EvalLog` (your own loop)
245
+
246
+ Write the loop yourself. You run the agent, time it, and decide PASS or FAIL. One `EvalLog` is one run (one model, one pass over the cases).
247
+
248
+ ```python
249
+ import time
250
+ from agent_eval_dashboard import EvalLog
251
+
252
+ log = EvalLog(db="evals.db", experiment="exp03-tool-choice", model="claude-haiku-5-5",
253
+ harness="my-own-loop", label="clear tools",
254
+ tools=[{"name": "get_order", "description": "Look up one order by its ID."}])
255
+
256
+ for case in cases: # sketch: cases and run_my_agent are your own
257
+ start = time.perf_counter()
258
+ try:
259
+ calls, answer = run_my_agent(case["input"])
260
+ passed = {c["tool"] for c in calls} == set(case["expected_tools"])
261
+ log.case(case["case_id"], case["input"], case["expected_tools"], calls,
262
+ passed=passed, reason="same as expected" if passed else "different tools",
263
+ answer=answer, seconds=time.perf_counter() - start)
264
+ except Exception as e:
265
+ log.error(case["case_id"], case["input"], case["expected_tools"],
266
+ reason=f"{type(e).__name__}: {e}", seconds=time.perf_counter() - start)
267
+
268
+ log.close()
269
+ ```
270
+
271
+ - `log.case` also takes `cost_usd`, `tokens` and `turns`. All optional.
272
+ - `EvalLog` does not clean the calls. Pass real tool names and args as dicts.
273
+ - A missing or wrong value raises a `ValueError` at once, naming the value.
274
+ - **`batch=`:** each `EvalLog` is its own entry in the run list. To show several as one entry, give them the same text:
275
+
276
+ ```python
277
+ for model in MODELS:
278
+ log = EvalLog(db="evals.db", ..., model=model, batch="my-batch-1")
279
+ ```
280
+
281
+ ## FAQ
282
+
283
+ **What if something goes wrong in `run_eval`?**
284
+
285
+ | What happens | Result |
286
+ |---|---|
287
+ | A bad case or setting (missing key, duplicate `case_id`, empty `models`, `repeats` below 1) | Stops before any agent call. The message names the case or setting. |
288
+ | `my_agent` raises (for example a network error) | That case is `ERROR`, reason `"ExcType: message"`. The run goes on. |
289
+ | Args text is not valid JSON (the model cut off its output) | That case is `FAIL`, reason `args not valid JSON: ...`. The run goes on. |
290
+ | `my_agent` returns something that is not a valid `AgentResult` | Stops at once. The message names the case. |
291
+ | Your `check` raises | Stops at once. The message names the case. |
292
+ | Every case in a run is `ERROR` | Prints a warning: "check my_agent". |
293
+ | Ctrl+C | Stops. Cases finished so far are kept. |
294
+
295
+ When a run stops because of a bug in your code, nothing from that run is saved, so a half run never shows up on the page.
296
+
297
+ **Can I use it in Jupyter?** A normal (sync) agent works. An `async` agent inside an event loop that is already running is not supported yet: `run_eval` raises a clear error.
298
+
299
+ **My `evals.db` is old.** A file from before tokens, turns and seconds stops with "old evals.db, delete it". There is no migration. A file from before batches still works: its old runs are grouped into batches by experiment + label + harness.
300
+
301
+ **How do I compare 2 setups of the same model** (for example clear vs vague tool descriptions)? Call `run_eval` twice with 2 labels.
302
+
303
+ **What is not supported yet?**
304
+ - Grading answer text or an AI judge built in. Do it in your own `check=`.
305
+ - Per-agent detail for multi-agent workflows. A workflow is saved as one run, with all calls in one list.
306
+ - A built-in price table, or ready helpers for each agent framework.
307
+ - Hosting, logins, or history over months. Tools like Langfuse, Braintrust or LangSmith do that.
308
+
309
+ ## Run the tests
310
+
311
+ ```
312
+ uv run pytest
313
+ ```
@@ -0,0 +1,18 @@
1
+ [project]
2
+ name = "agent-eval-dashboard"
3
+ version = "0.1.0"
4
+ description = "Test your AI agent on many cases, models and repeats, and see what passes, fails or is flaky on a local dashboard."
5
+ readme = "README.md"
6
+ license = "MIT"
7
+ requires-python = ">=3.11"
8
+ dependencies = []
9
+
10
+ [project.scripts]
11
+ agent-eval-dashboard = "agent_eval_dashboard.cli:main"
12
+
13
+ [build-system]
14
+ requires = ["uv_build>=0.10,<0.11"]
15
+ build-backend = "uv_build"
16
+
17
+ [dependency-groups]
18
+ dev = ["pytest"]
@@ -0,0 +1,18 @@
1
+ [project]
2
+ name = "agent-eval-dashboard"
3
+ version = "0.1.0"
4
+ description = "Test your AI agent on many cases, models and repeats, and see what passes, fails or is flaky on a local dashboard."
5
+ readme = "README.md"
6
+ license = "MIT"
7
+ requires-python = ">=3.11"
8
+ dependencies = []
9
+
10
+ [project.scripts]
11
+ agent-eval-dashboard = "agent_eval_dashboard.cli:main"
12
+
13
+ [build-system]
14
+ requires = ["uv_build>=0.10,<0.11"]
15
+ build-backend = "uv_build"
16
+
17
+ [dependency-groups]
18
+ dev = ["pytest"]
@@ -0,0 +1,6 @@
1
+ """agent-eval-dashboard: save agent test results, then see them on one page."""
2
+
3
+ from agent_eval_dashboard.recorder import EvalLog
4
+ from agent_eval_dashboard.runner import AgentResult, run_eval
5
+
6
+ __all__ = ["AgentResult", "EvalLog", "run_eval"]