Skip to content

"Vibe-Trading: Your Personal Trading Agent"

fix(goal): keep long-term and short-term objectives

Rudy Celeklicb16038cbb48
diff --git a/agent/src/goal/policy.py b/agent/src/goal/policy.py
index 90e6e60a0..cdc629d4b 100644
--- a/agent/src/goal/policy.py
+++ b/agent/src/goal/policy.py
@@ -11,14 +11,17 @@ _EXECUTION_PATTERNS = (
# security, so "buy NVDA shares" alone in a research objective is the
# normal case, not an execution request. Only fire on an actual
# execution-imminent cue alongside the buy/sell verb.
+ # "long-term" / "short-term" (and "long term" / "short term") are horizons.
+ # A hyphen or space is a word boundary, so "update the long-term thesis
+ # immediately" used to match long ... immediately and was rejected as an order.
re.compile(
- r"\b(buy|sell|short|long)\b.{0,40}\b(now|immediately|right away|market order|limit order)\b",
+ r"\b(?:buy|sell|short(?![\s-]*term\b)|long(?![\s-]*term\b))\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[\s,:-]+(?:please\s+)?(?:buy|sell|short|long)\b",
+ r"\b(?:now|immediately|right away)\b[\s,:-]+(?:please\s+)?(?:buy|sell|short(?![\s-]*term\b)|long(?![\s-]*term\b))\b",
re.I,
),
re.compile(r"(下单|市价单|限价单|马上买|立即买|现在买|马上卖|立即卖|现在卖)"),
diff --git a/agent/tests/test_goal_policy.py b/agent/tests/test_goal_policy.py
index f1a9b7a37..e8026032a 100644
--- a/agent/tests/test_goal_policy.py
+++ b/agent/tests/test_goal_policy.py
@@ -23,6 +23,10 @@ from src.goal.policy import reject_live_execution_objective
"Now analyze short interest in TSLA",
"Immediately evaluate a long AAPL thesis",
"Right away assess whether to sell TSLA",
+ # Horizons, not orders: "long"/"short" here are adjectives.
+ "Update the long-term thesis immediately",
+ "Refresh the short-term model right away",
+ "Revisit the long term allocation now",
],
)
def test_ordinary_research_objectives_are_accepted(objective: str) -> None:
@@ -54,6 +58,8 @@ def test_ordinary_research_objectives_are_accepted(objective: str) -> None:
"Now, please buy AAPL",
"Research the setup; immediately sell TSLA",
"Please immediately short TSLA",
+ "Short TSLA immediately",
+ "Go long now",
],
)
def test_genuine_execution_requests_are_still_rejected(objective: str) -> None: