python-yama 0.7.0__py3-none-any.whl → 0.9.0__py3-none-any.whl

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-yama
3
- Version: 0.7.0
3
+ Version: 0.9.0
4
4
  Summary: A reproducible evaluation runner for tool-using Agent skills
5
5
  Project-URL: Repository, https://github.com/world-sim-dev/yama
6
6
  Project-URL: Issues, https://github.com/world-sim-dev/yama/issues
@@ -103,6 +103,7 @@ uv run --project yama yama --plugin dingding-simple --report
103
103
  | `--list` | Only print the collected Cases, without running them |
104
104
  | `--no-artifacts` | Write no artifact files at all |
105
105
  | `--json` | Emit machine-readable JSON instead of Rich tables |
106
+ | `pr-run --upload-report --commit-id SHA` | With `--report`, upload the push report and merge/upload affected Plugin latest reports; requires `ADMIN_HOST` and `YAMA_EVAL_REPORT_API_TOKEN` |
106
107
 
107
108
  `--plugin`, `--all-plugins`, and `--plugin-root` are mutually exclusive. When none of them is given, yama walks up from the current directory to the nearest directory containing `yama.toml` and uses it as the workspace root (falling back to the cwd), running it as a single plugin root.
108
109
 
@@ -114,6 +115,21 @@ uv run --project yama yama dashboard --plugin dingding-simple
114
115
 
115
116
  `yama dashboard` starts a local HTTP server (default `http://127.0.0.1:8765/`, change with `--host`/`--port`; it also accepts the same plugin selection flags as the main command plus `-k/--filter` and `--result-dir`). The index page lists the historical HTML reports accumulated under `.yama/reports/` (newest first, with the `latest` one flagged), `/reports/<name>` serves each report, and `/preview` renders the same case preview as `--preview` — re-collecting and re-resolving the case files on every refresh (collection errors render as an error page), so you can edit a Case YAML and just reload the browser. No LLM calls are ever made by the dashboard.
116
117
 
