"Vibe-Trading: Your Personal Trading Agent"
Python ai-agentalgorithmic-tradingbacktestingfintechllmmcpmulti-agentpythonquantitative-financetrading
test(tools): cover recoverable write-file arguments
Haozhe Wu93220830dd0a
diff --git a/agent/src/tools/write_file_tool.py b/agent/src/tools/write_file_tool.pyindex 38a451d95..57dae509a 100644--- a/agent/src/tools/write_file_tool.py+++ b/agent/src/tools/write_file_tool.py@@ -55,9 +55,18 @@ class WriteFileTool(BaseTool):},ensure_ascii=False,)- content = kwargs.get("content")+ content = next(+ (kwargs[key] for key in ("content", "text", "data") if kwargs.get(key) is not None),+ None,+ )if content is None:- content = kwargs.get("text", kwargs.get("data", ""))+ return json.dumps(+ {+ "status": "error",+ "error": "missing required argument 'content' (string): the file content to write",+ },+ ensure_ascii=False,+ )run_dir = kwargs.get("run_dir")try:diff --git a/agent/tests/test_file_tool_sandbox_security.py b/agent/tests/test_file_tool_sandbox_security.pyindex fdac3b0f2..36b78cc28 100644--- a/agent/tests/test_file_tool_sandbox_security.py+++ b/agent/tests/test_file_tool_sandbox_security.py@@ -18,6 +18,31 @@ def _body(raw: str) -> dict:return json.loads(raw)+def test_write_file_accepts_model_argument_aliases(tmp_path: Path, monkeypatch) -> None:+ monkeypatch.setenv("VIBE_TRADING_ALLOWED_RUN_ROOTS", str(tmp_path))++ body = _body(+ WriteFileTool().execute(+ file_path="handoff.md",+ text="verified alias content",+ run_dir=str(tmp_path),+ )+ )++ assert body["status"] == "ok"+ assert (tmp_path / "handoff.md").read_text(encoding="utf-8") == "verified alias content"+++def test_write_file_returns_recoverable_errors_for_missing_arguments() -> None:+ missing_path = _body(WriteFileTool().execute(content="payload"))+ missing_content = _body(WriteFileTool().execute(path="handoff.md"))++ assert missing_path["status"] == "error"+ assert "missing required argument 'path'" in missing_path["error"]+ assert missing_content["status"] == "error"+ assert "missing required argument 'content'" in missing_content["error"]++def test_write_file_rejects_unconfigured_absolute_run_dir(tmp_path: Path, monkeypatch) -> None:monkeypatch.delenv("VIBE_TRADING_ALLOWED_RUN_ROOTS", raising=False)