Skip to content

"Vibe-Trading: Your Personal Trading Agent"

Updated grounding fix

William Liao87ddde4ec93b
diff --git a/agent/src/agent/grounding.py b/agent/src/agent/grounding.py
index 5c1877aa2..7566c6ae8 100644
--- a/agent/src/agent/grounding.py
+++ b/agent/src/agent/grounding.py
@@ -285,6 +285,12 @@ _PROSPECTIVE_LEVEL_RE = re.compile(
r")",
re.IGNORECASE,
)
+# A markdown ordered-list marker ("1. **持仓**: …", "10. 事件") is not a price:
+# the standalone integer + period at line start was parsed as a price claim and
+# rejected the BLDP.TO draft on its second attempt (#1.0 vs OHLC). Span-local:
+# the period must not be followed by a digit, so "3.50" and "1.5" stay checked.
+_ORDERED_LIST_MARKER_RE = re.compile(r"(?m)^\s*\d+\.(?!\d)")
+
# 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.
@@ -1894,6 +1900,7 @@ class GroundingLedger:
masked = _LABELLED_SCORE_RE.sub(" ", masked)
masked = _INDICATOR_VALUE_RE.sub(" ", masked)
masked = _PROSPECTIVE_LEVEL_RE.sub(" ", masked)
+ masked = _ORDERED_LIST_MARKER_RE.sub(" ", masked)
without_dates = _QUANTITY_WITH_UNIT_RE.sub(" ", masked)
values: list[float] = []
for match in _NUMBER_RE.finditer(without_dates):
diff --git a/agent/tests/test_agent_grounding.py b/agent/tests/test_agent_grounding.py
index 415db9fe6..52428ad20 100644
--- a/agent/tests/test_agent_grounding.py
+++ b/agent/tests/test_agent_grounding.py
@@ -1332,6 +1332,24 @@ def test_wan_quantities_are_not_read_as_price_claims(segment: str) -> None:
assert GroundingLedger._numbers_without_dates_or_percent(segment) == []
+# A markdown ordered-list item number ("1. 持仓", "10. 事件") is not a price.
+# The standalone integer + period at line start was parsed as a price claim of
+# 1.0 and rejected the BLDP.TO draft on its second attempt (Aug 2026).
+_ORDERED_LIST_MARKERS = [
+ "1. **持仓**",
+ "1. 持仓",
+ "2. GTC 单",
+ "10. 事件",
+ " 1. 持仓",
+]
+
+
[email protected]("segment", _ORDERED_LIST_MARKERS, ids=range(len(_ORDERED_LIST_MARKERS)))
+def test_ordered_list_markers_are_not_read_as_price_claims(segment: str) -> None:
+ """An ordered-list item number asserts nothing about observed data."""
+ assert GroundingLedger._numbers_without_dates_or_percent(segment) == []
+
+
# The other side of the same guard. Every entry here is an assertion about what
# the instrument did, and each must survive the mask above — otherwise the
# relaxation is a way to state a price without being checked.
@@ -1352,6 +1370,12 @@ _ASSERTIONS_THAT_MUST_STAY_CHECKED = [
# A 万 quantity must not hide a nearby observed quote (span-local):
# the volume is masked, the close beside it stays checked.
("收盘 0.49,量 119 万", [0.49]),
+ # An ordered-list marker must not shield the real price beside it:
+ # "1." and the 500-share quantity mask, the C$3.72 quote stays checked.
+ ("1. 持仓: 500 股 @ C$3.72", [3.72]),
+ # A decimal at line start is not a list marker ("3.50" has a digit after
+ # the period).
+ ("3.50 支撑位", [3.5]),
]