refactor: unify event routing, orchestration, and agent context handling with consistent naming and closed-loop tracking
This commit is contained in:
@@ -4,14 +4,14 @@ from sqlalchemy.orm import relationship
|
||||
from database.models import Base
|
||||
from datetime import datetime, timezone
|
||||
|
||||
# Helper for default timestamps
|
||||
# helper for default timestamps
|
||||
datetime_now = lambda: datetime.now(timezone.utc)
|
||||
|
||||
|
||||
class AgentContext(Base):
|
||||
"""
|
||||
共享上下文表(替代硬編碼鏈),支援多 Agent 存取與 TTL。
|
||||
索引:(session_id, agent_name, context_key) 以加速跨 Agent 查詢。
|
||||
Shared context table (replaces hardcoded chain), supporting multi-agent access and TTL.
|
||||
Index: (session_id, agent_name, context_key) for fast cross-agent queries.
|
||||
"""
|
||||
__tablename__ = 'agent_context'
|
||||
|
||||
@@ -19,7 +19,7 @@ class AgentContext(Base):
|
||||
session_id = Column(String(64), nullable=False, index=True)
|
||||
agent_name = Column(String(50), nullable=False, index=True)
|
||||
context_key = Column(String(100), nullable=False)
|
||||
context_val = Column(Text) # JSON 字串
|
||||
context_val = Column(Text) # JSON string
|
||||
created_at = Column(DateTime, default=datetime_now)
|
||||
ttl_minutes = Column(Integer, default=60)
|
||||
|
||||
@@ -31,7 +31,7 @@ class AgentContext(Base):
|
||||
|
||||
class ActionPlan(Base):
|
||||
"""
|
||||
行動計畫表(NemoTron 輸出,等待審核與執行追蹤)。
|
||||
Action plan table (NemoTron output, awaiting review/execution tracking).
|
||||
"""
|
||||
__tablename__ = 'action_plans'
|
||||
|
||||
@@ -39,7 +39,7 @@ class ActionPlan(Base):
|
||||
session_id = Column(String(64), nullable=True)
|
||||
plan_type = Column(String(50), nullable=True) # price_adjust / restock / campaign
|
||||
sku = Column(String(100), nullable=True, index=True)
|
||||
payload = Column(Text) # JSON 行動內容
|
||||
payload = Column(Text) # JSON payload
|
||||
status = Column(String(20), default='pending') # pending/approved/rejected/executed
|
||||
created_by = Column(String(50)) # nemotron / openclaw
|
||||
approved_by = Column(String(100), nullable=True) # Telegram user_id
|
||||
@@ -54,7 +54,7 @@ class ActionPlan(Base):
|
||||
|
||||
class ActionOutcome(Base):
|
||||
"""
|
||||
行動結果追蹤(閉環學習核心)。
|
||||
Action outcome tracking (closed-loop learning core).
|
||||
"""
|
||||
__tablename__ = 'action_outcomes'
|
||||
|
||||
@@ -72,8 +72,8 @@ class ActionOutcome(Base):
|
||||
|
||||
class AgentStrategyWeights(Base):
|
||||
"""
|
||||
Agent 策略權重(OpenClaw 學習累積)。
|
||||
索引:strategy_key 以便快速更新與查詢。
|
||||
Agent strategy weights (OpenClaw learning accumulation).
|
||||
Index: strategy_key for fast updates/query.
|
||||
"""
|
||||
__tablename__ = 'agent_strategy_weights'
|
||||
|
||||
|
||||
Reference in New Issue
Block a user