Skip to content

"Vibe-Trading: Your Personal Trading Agent"

test(grounding): strengthen #1260 regression test after adversarial review

cgycorey01616f8b9ec0
diff --git a/agent/tests/test_agent_grounding.py b/agent/tests/test_agent_grounding.py
index 3919379b9..81a70aec6 100644
--- a/agent/tests/test_agent_grounding.py
+++ b/agent/tests/test_agent_grounding.py
@@ -2129,6 +2129,67 @@ def test_fullwidth_parentheses_do_not_split_symbol_from_figure(
]
assert issues, f"{paren_width} parentheses must fire unsourced_symbol_figures"
+ # Pin the offending symbol, not just "some issue fired": the gate must
+ # blame the unsourced 000858.SZ, not the sourced 600519.SH.
+ assert [issue["symbol"] for issue in issues] == ["000858.SZ"]
+
+
+def test_unsourced_symbol_without_a_figure_stays_silent(tmp_path: Path) -> None:
+ """#1260 guard arm: figure co-presence is what the gate checks.
+
+ The regression test above pins that the gate fires when symbol and figure
+ share a clause. This arm pins the inverse: an unsourced symbol with NO
+ nearby figure must not fire unsourced_symbol_figures, so the gate's
+ figure-presence guard (_numbers_without_dates_or_percent) cannot be
+ dropped without this test failing.
+ """
+ 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(
+ "同期五粮液(000858.SZ)是知名白酒企业。"
+ ).issues
+ if issue.get("code") == "unsourced_symbol_figures"
+ ]
+
+ assert issues == []
def test_a_shortlist_answers_the_user_but_still_cannot_fetch_a_quote(