Repository navigation
382 lines (354 loc) · 15.2 KB
/
Copy path_eval.yml
File metadata and controls
382 lines (354 loc) · 15.2 KB
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
# Reusable workflow: one GHA eval run for a single model.
#
# Called by the per-provider matrix jobs in `evals.yml`. Inputs are validated
# upstream by `prep` (`_SAFE_SPEC_RE` in `.github/scripts/models.py`); this
# workflow trusts that contract.
name: "📊 Eval"
on:
workflow_call:
inputs:
model:
description: "Full model spec to evaluate."
required: true
type: string
provider:
description: "Provider prefix for the model spec."
required: true
type: string
artifact_key:
description: "Stable, artifact-safe suffix for uploaded reports."
required: true
type: string
eval_categories:
description: "Comma-separated eval categories to run."
required: false
default: ""
type: string
eval_categories_exclude:
description: "Comma-separated eval categories to skip."
required: false
default: ""
type: string
eval_tiers:
description: "Comma-separated eval tiers to run."
required: false
default: ""
type: string
analyze_failures:
description: "Run the LLM failure-analysis step after evals."
required: false
default: false
type: boolean
analysis_model:
description: "Model for failure analysis. Only used when `analyze_failures` is true."
required: false
default: "anthropic:claude-haiku-4-5-20251001"
type: string
openrouter_provider:
description: "Pin OpenRouter to one or more providers (comma-separated allowlist)."
required: false
default: ""
type: string
openrouter_allow_fallbacks:
description: "Allow OpenRouter to fall back outside `openrouter_provider`. Default is strict (no fallbacks)."
required: false
default: false
type: boolean
openai_reasoning_effort:
description: "Reasoning effort for OpenAI models (minimal | low | medium | high | xhigh)."
required: false
default: ""
type: string
repl:
description: "REPL middleware to use for `@pytest.mark.repl` tests (`quickjs` | `langchain`). Empty = bind tools directly."
required: false
default: ""
type: string
secrets:
ANTHROPIC_API_KEY:
required: false
BASETEN_API_KEY:
required: false
FIREWORKS_API_KEY:
required: false
GOOGLE_API_KEY:
required: false
GROQ_API_KEY:
required: false
LANGSMITH_API_KEY:
required: false
NVIDIA_API_KEY:
required: false
OLLAMA_API_KEY:
required: false
OPENAI_API_KEY:
required: false
OPENROUTER_API_KEY:
required: false
XAI_API_KEY:
required: false
permissions:
contents: read
env:
UV_NO_SYNC: "true"
UV_FROZEN: "true"
jobs:
eval:
# Carries the per-run detail (model · categories · tiers) so it appears in
# the matrix-job breadcrumb when the job actually runs. The outer caller
# in `evals.yml` is intentionally static — GHA does not evaluate `name:`
# expressions for jobs skipped via `if:`, so referencing `${{ matrix.* }}`
# there would render as raw template text in the UI.
name: "📊 ${{ inputs.model }} · ${{ inputs.eval_categories || 'all categories' }}${{ inputs.eval_categories_exclude && format(' excluding {0}', inputs.eval_categories_exclude) || '' }} · ${{ inputs.eval_tiers || 'all tiers' }}"
runs-on: ubuntu-latest
environment: evals
timeout-minutes: 360
defaults:
run:
working-directory: libs/evals
env:
PYTEST_ADDOPTS: "--evals-report-file evals_report.json"
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
BASETEN_API_KEY: ${{ secrets.BASETEN_API_KEY }}
FIREWORKS_API_KEY: ${{ secrets.FIREWORKS_API_KEY }}
GOOGLE_API_KEY: ${{ secrets.GOOGLE_API_KEY }}
GROQ_API_KEY: ${{ secrets.GROQ_API_KEY }}
LANGSMITH_API_KEY: ${{ secrets.LANGSMITH_API_KEY }}
LANGSMITH_TRACING: "true"
LANGSMITH_EXPERIMENT: ${{ inputs.model }}
NVIDIA_API_KEY: ${{ secrets.NVIDIA_API_KEY }}
OLLAMA_API_KEY: ${{ secrets.OLLAMA_API_KEY }}
OLLAMA_HOST: "https://ollama.com"
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
OPENROUTER_API_KEY: ${{ secrets.OPENROUTER_API_KEY }}
# Group all OpenRouter calls in this per-model eval job under a stable
# session ID derived from GHA runner env. Picked up by ChatOpenRouter
# via from_env (langchain-openrouter >= 0.2.2). Re-runs get a new
# session via run_attempt; different models get distinct sessions via
# artifact_key.
OPENROUTER_SESSION_ID: deepagents-evals-${{ github.run_id }}-${{ github.run_attempt }}-${{ inputs.artifact_key }}
XAI_API_KEY: ${{ secrets.XAI_API_KEY }}
steps:
- name: "📋 Checkout Code"
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- name: "🐍 Set up Python + UV"
uses: "./.github/actions/uv_setup"
with:
python-version: "3.12"
# Per-shard scope so parallel matrix jobs don't race on the same
# cache key. `artifact_key` is enforced unique by the matrix
# builder (`_artifact_key` in `.github/scripts/models.py`).
cache-suffix: evals-${{ inputs.artifact_key }}
working-directory: libs/evals
- name: "📦 Install Dependencies"
# `UV_FROZEN=true` already enforces lockfile use; uv 0.11 rejects
# combining that environment variable with `--locked`.
run: uv sync --group test
- name: "🏷️ Apply category filter"
if: inputs.eval_categories != ''
env:
EVAL_CATEGORIES: ${{ inputs.eval_categories }}
run: |
flags=()
IFS=',' read -ra cats <<< "${EVAL_CATEGORIES}"
for cat in "${cats[@]}"; do
cat=$(echo "$cat" | xargs)
[ -z "$cat" ] && continue
flags+=(--eval-category "$cat")
done
printf 'PYTEST_ADDOPTS=%s %s\n' "${PYTEST_ADDOPTS}" "${flags[*]}" >> "$GITHUB_ENV"
- name: "🏷️ Apply category exclude filter"
if: inputs.eval_categories_exclude != ''
env:
EVAL_CATEGORIES_EXCLUDE: ${{ inputs.eval_categories_exclude }}
run: |
flags=()
IFS=',' read -ra cats <<< "${EVAL_CATEGORIES_EXCLUDE}"
for cat in "${cats[@]}"; do
cat=$(echo "$cat" | xargs)
[ -z "$cat" ] && continue
flags+=(--eval-category-exclude "$cat")
done
printf 'PYTEST_ADDOPTS=%s %s\n' "${PYTEST_ADDOPTS}" "${flags[*]}" >> "$GITHUB_ENV"
- name: "🏷️ Apply tier filter"
if: inputs.eval_tiers != ''
env:
EVAL_TIERS: ${{ inputs.eval_tiers }}
run: |
flags=()
IFS=',' read -ra tiers <<< "${EVAL_TIERS}"
for tier in "${tiers[@]}"; do
tier=$(echo "$tier" | xargs)
[ -z "$tier" ] && continue
flags+=(--eval-tier "$tier")
done
printf 'PYTEST_ADDOPTS=%s %s\n' "${PYTEST_ADDOPTS}" "${flags[*]}" >> "$GITHUB_ENV"
- name: "🔒 Apply OpenRouter provider pin"
if: inputs.openrouter_provider != '' && inputs.provider == 'openrouter'
env:
OPENROUTER_PROVIDER: ${{ inputs.openrouter_provider }}
OPENROUTER_ALLOW_FALLBACKS: ${{ inputs.openrouter_allow_fallbacks }}
run: |
provider=$(echo "$OPENROUTER_PROVIDER" | xargs)
# Defense in depth: GitHub serializes typed `boolean` inputs as
# lowercase "true"/"false", but if this workflow is ever wired to
# a string-valued source (workflow_run payload, matrix string,
# caller-side env literal) the value could arrive as "True"/"1"/
# "yes". Normalize and fail loudly on anything unrecognized so a
# silent strict-pin never masquerades as a soft preference.
extra=""
case "${OPENROUTER_ALLOW_FALLBACKS,,}" in
true|1|yes)
extra=" --openrouter-allow-fallbacks"
;;
false|0|no|"")
;;
*)
echo "::error::Unrecognized openrouter_allow_fallbacks=${OPENROUTER_ALLOW_FALLBACKS}; expected true/false."
exit 1
;;
esac
printf 'PYTEST_ADDOPTS=%s --openrouter-provider %s%s\n' "${PYTEST_ADDOPTS}" "${provider}" "${extra}" >> "$GITHUB_ENV"
- name: "🧠 Apply OpenAI reasoning effort"
if: inputs.openai_reasoning_effort != '' && inputs.provider == 'openai'
env:
OPENAI_REASONING_EFFORT: ${{ inputs.openai_reasoning_effort }}
run: |
effort=$(echo "$OPENAI_REASONING_EFFORT" | xargs)
printf 'PYTEST_ADDOPTS=%s --openai-reasoning-effort %s\n' "${PYTEST_ADDOPTS}" "${effort}" >> "$GITHUB_ENV"
- name: "🧪 Apply REPL middleware"
# `repl` is `type: string` so a `workflow_call` caller could pass any
# value; the case below is the source of truth for accepted values.
# Keep the `repl` choice enums in `evals.yml` and `evals_trials.yml`
# in sync with this list.
if: inputs.repl != ''
env:
REPL: ${{ inputs.repl }}
run: |
repl=$(echo "$REPL" | xargs)
case "$repl" in
quickjs|langchain) ;;
*)
echo "::error::Unsupported repl value: ${repl}. Allowed: quickjs, langchain."
exit 1
;;
esac
printf 'PYTEST_ADDOPTS=%s --repl %s\n' "${PYTEST_ADDOPTS}" "${repl}" >> "$GITHUB_ENV"
- name: "📊 Run Evals"
env:
MODEL: ${{ inputs.model }}
run: make evals MODEL="$MODEL"
- name: "🔍 Check eval report"
if: "!cancelled()"
run: |
if [ ! -f evals_report.json ]; then
echo "::error::evals_report.json not found. pytest likely crashed before sessionfinish could write the report. Check the 'Run Evals' step logs for errors."
exit 1
fi
- name: "📊 Post results to summary"
if: "!cancelled()"
run: |
python3 << 'PYEOF'
import json, os, sys, traceback
from pathlib import Path
report_path = Path("evals_report.json")
# The upstream "Check eval report" step already emits ::error:: and
# exits 1 when this file is missing; exit 0 here so we don't
# double-fail the job.
if not report_path.exists():
print("evals_report.json not found, skipping summary", file=sys.stderr)
sys.exit(0)
try:
report = json.loads(report_path.read_text())
except (json.JSONDecodeError, UnicodeDecodeError) as exc:
print(f"::error::evals_report.json is malformed: {exc}")
sys.exit(1)
model = report.get("model", "unknown")
if model == "unknown":
print("::warning::evals_report.json has no 'model' key; using 'unknown'")
# Load category labels for friendly display names.
cats_json = Path("deepagents_evals/categories.json")
labels = {}
try:
labels = json.loads(cats_json.read_text()).get("labels", {})
except (FileNotFoundError, json.JSONDecodeError) as exc:
print(f"::warning::Could not load category labels from {cats_json}: {exc}")
lines = [
"<details>",
"<summary>(click to expand)</summary>",
"",
]
try:
# -- Metrics table --
metrics = [
("passed", None), ("failed", None), ("skipped", None),
("total", None), ("correctness", None), ("solve_rate", "n/a"),
("step_ratio", "n/a"), ("tool_call_ratio", "n/a"),
("median_duration_s", None),
]
header = "| " + " | ".join(f"`{k}`" for k, _ in metrics) + " |"
sep = "|" + "|".join("---:" for _ in metrics) + "|"
vals = []
for key, default in metrics:
val = report.get(key, default)
if val is None:
val = 0
vals.append(str(val))
row = "| " + " | ".join(vals) + " |"
lines += [header, sep, row]
# -- Per-category scores (horizontal) --
cat_scores = report.get("category_scores")
if isinstance(cat_scores, dict) and cat_scores:
sorted_cats = sorted(cat_scores.items())
def esc(s): return str(s).replace("|", "\\|")
cat_header = "| " + " | ".join(esc(labels.get(c, c)) for c, _ in sorted_cats) + " |"
cat_sep = "|" + "|".join("---:" for _ in sorted_cats) + "|"
cat_row = "| " + " | ".join(esc(s) for _, s in sorted_cats) + " |"
lines += ["", "### Per-category correctness", "", cat_header, cat_sep, cat_row]
# -- Experiment links --
exp_links = report.get("experiment_links")
if isinstance(exp_links, list) and exp_links:
lines += ["", "### LangSmith experiments", ""]
for link in exp_links:
if not isinstance(link, dict):
continue
name = link.get("name", "")
url = link.get("url", "")
public_url = link.get("public_url", "")
if public_url:
lines.append(f"- [{name}]({public_url}) ([internal]({url}))")
elif url:
lines.append(f"- [{name or url}]({url})")
except (KeyError, TypeError, ValueError, AttributeError) as exc:
tb = traceback.format_exc()
lines.append(f"\n\n**Error building summary:** `{exc}` (see job logs)\n")
print(f"::warning::Error building summary for {model}: {exc}\n{tb}")
finally:
lines += ["", "</details>"]
text = "\n".join(lines) + "\n"
summary = os.environ.get("GITHUB_STEP_SUMMARY", "")
if summary:
with open(summary, "a") as f:
f.write(text)
print(text)
PYEOF
- name: "🧠 Analyze eval failures"
if: ${{ !cancelled() && inputs.analyze_failures }}
continue-on-error: true
env:
ANALYSIS_MODEL: ${{ inputs.analysis_model }}
run: uv run python ../../.github/scripts/analyze_eval_failures.py evals_report.json
- name: "📤 Upload failure analysis"
if: ${{ !cancelled() && inputs.analyze_failures && hashFiles('libs/evals/failure_analysis.json') != '' }}
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
with:
name: failure-analysis-${{ inputs.artifact_key }}
path: libs/evals/failure_analysis.json
if-no-files-found: error
- name: "📤 Upload eval report"
if: "!cancelled()"
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
with:
name: evals-report-${{ inputs.artifact_key }}
path: libs/evals/evals_report.json
if-no-files-found: error