118
+ ### PR evals
119
+
120
+ ```bash
121
+ uv run --project yama yama pr-plan --base origin/main --json
122
+ OPENAI_API_KEY=... uv run --project yama yama pr-run --base origin/main --report --json-summary yama-pr-summary.json
123
+ ```
124
+
125
+ `yama pr-plan` selects PR-scoped eval cases without model calls. `yama pr-run` executes the same selection and writes a JSON summary for external CI jobs to render or upload; credentials stay in environment variables or `.env`, not CLI flags. `pr-run` always forces builtin bash execution to the Linux `linux-bubblewrap` sandbox, regardless of Case backend settings, so the runner must be Linux with `bwrap`/`bubblewrap` installed. See the [CI integration guide](https://github.com/world-sim-dev/yama/blob/main/docs/pr-evals-ci-integration.zh-CN.md) for workflow examples and the summary JSON contract.
126
+
127
+ For CI environments that publish reports to the Yama Eval Report service, add
128
+ `--upload-report --commit-id <sha>` together with `--report`. The command reads
129
+ `ADMIN_HOST` and `YAMA_EVAL_REPORT_API_TOKEN` from the environment, uploads the
130
+ current commit report, then updates each affected Plugin latest report by merging
131
+ the just-run cases into the previous remote Plugin report.
132
+
117
133
  ### Output
118
134
 
119
135
  Cases run in parallel, up to 10 at a time by default (`--concurrency` changes the cap); runs within one case stay sequential, and results keep collection order regardless of completion order. While several cases run concurrently, a transient dashboard at the bottom of the terminal shows one row per case, updated in place — waiting, then a spinner with the run/step currently executing, then its ✓/✗ verdict — and each case's full run/step detail is printed above the dashboard as one block the moment it finishes, so blocks of different cases never interleave. With `--concurrency 1` (or a single collected case) it streams instead — a spinner marks the step currently executing (on a terminal), and each case, run, and assertion result is printed the moment it completes. Either way a per-case summary table closes the output, and with `--json` the progress stream goes to stderr so stdout stays valid JSON.
@@ -1,30 +1,33 @@
1
1
  yama/__init__.py,sha256=UYhoZTSu1HiMT54LOZCdvLKMQ_L0qec8RT8jDfde_cY,1156
2
2
  yama/__main__.py,sha256=k1ocEWawweo1qCJWNFAAvyxz3tcY13dzvCenHszij30,48
3
3
  yama/assertions.py,sha256=9tp_fuoFxqHPrClq_D1WF4i58TxgZUMnTdc-Kc9uKiw,23000
4
- yama/cli.py,sha256=bM1w8AbSzLkaAKypznIfhGA0iWKbpN8BoS0a4G9vCpI,38032
4
+ yama/cli.py,sha256=kCpMWY_USb4C6qKwAmfWUmDzVlXxSw526EU6yAJeo3c,47320
5
5
  yama/dashboard.py,sha256=0yxRh-j_5Mk6Ug_xgv9-VyBSEr1aVKxX-zJwxGfd_TU,11601
6
6
  yama/llm.py,sha256=JzQ4YHhBLd1WE8W_ipTVcoNK6f-nSqRKDzqEl5kmuis,16085
7
7
  yama/mocks.py,sha256=YyiU6Y7NgttxHYJBsqGPILKYlTsM4IMTIilMNRkUuzs,14973
8
8
  yama/models.py,sha256=zd8RIxvUoWa3OdCLIRtgLvYmCVtkAjhQECJheo3HmKE,4128
9
+ yama/pr.py,sha256=ao27i5T5V0I16FFN3A7tX0dGvctc8Zqj2YhufX7isdI,11762
9
10
  yama/preview.py,sha256=gVTMqArXQqOLktGnactK9c0kfX6oHd6fWGjhkB7-QLQ,14220
10
- yama/report.py,sha256=WVY4EWInVQbE-Pv2LFHcH-QMoPFpdOd5unDs4uGEq-w,64557
11
+ yama/report.py,sha256=gzVGkfkhms5ABMvaHXYBAibyrVQFs-7jf_fUZeeE0ro,74587
12
+ yama/report_bundle.py,sha256=Y6ZaBTieSvnokq6s447uhbv7cxvlNr3kpX4WPp7a7bk,7477
13
+ yama/report_upload.py,sha256=GLmUJPHJNH7g5IhvaznJbnEYJAfccUSuOAMrM-WH7Ec,10840
11
14
  yama/runner.py,sha256=e3vIBgYBAbhRzG7aUTb9YKw5HJlEUWdpASIDwav1RGQ,38942
12
- yama/thread_case.py,sha256=9TvZxbzqk3Klihq9ghyRcyhv63HSkjEMQgrOEf26L4g,13171
15
+ yama/thread_case.py,sha256=WZzF4va44aRUkJ4DxP3m9F1A219AhwKQHG5fi9-tPqQ,13106
13
16
  yama/workspace.py,sha256=4GAe36Uj1-gjROMPwrQfTIg1TkzEIk9-gHEuezjbY_I,4614
14
17
  yama/loaders/__init__.py,sha256=DIwfa8QlIlKt6NpFMZJ_OcqbJPPrmKLBzd9_e-BCuBs,174
15
- yama/loaders/case.py,sha256=5uUpXm1t9EOmee2BZe7vDGXCrc4CSgcFGApSkuFe5tc,13954
18
+ yama/loaders/case.py,sha256=ADiaX6REgIMDlvIJWG4fV-Gj4RIy7TJ2Tr7eNrM3fq0,15190
16
19
  yama/loaders/common.py,sha256=Fg71_vcnu5339QI_itvYPvRbk9LtBgEnzoA3t4Krb4U,754
17
- yama/loaders/tool_loader.py,sha256=AaJwrFEjmfdUhKqXIlfl_jyvaKQ4ZoPPOpT8Wg5xuNU,12574
20
+ yama/loaders/tool_loader.py,sha256=J_p8jb_GgL_2X-_2teKHzLer9TWKh0FUuzXsEBZ8nTU,12917
18
21
  yama/tools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
19
22
  yama/tools/base.py,sha256=ONFuGzTSWVsA0k4-UUREncqAHmyQI2uHpVOU2Dh_XiQ,446
20
23
  yama/tools/bash/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
21
24
  yama/tools/bash/_cli_shim.py,sha256=f3Rom5UipW0dA0KRYavqIa9HJDKT336ssDZGWeVmkvo,2494
22
- yama/tools/bash/bash.py,sha256=4GlFvmqTUS4k6DgJ5Io91YF5fB6wF6e3e7p2P-pmbEQ,10358
23
- yama/tools/bash/fs.py,sha256=GChDwGe_Sgn73btZJDNp5nOwlVDhLfZyaMVqWSQwfOw,21859
25
+ yama/tools/bash/bash.py,sha256=dGKi2EvftnLs3CrJlbo4IYm6aicWrEnFzrXoH0vYqGw,10451
26
+ yama/tools/bash/fs.py,sha256=gPsdiTomnURzv1mTq6qWDlCg9IZNU_r-sYYk3S3NODQ,23706
24
27
  yama/tools/skill/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
25
28
  yama/tools/skill/skill.py,sha256=H2KdIBLkYhecYX7M2xbn79csDpDvougpRcAmlrwigEM,2235
26
- python_yama-0.7.0.dist-info/METADATA,sha256=abnFJBim_JNAHsPiflJ6wn-OT8lhwBALIM9NrnzMsmw,7539
27
- python_yama-0.7.0.dist-info/WHEEL,sha256=lCkmxWfQsSc9CfIClYeavTdQeEX2toPqufh9gI35EQA,87
28
- python_yama-0.7.0.dist-info/entry_points.txt,sha256=N5se3y1FflUcDU3TmUrH2Tu9dzsrBBo7sUP-Gu_2cVs,39
29
- python_yama-0.7.0.dist-info/licenses/LICENSE,sha256=cMAJJAs7R1lemJPPc7qMNv4w_sqn5QncFf4aXKYyEc4,1067
30
- python_yama-0.7.0.dist-info/RECORD,,
29
+ python_yama-0.9.0.dist-info/METADATA,sha256=cZL5fYN1qMwjmHW_WxHCZmfodoDSSmGGj682e6840m8,8919
30
+ python_yama-0.9.0.dist-info/WHEEL,sha256=lCkmxWfQsSc9CfIClYeavTdQeEX2toPqufh9gI35EQA,87
31
+ python_yama-0.9.0.dist-info/entry_points.txt,sha256=N5se3y1FflUcDU3TmUrH2Tu9dzsrBBo7sUP-Gu_2cVs,39
32
+ python_yama-0.9.0.dist-info/licenses/LICENSE,sha256=cMAJJAs7R1lemJPPc7qMNv4w_sqn5QncFf4aXKYyEc4,1067
33
+ python_yama-0.9.0.dist-info/RECORD,,
yama/cli.py CHANGED
@@ -3,6 +3,7 @@ from __future__ import annotations
3
3
  import argparse
4
4
  import asyncio
5
5
  import json
6
+ import os
6
7
  import sys
7
8
  from io import StringIO
8
9
  from pathlib import Path
@@ -29,7 +30,19 @@ from .dashboard import create_dashboard_server
29
30
  from .llm import LLMError, LiteLLMClient
30
31
  from .loaders import CollectionError, resolve_case
31
32
  from .preview import preview_payload, write_preview_html
33
+ from .pr import (
34
+ apply_pr_repeat,
35
+ build_pr_plan,
36
+ parse_changed_file_lines,
37
+ plugin_result_key,
38
+ pr_plan_to_dict,
39
+ pr_run_exit_status,
40
+ pr_summary_to_dict,
41
+ read_changed_files_from_git,
42
+ )
32
43
  from .report import write_html_report, write_timestamped_report
44
+ from .report_bundle import validate_commit_id
45
+ from .report_upload import upload_pr_reports
33
46
  from .runner import YamaRunner, combine_usage
34
47
  from .thread_case import (
35
48
  ThreadCaseError,
@@ -824,6 +837,242 @@ async def _run(args: argparse.Namespace) -> int:
824
837
  return 0
825
838
 
826
839
 
840
+ def _pr_plan_parser() -> argparse.ArgumentParser:
841
+ parser = argparse.ArgumentParser(
842
+ prog="yama pr-plan",
843
+ description="Plan PR-scoped eval cases without running them.",
844
+ )
845
+ parser.add_argument(
846
+ "--base",
847
+ default=None,
848
+ help="git diff base ref; yama diffs <base>...<head>",
849
+ )
850
+ parser.add_argument(
851
+ "--head",
852
+ default="HEAD",
853
+ help="git diff head ref for the PR branch",
854
+ )
855
+ parser.add_argument(
856
+ "--changed-files",
857
+ type=Path,
858
+ help="File containing changed paths or git diff --name-status lines",
859
+ )
860
+ parser.add_argument("--json", action="store_true", help="Print machine-readable plan")
861
+ return parser
862
+
863
+
864
+ def _changed_files_for_args(args: argparse.Namespace) -> Any:
865
+ if args.changed_files:
866
+ return parse_changed_file_lines(
867
+ args.changed_files.read_text(encoding="utf-8").splitlines()
868
+ )
869
+ if not args.base:
870
+ raise ConfigurationError("--base is required unless --changed-files is provided")
871
+ return read_changed_files_from_git(args.base, args.head)
872
+
873
+
874
+ def _relative_path(path: Path, root: Path) -> str:
875
+ try:
876
+ return path.resolve().relative_to(root.resolve()).as_posix()
877
+ except ValueError:
878
+ return str(path)
879
+
880
+
881
+ def _run_pr_plan(args: argparse.Namespace) -> int:
882
+ workspace = load_workspace_config(Path.cwd())
883
+ changed_files = _changed_files_for_args(args)
884
+ plan = build_pr_plan(workspace, changed_files, base=args.base, head=args.head)
885
+ payload = pr_plan_to_dict(plan, workspace.root)
886
+ if args.json:
887
+ print(json.dumps(payload, ensure_ascii=False, indent=2))
888
+ else:
889
+ console = Console()
890
+ if not plan.plugins:
891
+ console.print("No PR eval cases selected.")
892
+ for plugin in plan.plugins:
893
+ console.print(f"{plugin.name or '<workspace>'}: {len(plugin.cases)} case(s)")
894
+ for case in plugin.cases:
895
+ console.print(f" - {case.case_key} ({', '.join(case.reasons)})")
896
+ for warning in plugin.warnings:
897
+ console.print(f" warning: {warning}", style="yellow")
898
+ return 0
899
+
900
+
901
+ def _pr_run_parser() -> argparse.ArgumentParser:
902
+ parser = argparse.ArgumentParser(
903
+ prog="yama pr-run",
904
+ description="Run PR-scoped eval cases and write yama-side summary JSON.",
905
+ )
906
+ parser.add_argument(
907
+ "--base",
908
+ default=None,
909
+ help="git diff base ref; yama diffs <base>...<head>",
910
+ )
911
+ parser.add_argument(
912
+ "--head",
913
+ default="HEAD",
914
+ help="git diff head ref for the PR branch",
915
+ )
916
+ parser.add_argument("--changed-files", type=Path)
917
+ parser.add_argument("--report", action="store_true")
918
+ parser.add_argument("--upload-report", action="store_true")
919
+ parser.add_argument("--commit-id")
920
+ parser.add_argument("--json-summary", type=Path, required=True)
921
+ parser.add_argument("--concurrency", type=_positive_int, default=10)
922
+ parser.add_argument("--no-artifacts", action="store_true")
923
+ return parser
924
+
925
+
926
+ def _validate_pr_upload_args(args: argparse.Namespace) -> tuple[str, str, str] | None:
927
+ if not args.upload_report:
928
+ return None
929
+ if not args.report:
930
+ raise ConfigurationError("--upload-report requires --report")
931
+ if not args.commit_id:
932
+ raise ConfigurationError("--upload-report requires --commit-id")
933
+ commit_id = validate_commit_id(args.commit_id)
934
+ admin_host = os.environ.get("ADMIN_HOST")
935
+ token = os.environ.get("YAMA_EVAL_REPORT_API_TOKEN")
936
+ if not admin_host:
937
+ raise ConfigurationError("ADMIN_HOST is required when --upload-report is set")
938
+ if not token:
939
+ raise ConfigurationError(
940
+ "YAMA_EVAL_REPORT_API_TOKEN is required when --upload-report is set"
941
+ )
942
+ return commit_id, admin_host, token
943
+
944
+
945
+ async def _run_pr_run(args: argparse.Namespace) -> int:
946
+ workspace = load_workspace_config(Path.cwd())
947
+ upload_config = _validate_pr_upload_args(args)
948
+ changed_files = _changed_files_for_args(args)
949
+ plan = build_pr_plan(workspace, changed_files, base=args.base, head=args.head)
950
+ if not any(plugin.cases for plugin in plan.plugins):
951
+ payload = pr_summary_to_dict(plan, workspace_root=workspace.root, plugin_results={})
952
+ args.json_summary.parent.mkdir(parents=True, exist_ok=True)
953
+ args.json_summary.write_text(
954
+ json.dumps(payload, ensure_ascii=False, indent=2),
955
+ encoding="utf-8",
956
+ )
957
+ print("No PR eval cases selected.")
958
+ return 0
959
+
960
+ plugin_results: dict[str, dict[str, Any]] = {}
961
+ plugin_cases: dict[str, list[Any]] = {}
962
+ for plugin in plan.plugins:
963
+ if not plugin.cases:
964
+ continue
965
+ plugin_key = plugin_result_key(plugin, workspace.root)
966
+ result_root = plugin.root / workspace.result_dir
967
+ try:
968
+ cases = [
969
+ apply_pr_repeat(
970
+ resolve_case(
971
+ selected.path,
972
+ plugin.root,
973
+ workspace,
974
+ plugin.config,
975
+ force_bash_backend="linux-bubblewrap",
976
+ ),
977
+ plugin.repeat,
978
+ )
979
+ for selected in plugin.cases
980
+ ]
981
+ plugin_cases[plugin_key] = cases
982
+ except (ConfigurationError, CollectionError, ValueError) as exc:
983
+ plugin_results[plugin_key] = {
984
+ "results": [],
985
+ "errors": [{"phase": "collection", "message": str(exc)}],
986
+ "report_path": None,
987
+ "latest_report_path": None,
988
+ "runs_root": result_root,
989
+ }
990
+ continue
991
+ progress_console = Console(stderr=True)
992
+ progress = (
993
+ ParallelProgressPrinter(progress_console, cases=cases)
994
+ if args.concurrency > 1 and len(cases) > 1
995
+ else ProgressPrinter(progress_console, total_cases=len(cases))
996
+ )
997
+ semaphore = asyncio.Semaphore(args.concurrency)
998
+
999
+ async def run_one(case: Any) -> Any:
1000
+ async with semaphore:
1001
+ runner = YamaRunner(
1002
+ LiteLLMClient(),
1003
+ result_root=result_root,
1004
+ write_artifacts=not args.no_artifacts,
1005
+ on_event=progress,
1006
+ )
1007
+ return await runner.run_case(case)
1008
+
1009
+ try:
1010
+ outcomes = await asyncio.gather(
1011
+ *(run_one(case) for case in cases),
1012
+ return_exceptions=True,
1013
+ )
1014
+ finally:
1015
+ progress.close()
1016
+ plugin_errors = []
1017
+ for outcome in outcomes:
1018
+ if isinstance(outcome, BaseException):
1019
+ plugin_errors.append({"phase": "execution", "message": str(outcome)})
1020
+ results = [
1021
+ outcome for outcome in outcomes if not isinstance(outcome, BaseException)
1022
+ ]
1023
+ report_path = None
1024
+ if args.report:
1025
+ report_path = write_timestamped_report(
1026
+ cases,
1027
+ results,
1028
+ result_root.parent / "reports",
1029
+ )
1030
+ plugin_results[plugin_key] = {
1031
+ "results": results,
1032
+ "errors": plugin_errors,
1033
+ "report_path": report_path,
1034
+ "latest_report_path": result_root.parent / "reports" / "latest.html"
1035
+ if report_path
1036
+ else None,
1037
+ "runs_root": result_root,
1038
+ "plugin_root": _relative_path(plugin.root, workspace.root),
1039
+ }
1040
+
1041
+ remote_push_report_url = None
1042
+ upload_errors: list[str] = []
1043
+ if upload_config is not None and any(
1044
+ entry.get("report_path") for entry in plugin_results.values()
1045
+ ):
1046
+ commit_id, admin_host, token = upload_config
1047
+ upload_payload = upload_pr_reports(
1048
+ workspace_root=workspace.root,
1049
+ commit_id=commit_id,
1050
+ admin_host=admin_host,
1051
+ token=token,
1052
+ plugin_results=plugin_results,
1053
+ plugin_cases=plugin_cases,
1054
+ )
1055
+ remote_push_report_url = upload_payload.get("remote_push_report_url")
1056
+ upload_errors = list(upload_payload.get("upload_errors", []))
1057
+
1058
+ payload = pr_summary_to_dict(
1059
+ plan,
1060
+ workspace_root=workspace.root,
1061
+ plugin_results=plugin_results,
1062
+ remote_push_report_url=remote_push_report_url,
1063
+ upload_errors=upload_errors,
1064
+ )
1065
+ args.json_summary.parent.mkdir(parents=True, exist_ok=True)
1066
+ args.json_summary.write_text(
1067
+ json.dumps(payload, ensure_ascii=False, indent=2),
1068
+ encoding="utf-8",
1069
+ )
1070
+ status = pr_run_exit_status(plugin_results)
1071
+ if status == 0 and upload_errors:
1072
+ return 2
1073
+ return status
1074
+
1075
+
827
1076
  def _dashboard_parser() -> argparse.ArgumentParser:
828
1077
  parser = argparse.ArgumentParser(
829
1078
  prog="yama dashboard",
@@ -1010,6 +1259,10 @@ def main(argv: list[str] | None = None) -> int:
1010
1259
  return _run_dashboard(_dashboard_parser().parse_args(argv[1:]))
1011
1260
  if argv[:1] == ["from-thread"]:
1012
1261
  return _run_thread_case(_thread_case_parser().parse_args(argv[1:]))
1262
+ if argv[:1] == ["pr-plan"]:
1263
+ return _run_pr_plan(_pr_plan_parser().parse_args(argv[1:]))
1264
+ if argv[:1] == ["pr-run"]:
1265
+ return asyncio.run(_run_pr_run(_pr_run_parser().parse_args(argv[1:])))
1013
1266
  args = _parser().parse_args(argv)
1014
1267
  return asyncio.run(_run(args))
1015
1268
  except (ConfigurationError, CollectionError, ValueError) as exc:
yama/loaders/case.py CHANGED
@@ -230,6 +230,8 @@ def resolve_case(
230
230
  plugin_root: Path,
231
231
  workspace: WorkspaceConfig,
232
232
  plugin_config: dict[str, Any],
233
+ *,
234
+ force_bash_backend: str | None = None,
233
235
  ) -> ResolvedCase:
234
236
  raw = load_yaml(path)
235
237
  evals_root = (plugin_root / "__evals__").resolve()
@@ -256,18 +258,6 @@ def resolve_case(
256
258
  "skills_dir": plugin_config.get("skills_dir", "skills"),
257
259
  "skill_entry": plugin_config.get("skill_entry", "SKILL.md"),
258
260
  }
259
- system_config = context.get("system_prompt", {"default": True})
260
- if system_config is None or system_config == {"default": True}:
261
- system_path = plugin_root / conventions["system_prompt"]
262
- elif isinstance(system_config, dict) and isinstance(system_config.get("file"), str):
263
- system_path = evals_root / system_config["file"]
264
- else:
265
- raise CollectionError(
266
- "context.system_prompt must use {default: true} or {file: ...}"
267
- )
268
- if not system_path.is_file():
269
- raise CollectionError(f"system prompt does not exist: {system_path}")
270
-
271
261
  skills = [
272
262
  _load_skill(
273
263
  plugin_root, conventions["skills_dir"], conventions["skill_entry"], item
@@ -277,9 +267,48 @@ def resolve_case(
277
267
  names = [skill.name for skill in skills]
278
268
  if len(names) != len(set(names)):
279
269
  raise CollectionError("context.skills contains duplicate names")
280
- rendered_system = _render_system_prompt(
281
- system_path.read_text(encoding="utf-8"), skills
282
- )
270
+
271
+ context_messages = context.get("messages", [])
272
+ if not isinstance(context_messages, list):
273
+ raise CollectionError("context.messages must be a list")
274
+ recorded_system_message: dict[str, Any] | None = None
275
+ if context_messages and isinstance(context_messages[0], dict):
276
+ first_message = context_messages[0]
277
+ if first_message.get("role") == "system":
278
+ content = first_message.get("content")
279
+ if not isinstance(content, str) or not content:
280
+ raise CollectionError(
281
+ "context.messages[0] is a system message but its content "
282
+ "must be a non-empty string to replay as the recorded "
283
+ "system prompt"
284
+ )
285
+ recorded_system_message = first_message
286
+
287
+ if recorded_system_message is None:
288
+ system_config = context.get("system_prompt", {"default": True})
289
+ if system_config is None or system_config == {"default": True}:
290
+ system_path = plugin_root / conventions["system_prompt"]
291
+ elif isinstance(system_config, dict) and isinstance(
292
+ system_config.get("file"), str
293
+ ):
294
+ system_path = evals_root / system_config["file"]
295
+ else:
296
+ raise CollectionError(
297
+ "context.system_prompt must use {default: true} or {file: ...}"
298
+ )
299
+ if not system_path.is_file():
300
+ raise CollectionError(f"system prompt does not exist: {system_path}")
301
+ rendered_system = _render_system_prompt(
302
+ system_path.read_text(encoding="utf-8"), skills
303
+ )
304
+ initial_messages: list[dict[str, Any]] = [
305
+ {"role": "system", "content": rendered_system}
306
+ ]
307
+ history_messages = context_messages
308
+ else:
309
+ rendered_system = recorded_system_message["content"]
310
+ initial_messages = [deepcopy(recorded_system_message)]
311
+ history_messages = context_messages[1:]
283
312
 
284
313
  mocks = deepcopy(raw.get("mocks", {}))
285
314
  if not isinstance(mocks, dict):
@@ -298,13 +327,11 @@ def resolve_case(
298
327
  evals_root=evals_root,
299
328
  skills=skills,
300
329
  conventions=conventions,
330
+ force_bash_backend=force_bash_backend,
301
331
  )
302
332
 
303
333
  fixture_manifest: list[dict[str, Any]] = []
304
- initial_messages: list[dict[str, Any]] = [
305
- {"role": "system", "content": rendered_system}
306
- ]
307
- for message in context.get("messages", []):
334
+ for message in history_messages:
308
335
  if not isinstance(message, dict) or message.get("role") not in {
309
336
  "user",
310
337
  "assistant",
@@ -74,6 +74,7 @@ def resolve_builtin_handlers(
74
74
  evals_root: Path,
75
75
  skills: list[LoadedSkill],
76
76
  conventions: dict[str, str],
77
+ force_bash_backend: str | None = None,
77
78
  ) -> None:
78
79
  """Wire builtin tool declarations and expand ``handler: {builtin: ...}``.
79
80
 
@@ -140,6 +141,9 @@ def resolve_builtin_handlers(
140
141
  raise CollectionError("mocks.cli cannot be combined with mocks.fs")
141
142
  try:
142
143
  if fs_raw is not None:
144
+ if force_bash_backend is not None and isinstance(fs_raw, dict):
145
+ fs_raw = dict(fs_raw)
146
+ fs_raw["backend"] = force_bash_backend
143
147
  handler_with: dict[str, Any] = {
144
148
  "fs": normalize_fs_config(
145
149
  fs_raw, base_dir=evals_root, root=evals_root.parent
@@ -151,6 +155,8 @@ def resolve_builtin_handlers(
151
155
  cli_raw, base_dir=evals_root, root=evals_root.parent
152
156
  )
153
157
  }
158
+ if force_bash_backend is not None:
159
+ handler_with["fs_backend"] = force_bash_backend
154
160
  except MockConfigurationError as exc:
155
161
  raise CollectionError(str(exc)) from exc
156
162
  for entry in bash_entries: