feat(file-check): 持久化 chat_tool_runs 并统一 agent_runtime_context 注入
新增跨 worker 进度绑定表与显式 hxops_turn_id 链路;Dify Start 仅注入 agent_runtime_context,task_id/turn_id 写入 refs 供画布解析后回传 Tool。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
c778f40fbc
commit
f4e74f7b07
23 files changed
+1580
-196
No files matched your search
@@ -83,6 +83,37 @@ class Feedback(Base):
|
||||
chat_log: Mapped['ChatLog'] = relationship(back_populates='feedback')
|
||||
|
||||
|
||||
class ChatToolRun(Base):
|
||||
"""
|
||||
对话轮次 Tool 运行绑定表(chat-turn binding)。
|
||||
|
||||
用途:持久化 hxops_turn_id / chat_log_id / schedule_run_id 绑定,支撑跨 worker 与异步时序的稳定进度显示。
|
||||
约束:turn_id 非空且唯一,仅适用于经 chat API 触发的检核轮次;非聊天入口勿复用本表。
|
||||
"""
|
||||
|
||||
__tablename__ = 'chat_tool_runs'
|
||||
__table_args__ = (
|
||||
Index('ix_chat_tool_runs_chat_log_id', 'chat_log_id'),
|
||||
Index('ix_chat_tool_runs_schedule_run_id', 'schedule_run_id'),
|
||||
Index('ix_chat_tool_runs_session_task_created', 'session_id', 'schedule_task_id', 'created_at'),
|
||||
)
|
||||
|
||||
id: Mapped[int] = mapped_column(primary_key=True)
|
||||
tool_name: Mapped[str] = mapped_column(String(64), default='run_file_check')
|
||||
agent_id: Mapped[Optional[int]] = mapped_column(ForeignKey('agents.id'), index=True, nullable=True)
|
||||
user_id: Mapped[Optional[int]] = mapped_column(ForeignKey('users.id'), index=True, nullable=True)
|
||||
session_id: Mapped[str] = mapped_column(String(100), index=True)
|
||||
turn_id: Mapped[str] = mapped_column(String(64), unique=True)
|
||||
chat_log_id: Mapped[Optional[int]] = mapped_column(ForeignKey('chat_logs.id'), nullable=True)
|
||||
schedule_task_id: Mapped[Optional[int]] = mapped_column(ForeignKey('schedule_tasks.id'), nullable=True)
|
||||
schedule_run_id: Mapped[Optional[int]] = mapped_column(ForeignKey('schedule_runs.id'), nullable=True)
|
||||
user_message: Mapped[Optional[str]] = mapped_column(Text, nullable=True)
|
||||
status: Mapped[str] = mapped_column(String(20), default='pending')
|
||||
bind_source: Mapped[Optional[str]] = mapped_column(String(32), nullable=True)
|
||||
created_at: Mapped[datetime] = mapped_column(default=datetime.utcnow, index=True)
|
||||
updated_at: Mapped[datetime] = mapped_column(default=datetime.utcnow, onupdate=datetime.utcnow)
|
||||
|
||||
|
||||
class GeneralFeedback(Base):
|
||||
"""
|
||||
通用意见反馈表
|
||||
|
||||
Reference in new issue
Block a user