Skip to content

"Vibe-Trading: Your Personal Trading Agent"

Updated grounding fix

William Liaofe64043a647d
diff --git a/agent/src/agent/grounding.py b/agent/src/agent/grounding.py
index f365c5f8a..144cb374a 100644
--- a/agent/src/agent/grounding.py
+++ b/agent/src/agent/grounding.py
@@ -169,13 +169,22 @@ _NUMBER_RE = re.compile(
r"(?<![A-Za-z0-9_])[-+]?(?:\d{1,3}(?:,\d{3})+|\d+)(?:\.\d+)?"
r"(?![A-Za-z0-9_])"
)
-_DATE_RE = re.compile(r"\b(?:19|20)\d{2}[-/]\d{1,2}[-/]\d{1,2}\b")
+_DATE_RE = re.compile(
+ r"\b(?:19|20)\d{2}[-/]\d{1,2}[-/]\d{1,2}"
+ r"(?:\s*[-–—~至到]\s*(?:0?[1-9]|[12]\d|3[01]))?\b"
+)
# A year-less "8/5" is how a trading day is written in running prose, and it
# contributed 8 and 5 as candidate prices (#983). The month and day ranges are
# bounded, and both sides are fenced off from a longer slash run, so the window
# enumeration "20/50/200-day" cannot be mistaken for a date.
+#
+# A day-range shares the month prefix: "8/10–14" (or "2026-08-10–14") means the
+# 10th through 14th, and the tail day was parsed as a price (14.0) that rejected
+# the GRID.TO / DCBO.TO drafts. The range tail is optional so a bare "8/10"
+# still masks exactly as before.
_SHORT_DATE_RE = re.compile(
- r"(?<![\d/])(?:0?[1-9]|1[0-2])/(?:0?[1-9]|[12]\d|3[01])(?![\d/])"
+ r"(?<![\d/])(?:0?[1-9]|1[0-2])/(?:0?[1-9]|[12]\d|3[01])"
+ r"(?:\s*[-–—~至到]\s*(?:0?[1-9]|[12]\d|3[01]))?(?![\d/])"
)
# A percentage range masks only its upper bound through the "%" tail check
# below, because the sign touches the second number: "1–2%" left 1 behind
diff --git a/agent/tests/test_agent_grounding.py b/agent/tests/test_agent_grounding.py
index 07e200c79..53efc2176 100644
--- a/agent/tests/test_agent_grounding.py
+++ b/agent/tests/test_agent_grounding.py
@@ -1315,6 +1315,12 @@ _PLAN_LEVELS_FROM_983 = [
"布林带 30.98/26.64/22.29",
"SMA200 35.78(价格在其下)",
"RSI 46.7",
+ # A day-range shares the month prefix: the "–14" tail of "8/10–14" was
+ # parsed as a price of 14.0 and rejected the GRID.TO / DCBO.TO drafts.
+ "8/10–14 每日收盘判定项",
+ "8/10-14",
+ "8/10至14",
+ "2026-08-10–14",
]
@@ -1392,6 +1398,8 @@ _ASSERTIONS_THAT_MUST_STAY_CHECKED = [
("低 19.87(2026-04-13)", [19.87]),
# `C$`/`$` alone (no operator/marker) is not prospective: stays checked.
("C$26.00 收盘", [26.0]),
+ # A single short date masks, but the price beside it stays checked.
+ ("8/10 收 5.00", [5.0]),
]