Skip to content

Python API

Reference for the agent_eval package, generated from the source docstrings and type hints. Most users drive the harness through the slash commands and eval.yaml — this page is for extending it (for example, writing a custom runner) or embedding it in your own tooling.

Autodoc

These entries are rendered by mkdocstrings. The documentation build runs pip install -e . so the package is importable; add more ::: directives to this page to surface additional modules.

Configuration

The entire eval.yaml surface is parsed into EvalConfig. See the eval.yaml reference for the YAML-level documentation of every field.

agent_eval.config.EvalConfig dataclass

EvalConfig(name='', description='', skill=None, permissions=dict(), hooks=HooksConfig(), execution=ExecutionConfig(), runner=RunnerConfig(), models=ModelsConfig(), mlflow=MlflowConfig(), dataset=DatasetConfig(), generation=GenerationConfig(), outputs=list(), inputs=InputsConfig(), traces=TracesConfig(), judges=list(), reward=None, thresholds=dict(), config_dir=None, config_path=None, model='', subagent_model='', run_id='', baseline='')

Complete evaluation suite configuration.

Structure is schema-driven: dataset and output structures are described in natural language. The harness interprets these descriptions via LLM (once, cached) to drive prepare, collect, and score steps.

project_root property

project_root

Project root directory (always CWD, not the eval.yaml location).

eval_name

eval_name()

Derive eval identifier with backward-compatible fallback chain.

Priority order (backward-compatible with existing skill evals): 1. skill field - preserves existing skill-based eval runs 2. name field - allows explicit naming for prompt-mode evals 3. directory/filename - pure path-based derivation 4. "eval" - final fallback

This ensures existing skill evals continue to work while enabling prompt mode to use either explicit names or path-based identifiers.

Source code in agent_eval/config.py
def eval_name(self) -> str:
    """Derive eval identifier with backward-compatible fallback chain.

    Priority order (backward-compatible with existing skill evals):
    1. skill field - preserves existing skill-based eval runs
    2. name field - allows explicit naming for prompt-mode evals
    3. directory/filename - pure path-based derivation
    4. "eval" - final fallback

    This ensures existing skill evals continue to work while enabling
    prompt mode to use either explicit names or path-based identifiers.
    """
    # Priority 1: skill field (backward compat with existing evals).
    # Resolve through resolve_skill() so execution.skill-only configs
    # still name the run after the skill under test.
    skill = self.resolve_skill()
    if skill:
        return skill

    # Priority 2: name field (explicit identifier, sanitized)
    # Skip if name == path.stem (auto-set default from from_yaml)
    if self.name and not (self.config_path and self.name == self.config_path.stem):
        # Sanitize: convert spaces to hyphens, keep only safe chars
        sanitized = self.name.lower().replace(" ", "-")
        sanitized = "".join(c for c in sanitized if c.isalnum() or c in "._-")
        if sanitized and _is_valid_eval_name(sanitized):
            return sanitized

    # Priority 3: derive from path (new behavior for prompt mode)
    if self.config_path:
        if self.config_path.name == "eval.yaml":
            # Nested: eval/user-guides/eval.yaml → "user-guides"
            # Check if grandparent directory is named "eval"
            if self.config_path.parent.parent.name == "eval":
                return self.config_path.parent.name
            # Root: eval.yaml at project root → "eval"
            else:
                return "eval"
        # Flat: eval/user-guides.yaml → "user-guides"
        else:
            return self.config_path.stem

    # Final fallback
    return "eval"

from_yaml classmethod

from_yaml(path)

Load config from a YAML file.

Source code in agent_eval/config.py
 992
 993
 994
 995
 996
 997
 998
 999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
@classmethod
def from_yaml(cls, path: str | Path) -> "EvalConfig":
    """Load config from a YAML file."""
    path = Path(path)
    if not path.exists():
        raise FileNotFoundError(f"Config not found: {path}")

    with open(path) as f:
        raw = yaml.safe_load(f) or {}

    # Deprecation: top-level `skill:` is auto-normalized into
    # execution.skill (below) but the canonical home is the execution
    # block, symmetric with execution.prompt. Warn once per load; only
    # for a non-empty value that isn't already mirrored in execution.
    exec_raw = raw.get("execution", {})
    if raw.get("skill") and not (exec_raw.get("skill") or "").strip():
        import warnings
        warnings.warn(
            f"Top-level 'skill:' in {path} is deprecated; move it under "
            "execution.skill (it is auto-normalized for now and will be "
            "removed in a future release).",
            DeprecationWarning,
            stacklevel=2,
        )

    # Dataset
    dataset = raw.get("dataset", {})

    # Execution config — including an optional multi-step pipeline.
    steps = []
    for i, s in enumerate(exec_raw.get("steps") or []):
        if not isinstance(s, dict):
            raise ValueError(f"execution.steps[{i}] must be a mapping")
        step_runner = None
        if s.get("runner"):
            step_runner = _parse_runner_config(
                s.get("runner"), context=f"execution.steps[{i}].runner")
        step_env = s.get("env") or {}
        if not isinstance(step_env, dict):
            raise ValueError(
                f"execution.steps[{i}].env must be a mapping")
        step_timeout = s.get("timeout")
        if step_timeout is not None and (
                not isinstance(step_timeout, int)
                or isinstance(step_timeout, bool)
                or step_timeout <= 0):
            raise ValueError(
                f"execution.steps[{i}].timeout must be a positive integer")
        step_budget = s.get("max_budget_usd")
        if step_budget is not None and (
                not isinstance(step_budget, (int, float))
                or isinstance(step_budget, bool)
                or step_budget < 0):
            raise ValueError(
                f"execution.steps[{i}].max_budget_usd must be a "
                "non-negative number")
        step = StepConfig(
            id=s.get("id", "") or "",
            name=s.get("name", "") or "",
            skill=s.get("skill", "") or "",
            prompt=s.get("prompt", "") or "",
            arguments=s.get("arguments", "") or "",
            env=step_env,
            timeout=step_timeout,
            max_budget_usd=step_budget,
            runner=step_runner,
            on_failure=s.get("on_failure", "fail"),
        )
        if not ((step.skill and step.skill.strip())
                or (step.prompt and step.prompt.strip())):
            raise ValueError(
                f"execution.steps[{i}] ('{step.id}') must set either "
                "skill or prompt")
        steps.append(step)

    execution = ExecutionConfig(
        mode=exec_raw.get("mode", "case"),
        skill=exec_raw.get("skill", "") or raw.get("skill", ""),
        prompt=exec_raw.get("prompt", ""),
        arguments=exec_raw.get("arguments", ""),
        timeout=exec_raw.get("timeout"),
        max_budget_usd=exec_raw.get("max_budget_usd"),
        parallelism=exec_raw.get("parallelism"),
        env=exec_raw.get("env") or {},
        steps=steps,
    )

    # Runner config (block form)
    runner = _parse_runner_config(raw.get("runner"), context="runner")

    # Models block
    models_raw = raw.get("models", {}) or {}
    models = ModelsConfig(
        skill=models_raw.get("skill"),
        subagent=models_raw.get("subagent"),
        judge=models_raw.get("judge"),
        hook=models_raw.get("hook"),
    )

    # MLflow block. Experiment defaults to the eval's top-level
    # `name` only when an `mlflow:` block is present — so omitting
    # the block entirely leaves MLflow off (no accidental experiment
    # creation on shared tracking servers).
    has_mlflow_block = "mlflow" in raw and raw["mlflow"] is not None
    mlflow_raw = raw.get("mlflow") or {}
    if has_mlflow_block:
        experiment = mlflow_raw.get("experiment") or raw.get("name", "")
    else:
        experiment = ""
    mlflow = MlflowConfig(
        experiment=experiment,
        tracking_uri=mlflow_raw.get("tracking_uri"),
        tags=mlflow_raw.get("tags", {}) or {},
    )

    # Dataset — path, schema, and workspace file provisioning
    ws_raw = dataset.get("workspace", {}) or {}
    ws_files_raw = ws_raw.get("files", []) or []
    ws_files = []
    for i, f in enumerate(ws_files_raw):
        if not isinstance(f, str):
            raise ValueError(
                f"dataset.workspace.files[{i}] must be a string, got {type(f).__name__}"
            )
        ws_files.append(
            _validate_relative_path(f.rstrip("/"), "dataset.workspace.files")
        )
    dataset_config = DatasetConfig(
        path=_validate_relative_path(
            dataset.get("path", ""), "dataset.path", allow_absolute=True
        ),
        schema=dataset.get("schema", ""),
        workspace=WorkspaceConfig(files=ws_files),
    )
    # Generation — synthetic test-case generation (optional) with validation
    gen_raw = raw.get("generation") or {}
    seeds = []
    for i, s in enumerate(gen_raw.get("seeds") or []):
        category = s.get("category", "")
        count = s.get("count")
        if not category or not isinstance(category, str):
            raise ValueError(
                f"generation.seeds[{i}].category must be a non-empty string, got: {category!r}")
        # count is required — a silent default would swallow a mistyped field name
        if not isinstance(count, int) or count < 1:
            raise ValueError(
                f"generation.seeds[{i}].count must be an integer >= 1, got: {count!r}")

        # Exactly one prompt discriminator (mirrors judges: builtin/prompt_file/prompt)
        discriminators = [
            k for k in ("builtin", "prompt_file", "prompt") if s.get(k)
        ]
        if len(discriminators) != 1:
            raise ValueError(
                f"generation.seeds[{i}] ('{category}') must set exactly one of "
                f"builtin / prompt_file / prompt, got: {discriminators or 'none'}")

        seeds.append(GenerationSeed(
            category=category,
            count=count,
            builtin=s.get("builtin", ""),
            prompt_file=s.get("prompt_file", ""),
            prompt=s.get("prompt", ""),
            description=s.get("description", ""),
        ))

    # Provenance: absent normalizes to 'skill' (the default source).
    strategy = gen_raw.get("strategy") or "skill"
    if strategy not in GENERATION_STRATEGIES:
        raise ValueError(
            f"generation.strategy must be one of "
            f"{', '.join(GENERATION_STRATEGIES)}, got: {strategy!r}")
    if strategy == "synthetic" and not seeds:
        raise ValueError(
            "generation.strategy is 'synthetic' but generation.seeds is empty.")
    if seeds and strategy != "synthetic":
        raise ValueError(
            f"generation.seeds are only valid with strategy: synthetic "
            f"(got strategy: {strategy}).")

    generation_config = GenerationConfig(
        strategy=strategy,
        context=gen_raw.get("context", {}),
        seeds=seeds,
    )

    config = cls(
        name=raw.get("name", path.stem),
        description=raw.get("description", ""),
        skill=raw.get("skill") or None,  # Convert empty string to None
        permissions=raw.get("permissions", {}),
        execution=execution,
        runner=runner,
        models=models,
        mlflow=mlflow,
        config_dir=path.resolve().parent,
        config_path=path.resolve(),
        dataset=dataset_config,
        generation=generation_config,
    )

    # Outputs (path or tool)
    for i, o in enumerate(raw.get("outputs", [])):
        config.outputs.append(
            OutputConfig(
                path=_validate_relative_path(
                    o.get("path", ""), f"outputs[{i}].path", reject_root=True
                ),
                tool=o.get("tool", ""),
                schema=o.get("schema", ""),
                batch_pattern=o.get("batch_pattern", ""),
                types=o.get("types") or None,
            )
        )

    # Inputs (tool interception)
    inputs_raw = raw.get("inputs", {})
    for t in inputs_raw.get("tools") or []:
        config.inputs.tools.append(
            ToolInputConfig(
                match=t.get("match", ""),
                prompt=t.get("prompt", ""),
                prompt_file=t.get("prompt_file", ""),
            )
        )

    # Traces
    traces = raw.get("traces", {})
    if traces:
        config.traces = TracesConfig(
            stdout=traces.get("stdout", True),
            stderr=traces.get("stderr", True),
            events=traces.get("events", True),
            metrics=traces.get("metrics", True),
        )

    # Judges
    for j in raw.get("judges", []):
        builtin_val = j.get("builtin", "")
        if builtin_val is None:
            builtin_val = ""
        if not isinstance(builtin_val, str):
            raise ValueError(
                f"Judge '{j.get('name', '')}': 'builtin' must be a string"
            )
        args_val = j.get("arguments")
        if args_val is None:
            args_val = {}
        elif not isinstance(args_val, dict):
            raise ValueError(
                f"Judge '{j.get('name', '')}': 'arguments' must be a mapping"
            )
        agent_val = j.get("agent")
        if agent_val is None:
            agent_val = {}
        elif not isinstance(agent_val, dict):
            raise ValueError(
                f"Judge '{j.get('name', '')}': 'agent' must be a mapping"
            )
        elif agent_val.get("runner") is not None:
            # Parse the nested runner: sub-block with the SAME block-parsing
            # logic as the top-level runner, so a judge's runner is fully
            # validated. Shallow-copy so the raw YAML isn't mutated.
            if not isinstance(agent_val["runner"], dict):
                raise ValueError(
                    f"Judge '{j.get('name', '')}': 'agent.runner' must be a mapping"
                )
            agent_val = dict(agent_val)
            agent_val["runner"] = _parse_runner_config(
                agent_val["runner"],
                context=f"Judge '{j.get('name', '')}': agent.runner",
            )
        score_range_val = j.get("score_range")
        if score_range_val is not None:
            jname = j.get("name", "")
            if (not isinstance(score_range_val, list)
                    or len(score_range_val) != 2):
                raise ValueError(
                    f"Judge '{jname}': 'score_range' must be a [min, max] list")
            try:
                lo, hi = float(score_range_val[0]), float(score_range_val[1])
            except (TypeError, ValueError) as exc:
                raise ValueError(
                    f"Judge '{jname}': 'score_range' values must be numeric") from exc
            if not (math.isfinite(lo) and math.isfinite(hi)) or lo >= hi:
                raise ValueError(
                    f"Judge '{jname}': 'score_range' must be finite and "
                    "increasing [min, max]")
            score_range_val = [lo, hi]
        config.judges.append(
            JudgeConfig(
                name=j.get("name", ""),
                description=j.get("description", ""),
                condition=j.get("if", ""),
                check=j.get("check", ""),
                prompt=j.get("prompt", ""),
                prompt_file=j.get("prompt_file", ""),
                llm_rubric=j.get("llm_rubric", ""),
                context=j.get("context", []),
                feedback_type=j.get("feedback_type", ""),
                score_range=score_range_val,
                model=j.get("model", ""),
                module=j.get("module", ""),
                function=j.get("function", ""),
                builtin=builtin_val,
                arguments=args_val,
                step=j.get("step", "") or "",
                samples=int(j.get("samples", 1)),
                agent=agent_val,
            )
        )

    # Per-step judge scoping: a judge's `step:` must name a defined
    # execution step (fail loud on typos, like reward.judge validation).
    step_ids = {s.id for s in execution.steps}
    for jc in config.judges:
        if not jc.step:
            continue
        if not execution.steps:
            raise ValueError(
                f"Judge '{jc.name}': 'step: {jc.step}' requires an "
                "execution.steps pipeline")
        if jc.step not in step_ids:
            raise ValueError(
                f"Judge '{jc.name}': 'step: {jc.step}' does not match any "
                f"execution step id ({sorted(step_ids)})")

    # Scale coherence: a judge's declared scale has to agree with its
    # feedback_type and with the scorer that will actually run it. Each of
    # these used to be accepted and then quietly ignored at scoring time,
    # which is how a judge shipped scoring on a scale nobody declared.
    from agent_eval.judges import builtin_judge_kind, builtin_judge_names

    for jc in config.judges:
        builtin_kind = builtin_judge_kind(jc.builtin) if jc.builtin else None
        if jc.builtin and builtin_kind is None:
            raise ValueError(
                f"Judge '{jc.name}': unknown builtin judge '{jc.builtin}' "
                f"(available: {', '.join(builtin_judge_names())})")
        if jc.feedback_type == "bool" and jc.score_range:
            raise ValueError(
                f"Judge '{jc.name}': 'score_range' has no meaning with "
                "'feedback_type: bool' (the verdict is pass/fail) — "
                "drop one of the two")
        if (jc.feedback_type == "int" and jc.score_range
                and any(float(b) != int(b) for b in jc.score_range)):
            raise ValueError(
                f"Judge '{jc.name}': 'feedback_type: int' cannot express "
                f"the fractional 'score_range' {jc.score_range} — use "
                "'feedback_type: float'")
        if (builtin_kind == "llm"
                and (jc.feedback_type not in ("", "bool") or jc.score_range)):
            raise ValueError(
                f"Judge '{jc.name}': builtin LLM judge '{jc.builtin}' is "
                "always scored as pass/fail, so 'feedback_type'/"
                "'score_range' would be silently ignored")
        # `feedback_type` is optional, and score.py's `_numeric_bounds`
        # treats anything that is not "bool" as numeric — so the judge that
        # most needs this warning is the one that declares neither field,
        # and gating on ("int", "float") alone never reached it.
        # The judge named "pairwise" is exempt: score.py routes it past
        # the numeric path by that name into the A/B/tie verdict flow, so
        # no scale — declared or defaulted — is ever applied to it.
        if (jc.feedback_type in ("int", "float", "") and not jc.score_range
                and not jc.builtin and jc.name != "pairwise"
                and (jc.prompt or jc.prompt_file or jc.llm_rubric)):
            import warnings
            warnings.warn(
                f"Judge '{jc.name}': numeric judge has no 'score_range', "
                "so it is scored on the unenforced [1, 5] default — "
                "declare one to have the returned value checked",
                stacklevel=2)

    # Reward composition
    if "reward" in raw:
        reward_raw = raw.get("reward")
        if not isinstance(reward_raw, dict):
            raise ValueError("reward must be a mapping when provided")
        sr = reward_raw.get("score_range")
        reward_score_range = None
        if sr is not None:
            if not isinstance(sr, list) or len(sr) != 2:
                raise ValueError(
                    "reward.score_range must be a [min, max] list")
            try:
                score_min = float(sr[0])
                score_max = float(sr[1])
            except (TypeError, ValueError) as exc:
                raise ValueError(
                    "reward.score_range values must be numeric") from exc
            if (not (math.isfinite(score_min) and math.isfinite(score_max))
                    or score_min >= score_max):
                raise ValueError(
                    "reward.score_range must be finite and increasing "
                    "[min, max]")
            reward_score_range = [score_min, score_max]
        weights = reward_raw.get("weights", {}) or {}
        if not isinstance(weights, dict):
            raise ValueError("reward.weights must be a mapping")
        try:
            weights = {str(k): float(v) for k, v in weights.items()}
        except (TypeError, ValueError) as exc:
            raise ValueError(
                "reward.weights values must be numeric") from exc
        if any(v < 0 for v in weights.values()):
            raise ValueError("reward.weights values must be non-negative")
        raw_list = reward_raw.get("raw", []) or []
        if not isinstance(raw_list, list):
            raw_list = [raw_list]
        # Single-judge mode: one judge's value is the reward. Mutually
        # exclusive with the composition inputs.
        judge = reward_raw.get("judge")
        if judge is not None:
            if not isinstance(judge, str) or not judge.strip():
                raise ValueError(
                    "reward.judge must be a non-empty judge name")
            conflicting = [k for k in ("formula", "weights", "raw")
                           if k in reward_raw]
            if conflicting:
                raise ValueError(
                    "reward.judge cannot be combined with "
                    f"{'/'.join(conflicting)}")
            judge_names = {j.name for j in config.judges if j.name}
            if judge not in judge_names:
                raise ValueError(
                    f"reward.judge '{judge}' does not match any defined "
                    "judge")
        normalize = reward_raw.get("normalize", False)
        if not isinstance(normalize, bool):
            raise ValueError("reward.normalize must be a boolean")
        # gate defaults to False in judge mode, True for composition.
        gate = reward_raw.get("gate", judge is None)
        if not isinstance(gate, bool):
            raise ValueError("reward.gate must be a boolean")
        formula = str(reward_raw.get("formula", "weighted"))
        # Validate expression formulas now so a typo or unsafe construct
        # fails loudly here, not silently as reward 0.0 on every case at
        # run time. Bare references ("weighted") are resolved at compute
        # time, so skip the expression check for them. Skipped in judge
        # mode, where formula is unused.
        if judge is None and not re.fullmatch(
                r"[A-Za-z_][\w.\-]*", formula.strip()):
            from agent_eval.harbor.reward import validate_formula
            try:
                validate_formula(formula)
            except ValueError as exc:
                raise ValueError(
                    f"reward.formula is invalid: {exc}") from exc
        config.reward = RewardConfig(
            formula=formula,
            weights=weights,
            gate=gate,
            score_range=reward_score_range,
            raw=[str(r) for r in raw_list],
            judge=judge,
            normalize=normalize,
        )
        if sr is not None:
            _warn_reward_range_precedence(config)
        _warn_reward_judge_clamp(config)

    # Thresholds
    config.thresholds = raw.get("thresholds", {})

    # Hooks
    hooks_raw = raw.get("hooks", {}) or {}
    phases = ["before_all", "before_each", "after_each", "before_step",
              "after_step", "before_scoring", "after_all", "before_report"]
    for phase in phases:
        entries = []
        for h in (hooks_raw.get(phase) or []):
            on_failure_val = h.get("on_failure", "fail")
            if on_failure_val not in ("fail", "continue"):
                raise ValueError(
                    f"hooks.{phase}: on_failure must be 'fail' or "
                    f"'continue', got '{on_failure_val}'")
            timeout_val = h.get("timeout", 120)
            if not isinstance(timeout_val, int) or timeout_val <= 0:
                raise ValueError(
                    f"hooks.{phase}: timeout must be a positive "
                    f"integer, got {timeout_val}")
            entries.append(HookEntry(
                command=h.get("command", ""),
                timeout=timeout_val,
                description=h.get("description", ""),
                on_failure=on_failure_val,
                condition=h.get("condition", ""),
            ))
        setattr(config.hooks, phase, entries)

    if config.execution.mode == "batch":
        per_case = []
        if config.hooks.before_each:
            per_case.append("before_each")
        if config.hooks.after_each:
            per_case.append("after_each")
        if config.hooks.before_step:
            per_case.append("before_step")
        if config.hooks.after_step:
            per_case.append("after_step")
        if per_case:
            import warnings
            warnings.warn(
                f"hooks.{', '.join(per_case)} ignored in batch mode "
                f"(per-case hooks only run in case/prompt mode)",
                stacklevel=2,
            )

    resolved_skill = config.resolve_skill()
    if resolved_skill:
        try:
            _validate_path_segment(resolved_skill, f"skill name in {path}")
        except ValueError as e:
            raise ValueError(str(e)) from e

    codex_runners = [config.runner]
    codex_runners.extend(
        step.runner for step in config.execution.steps if step.runner)
    codex_runners = [runner for runner in codex_runners
                     if runner.type == "codex"]
    if codex_runners and config.inputs.tools:
        raise ValueError(
            "runner.type 'codex' does not support inputs.tools interception; "
            "use claude-code or remove the tool interceptors")
    if any(runner.workspace_mode == "repo" for runner in codex_runners):
        raise ValueError(
            "runner.type 'codex' does not support workspace_mode: repo "
            "because repository answer-key protections cannot be enforced")

    return config

is_prompt_mode

is_prompt_mode()

True when the eval runs a direct prompt (no skill wrapper).

Source code in agent_eval/config.py
def is_prompt_mode(self) -> bool:
    """True when the eval runs a direct prompt (no skill wrapper)."""
    return bool(self.execution.prompt and self.execution.prompt.strip())

resolve_path

resolve_path(relative)

Resolve a path relative to the config file's directory.

Absolute paths are returned as-is. Relative paths resolve against config_dir (falling back to cwd when config_dir is None).

Source code in agent_eval/config.py
def resolve_path(self, relative: Path | str) -> Path:
    """Resolve a path relative to the config file's directory.

    Absolute paths are returned as-is. Relative paths resolve against
    config_dir (falling back to cwd when config_dir is None).
    """
    p = Path(relative)
    if p.is_absolute():
        return p
    base = self.config_dir if self.config_dir is not None else Path.cwd()
    return base / p

resolve_skill

resolve_skill()

Canonical skill name for skill mode, or None for prompt mode.

Prefers execution.skill (the current location) and falls back to the deprecated top-level skill field. Returns None when neither is set — i.e. prompt mode or an unconfigured target. All execution substrates (local, Harbor, EvalHub) MUST resolve the target through this method so a config authored with only execution.skill runs the skill instead of silently degrading to prompt mode.

Source code in agent_eval/config.py
def resolve_skill(self) -> Optional[str]:
    """Canonical skill name for skill mode, or None for prompt mode.

    Prefers ``execution.skill`` (the current location) and falls back to
    the deprecated top-level ``skill`` field.  Returns None when neither
    is set — i.e. prompt mode or an unconfigured target.  All execution
    substrates (local, Harbor, EvalHub) MUST resolve the target through
    this method so a config authored with only ``execution.skill`` runs
    the skill instead of silently degrading to prompt mode.
    """
    return self.execution.skill or self.skill or None

Runners

A runner adapts a generic evaluation call to a specific agent runtime and returns a normalized RunResult. To support a new agent, subclass EvalRunner, implement the three abstract members below, and register it in the RUNNERS registry — see Runners.

agent_eval/agent/base.py
class EvalRunner(ABC):
    """Abstract runner -- one implementation per agent platform."""

    @classmethod
    @abstractmethod
    def from_config(cls, config, *, log_prefix=None, **overrides):
        """Construct a runner from an EvalConfig."""

    @property
    @abstractmethod
    def name(self) -> str:
        """Short identifier for this runner (e.g. 'claude-code')."""

    @abstractmethod
    def execute(self, target, args, workspace, model, ...) -> RunResult:
        """Run one invocation and return a normalized RunResult."""

Every runner returns the same normalized result, so scoring and reporting are runner-agnostic:

agent_eval.agent.base.RunResult dataclass

RunResult(exit_code, stdout, stderr, duration_s, token_usage=None, cost_usd=None, num_turns=None, resolved_model=None, models_used=None, per_model_usage=None, per_model_turns=None, permission_denials=None, raw_output=None)

Result of a single skill invocation.