from __future__ import annotations import argparse import sys from pathlib import Path _agent_root = Path(__file__).resolve().parents[2] if str(_agent_root) not in sys.path: sys.path.insert(0, str(_agent_root)) _src = _agent_root / "src" if _src.exists() and str(_src) not in sys.path: sys.path.insert(0, str(_src)) from tests.pipeline_setup_v3.shared.env_loader import load_pipeline_setup_env from tests.pipeline_setup_v3.core.runner import V3Runner def main(argv: list[str] | None = None) -> int: parser = argparse.ArgumentParser(description="Run agent-backed pipeline_setup_v3 cases") parser.add_argument("--cases-dir", required=True, help="Directory or file with YAML case files") parser.add_argument("--run-name", default="manual_run", help="Output directory prefix") parser.add_argument("--results-dir", default=None, help="Override results root directory") parser.add_argument("--pipeline-mode", default="full", choices=["full", "pre_llm_only"], help="Pipeline execution mode") parser.add_argument( "--workflow-llm-enabled", default="true", choices=["true", "false"], help="Enable or disable final workflow LLM calls where supported", ) parser.add_argument( "--router-llm-mode", default="deterministic", choices=["deterministic", "llm_disambiguation"], help="Intent router mode: deterministic only or deterministic with optional LLM disambiguation", ) ns = parser.parse_args(argv) cases_dir = Path(str(ns.cases_dir)).expanduser().resolve() results_dir = Path(str(ns.results_dir)).expanduser().resolve() if ns.results_dir else Path(__file__).resolve().parent / "test_results" load_pipeline_setup_env(start_dir=Path(__file__).resolve().parent) runner = V3Runner( cases_dir=cases_dir, results_dir=results_dir, run_name=str(ns.run_name).strip() or "manual_run", pipeline_mode=str(ns.pipeline_mode).strip() or "full", router_llm_mode=str(ns.router_llm_mode).strip() or "deterministic", workflow_llm_enabled=str(ns.workflow_llm_enabled).strip().lower() == "true", ) print(f"Cases dir: {cases_dir}") print(f"Run dir: {runner.run_dir}") results, summary_path = runner.run() passed = sum(1 for item in results if item.passed) print(f"Passed: {passed}/{len(results)}") print(f"Summary: {summary_path}") for item in results: if not item.passed: print(f"FAIL {item.case.case_id}: {'; '.join(item.mismatches)}") return 0 if passed == len(results) else 1 if __name__ == "__main__": raise SystemExit(main())