diff --git a/src/agents/tradingagents/auto_trigger.py b/src/agents/tradingagents/auto_trigger.py index 677f965..646eda7 100644 --- a/src/agents/tradingagents/auto_trigger.py +++ b/src/agents/tradingagents/auto_trigger.py @@ -30,7 +30,7 @@ def _read_auto_trigger_config(db: Session) -> dict | None: - """从 AgentConfig.raw_config 读 auto_trigger 配置。 + """从 AgentConfig.config 读 auto_trigger 配置。 Returns: { @@ -42,7 +42,7 @@ def _read_auto_trigger_config(db: Session) -> dict | None: agent = db.query(AgentConfig).filter(AgentConfig.name == "tradingagents").first() if not agent: return None - raw = agent.raw_config or {} + raw = agent.config or {} auto = raw.get("auto_trigger") or {} if not auto.get("enabled"): return None @@ -69,7 +69,7 @@ def _within_cooldown(db: Session, stock_symbol: str, cooldown_hours: int) -> boo def _budget_allows(db: Session) -> bool: - """检查月度预算是否还有余量。预算从 tradingagents 的 raw_config.monthly_budget_usd 读。""" + """检查月度预算是否还有余量。预算从 tradingagents 的 config.monthly_budget_usd 读。""" try: from src.agents.tradingagents.cost_tracker import check_budget except ImportError: @@ -78,7 +78,7 @@ def _budget_allows(db: Session) -> bool: agent = db.query(AgentConfig).filter(AgentConfig.name == "tradingagents").first() if not agent: return True - raw = agent.raw_config or {} + raw = agent.config or {} budget = float(raw.get("monthly_budget_usd") or 0.0) if budget <= 0: return True # 没设上限 = 不限制 diff --git a/tests/test_tradingagents_auto_trigger.py b/tests/test_tradingagents_auto_trigger.py index 1a9776f..d916a68 100644 --- a/tests/test_tradingagents_auto_trigger.py +++ b/tests/test_tradingagents_auto_trigger.py @@ -7,11 +7,12 @@ import pytest from src.agents.tradingagents import auto_trigger +from src.web.models import AgentConfig -def _make_agent(raw_config: dict): - agent = MagicMock() - agent.raw_config = raw_config +def _make_agent(config: dict): + agent = MagicMock(spec=AgentConfig) + agent.config = config return agent