Skip to content

"Vibe-Trading: Your Personal Trading Agent"

fix(goal): stop the execution filter blocking normal research goals

Lanre Shittudcf99923912f
diff --git a/agent/src/goal/policy.py b/agent/src/goal/policy.py
index f070018c8..ed4a62ef2 100644
--- a/agent/src/goal/policy.py
+++ b/agent/src/goal/policy.py
@@ -6,8 +6,13 @@ import re
_EXECUTION_PATTERNS = (
re.compile(r"\b(place|submit|execute|send)\b.{0,40}\b(order|trade)\b", re.I),
+ # No bare asset noun (shares/contracts/btc/...) here: this is a research
+ # product whose whole purpose is evaluating whether to buy/sell/short a
+ # 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.
re.compile(
- r"\b(buy|sell|short|long)\b.{0,40}\b(now|immediately|market order|limit order|shares?|contracts?|btc|eth|usdt)\b",
+ r"\b(buy|sell|short|long)\b.{0,40}\b(now|immediately|right away|market order|limit order)\b",
re.I,
),
re.compile(r"(下单|市价单|限价单|马上买|立即买|现在买|马上卖|立即卖|现在卖)"),
diff --git a/agent/tests/test_goal_policy.py b/agent/tests/test_goal_policy.py
new file mode 100644
index 000000000..28c2e75a9
--- /dev/null
+++ b/agent/tests/test_goal_policy.py
@@ -0,0 +1,38 @@
+"""Tests for the finance research goal execution filter."""
+
+from __future__ import annotations
+
+import pytest
+
+from src.goal.policy import reject_live_execution_objective
+
+
+ "objective",
+ [
+ "Research whether Coinbase should buy more BTC reserves this quarter",
+ "Assess if the fund should sell its GOOGL shares given antitrust risk",
+ "Determine whether to short TSLA contracts based on delivery numbers",
+ "Evaluate a long AAPL thesis versus a short thesis on valuation grounds",
+ ],
+)
+def test_ordinary_research_objectives_are_accepted(objective: str) -> None:
+ # This is a research product whose whole purpose is evaluating whether to
+ # buy/sell/short a security, so mentioning a buy/sell verb near an asset
+ # noun (shares, contracts, btc) in a research objective is the normal
+ # case, not an execution request.
+ reject_live_execution_objective(objective)
+
+
+ "objective",
+ [
+ "Buy AAPL now at market order",
+ "Sell TSLA immediately, submit the order right away",
+ "Place an order to buy BTC right away",
+ "Buy 100 shares of NVDA right away using a limit order",
+ ],
+)
+def test_genuine_execution_requests_are_still_rejected(objective: str) -> None:
+ with pytest.raises(ValueError, match="live trading or execution"):
+ reject_live_execution_objective(objective)