Skip to content

"Vibe-Trading: Your Personal Trading Agent"

fix(goal): reject execution objectives that put the immediacy cue before the verb

Lanre Shittue3fa7af20bbc
diff --git a/agent/src/goal/policy.py b/agent/src/goal/policy.py
index 0d0919991..c68d1679a 100644
--- a/agent/src/goal/policy.py
+++ b/agent/src/goal/policy.py
@@ -15,6 +15,12 @@ _EXECUTION_PATTERNS = (
r"\b(buy|sell|short|long)\b.{0,40}\b(now|immediately|right away|market order|limit order)\b",
re.I,
),
+ # Same cue, reversed order ("immediately buy TSLA", "right away sell
+ # AAPL"): the pattern above only fires when the verb comes first.
+ re.compile(
+ r"\b(now|immediately|right away)\b.{0,40}\b(buy|sell|short|long)\b",
+ re.I,
+ ),
re.compile(r"(下单|市价单|限价单|马上买|立即买|现在买|马上卖|立即卖|现在卖)"),
# What the asset-noun list above used to catch, without its false
# positives: an objective that IS an order -- it opens with the verb
diff --git a/agent/tests/test_goal_policy.py b/agent/tests/test_goal_policy.py
index 8c9b9c707..6f1cd6082 100644
--- a/agent/tests/test_goal_policy.py
+++ b/agent/tests/test_goal_policy.py
@@ -43,6 +43,10 @@ def test_ordinary_research_objectives_are_accepted(objective: str) -> None:
"Please buy AAPL",
"Research the setup, then sell 50 TSLA",
"买入100股贵州茅台",
+ # Reversed word order: the immediacy cue comes before the verb.
+ "Immediately buy TSLA",
+ "Right away sell my AAPL position",
+ "Now sell GOOGL",
],
)
def test_genuine_execution_requests_are_still_rejected(objective: str) -> None: