"Vibe-Trading: Your Personal Trading Agent"
Python ai-agentalgorithmic-tradingbacktestingfintechllmmcpmulti-agentpythonquantitative-financetrading
fix(fund-nav): clamp an explicit zero limit instead of returning the 2000-row default (#1927)
Rudy Mizrahi Celeklic8ef6a6f6610
diff --git a/agent/src/tools/fund_nav_tool.py b/agent/src/tools/fund_nav_tool.pyindex 3a6211d75..dbad8cdc2 100644--- a/agent/src/tools/fund_nav_tool.py+++ b/agent/src/tools/fund_nav_tool.py@@ -166,7 +166,10 @@ class GildataFundNavTool(BaseTool):)try:- limit = int(kwargs.get("limit", _DEFAULT_LIMIT) or _DEFAULT_LIMIT)+ # Only an omitted limit takes the default; an explicit 0 clamps to 1+ # like any other out-of-range value instead of becoming 2000 rows.+ raw_limit = kwargs.get("limit")+ limit = _DEFAULT_LIMIT if raw_limit is None else int(raw_limit)except (TypeError, ValueError):limit = _DEFAULT_LIMITlimit = max(1, min(_MAX_LIMIT, limit))diff --git a/agent/tests/test_fund_nav_tool.py b/agent/tests/test_fund_nav_tool.pyindex e72021b59..b3186f9c8 100644--- a/agent/tests/test_fund_nav_tool.py+++ b/agent/tests/test_fund_nav_tool.py@@ -181,6 +181,31 @@ class TestExecute:assert fund["count"] == 3assert fund["rows"][-1]["date"] == "2024-01-10" # newest kept+ def test_explicit_zero_limit_clamps_to_one_row(self, monkeypatch):+ rows = [+ {+ "enddate": f"2024-01-{day:02d}",+ "fundname": "F",+ "unitnv": 1.0,+ "accumulatedunitnv": 1.0,+ "unitnvrestored": 1.0,+ "nvdailygrowthrate": 0.0,+ }+ for day in range(1, 11)+ ]++ def transport(tool, args):+ if tool == "ParamCandidateRecall":+ return {"candidates": [{"caption": "F", "code": "11363", "ref_code": "110022.OF"}]}+ return _tool_entry(rows)++ self._patch_transport(monkeypatch, transport)+ for limit, count in ((0, 1), (-5, 1), (None, 10)):+ out = json.loads(GildataFundNavTool().execute(funds=["110022"], limit=limit))+ fund = out["funds"]["110022.OF"]+ assert fund["count"] == count, limit+ assert fund["rows"][-1]["date"] == "2024-01-10"+def test_empty_window_reports_error(self, monkeypatch):def transport(tool, args):if tool == "ParamCandidateRecall":