"Vibe-Trading: Your Personal Trading Agent"
Python ai-agentalgorithmic-tradingbacktestingfintechllmmcpmulti-agentpythonquantitative-financetrading
fix(grounding): don't split clauses on full-width brackets (#1260)
cgycoreyce4fb243f03b
diff --git a/agent/src/agent/grounding.py b/agent/src/agent/grounding.pyindex f6f33cee0..8ae4adf06 100644--- a/agent/src/agent/grounding.py+++ b/agent/src/agent/grounding.py@@ -451,10 +451,12 @@ _PROSPECTIVE_LEVEL_RE = re.compile(r")",re.IGNORECASE,)-# Full-width brackets and enumeration commas delimit prose clauses. ASCII-# parentheses are deliberately not separators: an explicit derivation such as-# "(8.5 - 7.9) / 2" must stay in one segment for the formula check.-_CLAUSE_SEPARATOR_RE = re.compile(r"[,,;;。、\n()【】]")+# Full-width enumeration commas delimit prose clauses. Paired brackets (ASCII+# or full-width ()()[]) are deliberately not separators: an explicit+# derivation such as "(8.5 - 7.9) / 2" must stay in one segment for the+# formula check, and 公司名(代码)价格 must stay in one segment so the+# unsourced-symbol gate can see the symbol with its figure (#1260).+_CLAUSE_SEPARATOR_RE = re.compile(r"[,,;;。、\n]")# The ASCII comma both separates clauses and groups thousands, and the clausediff --git a/agent/tests/test_agent_grounding.py b/agent/tests/test_agent_grounding.pyindex 96d7d66e6..3919379b9 100644--- a/agent/tests/test_agent_grounding.py+++ b/agent/tests/test_agent_grounding.py@@ -2064,6 +2064,73 @@ def test_an_unevidenced_price_is_still_rejected_without_any_tool_call(}+ ("draft", "paren_width"),+ [+ ("同期五粮液(000858.SZ)收 168.50 元。", "full-width"),+ ("同期五粮液(000858.SZ)收 168.50 元。", "half-width"),+ ],+)+def test_fullwidth_parentheses_do_not_split_symbol_from_figure(+ tmp_path: Path,+ draft: str,+ paren_width: str,+) -> None:+ """#1260: 公司名(代码)价格 must stay in one clause for the gate.++ Full-width () were treated as clause separators, so the symbol landed in+ one segment and the figure in the next and the unsourced-symbol gate+ never saw them together — a false negative that flipped on parenthesis+ width alone. Both widths must fire now; the half-width form is the+ control that already passed.+ """+ ledger = GroundingLedger(+ run_dir=tmp_path,+ user_message="What is Kweichow Moutai (600519.SH) trading at this week?",+ )+ ledger.ingest_tool_result(+ tool_name="get_market_data",+ arguments={+ "codes": ["600519.SH"],+ "start_date": "2026-08-24",+ "end_date": "2026-08-28",+ "source": "baostock",+ },+ result=json.dumps(+ {+ "600519.SH": [+ {+ "trade_date": "2026-08-28T00:00:00",+ "open": 1289.0,+ "high": 1297.89,+ "low": 1288.0,+ "close": 1297.4,+ "volume": 16126.11,+ }+ ],+ "_provenance": {+ "600519.SH": {+ "source": "baostock",+ "fallback_used": False,+ "currency_conversion": "none",+ "volume_unit": "lots",+ }+ },+ }+ ),+ call_id="c1",+ success=True,+ )++ issues = [+ issue+ for issue in ledger.validate_final_answer(draft).issues+ if issue.get("code") == "unsourced_symbol_figures"+ ]++ assert issues, f"{paren_width} parentheses must fire unsourced_symbol_figures"++def test_a_shortlist_answers_the_user_but_still_cannot_fetch_a_quote(tmp_path: Path,) -> None: