"Vibe-Trading: Your Personal Trading Agent"
Python ai-agentalgorithmic-tradingbacktestingfintechllmmcpmulti-agentpythonquantitative-financetrading
fix(tools): name the run_dir the backtest tool actually looked in
cgycoreyfd3d778686f8
diff --git a/agent/src/tools/backtest_tool.py b/agent/src/tools/backtest_tool.pyindex 59681937a..459c0a15a 100644--- a/agent/src/tools/backtest_tool.py+++ b/agent/src/tools/backtest_tool.py@@ -31,7 +31,14 @@ def run_backtest(run_dir: str) -> str:config_path = run_path / "config.json"if not config_path.exists():- return json.dumps({"status": "error", "error": "config.json not found"}, ensure_ascii=False)+ return json.dumps(+ {+ "status": "error",+ "error": f"config.json not found in {run_path}",+ "hint": "config.json belongs at the root of run_dir.",+ },+ ensure_ascii=False,+ )try:config = json.loads(config_path.read_text(encoding="utf-8"))@@ -46,7 +53,14 @@ def run_backtest(run_dir: str) -> str:signal_path = run_path / "code" / "signal_engine.py"if not signal_path.exists():- return json.dumps({"status": "error", "error": "code/signal_engine.py not found"}, ensure_ascii=False)+ return json.dumps(+ {+ "status": "error",+ "error": f"code/signal_engine.py not found in {run_path}",+ "hint": "signal_engine.py belongs in code/ inside run_dir.",+ },+ ensure_ascii=False,+ )agent_root = Path(__file__).resolve().parents[2]entry_script = agent_root / "backtest" / "runner.py"diff --git a/agent/tests/test_backtest_tool_state.py b/agent/tests/test_backtest_tool_state.pyindex 49c2c2456..64793b5bc 100644--- a/agent/tests/test_backtest_tool_state.py+++ b/agent/tests/test_backtest_tool_state.py@@ -70,6 +70,28 @@ def test_validation_error_records_no_state(tool_run_dir):assert not (tool_run_dir / "state.json").exists()+def test_validation_error_names_the_directory_it_checked(tool_run_dir):+ """The path matters: a caller whose run_dir was supplied by someone else+ (e.g. a swarm worker injecting the agent workspace) has no way to tell that+ the tool looked somewhere other than the path it passed."""+ (tool_run_dir / "config.json").unlink()++ envelope = json.loads(run_backtest(str(tool_run_dir)))++ assert str(tool_run_dir) in envelope["error"]+ assert "hint" in envelope, "mirrors autopilot_tool's missing-artifact envelope"+++def test_missing_signal_engine_names_the_directory_it_checked(tool_run_dir):+ (tool_run_dir / "code" / "signal_engine.py").unlink()++ envelope = json.loads(run_backtest(str(tool_run_dir)))++ assert envelope["status"] == "error"+ assert str(tool_run_dir) in envelope["error"]+ assert "hint" in envelope++def test_timeout_records_state_failed_and_returns_error_envelope(tool_run_dir):with patch("src.tools.backtest_tool.emit_progress"), patch("src.tools.backtest_tool.Runner") as runner_cls:runner_cls.return_value.timeout = 300