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
@@ -0,0 +1,78 @@
|
||||
"""add chat_tool_runs table
|
||||
|
||||
Revision ID: e2f3a4b5c6d7
|
||||
Revises: d1e2f3a4b5c6, ff6a7b8c9d0e
|
||||
Create Date: 2026-07-09 15:40:00.000000
|
||||
|
||||
Purpose:
|
||||
Persist hxops_turn_id / chat_log_id / schedule_run_id bindings for stable
|
||||
file-check progress display across workers and async ordering.
|
||||
"""
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
revision = 'e2f3a4b5c6d7'
|
||||
down_revision = ('d1e2f3a4b5c6', 'ff6a7b8c9d0e')
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
bind = op.get_bind()
|
||||
insp = sa.inspect(bind)
|
||||
if 'chat_tool_runs' in set(insp.get_table_names()):
|
||||
return
|
||||
|
||||
op.create_table(
|
||||
'chat_tool_runs',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('tool_name', sa.String(length=64), nullable=False, server_default='run_file_check'),
|
||||
sa.Column('agent_id', sa.Integer(), nullable=True),
|
||||
sa.Column('user_id', sa.Integer(), nullable=True),
|
||||
sa.Column('session_id', sa.String(length=100), nullable=False),
|
||||
sa.Column('turn_id', sa.String(length=64), nullable=False),
|
||||
sa.Column('chat_log_id', sa.Integer(), nullable=True),
|
||||
sa.Column('schedule_task_id', sa.Integer(), nullable=True),
|
||||
sa.Column('schedule_run_id', sa.Integer(), nullable=True),
|
||||
sa.Column('user_message', sa.Text(), nullable=True),
|
||||
sa.Column('status', sa.String(length=20), nullable=False, server_default='pending'),
|
||||
sa.Column('bind_source', sa.String(length=32), nullable=True),
|
||||
sa.Column('created_at', sa.DateTime(), nullable=True),
|
||||
sa.Column('updated_at', sa.DateTime(), nullable=True),
|
||||
sa.ForeignKeyConstraint(['agent_id'], ['agents.id']),
|
||||
sa.ForeignKeyConstraint(['chat_log_id'], ['chat_logs.id']),
|
||||
sa.ForeignKeyConstraint(['schedule_run_id'], ['schedule_runs.id']),
|
||||
sa.ForeignKeyConstraint(['schedule_task_id'], ['schedule_tasks.id']),
|
||||
sa.ForeignKeyConstraint(['user_id'], ['users.id']),
|
||||
sa.PrimaryKeyConstraint('id'),
|
||||
sa.UniqueConstraint('turn_id'),
|
||||
)
|
||||
op.create_index('ix_chat_tool_runs_chat_log_id', 'chat_tool_runs', ['chat_log_id'], unique=False)
|
||||
op.create_index('ix_chat_tool_runs_schedule_run_id', 'chat_tool_runs', ['schedule_run_id'], unique=False)
|
||||
op.create_index(
|
||||
'ix_chat_tool_runs_session_task_created',
|
||||
'chat_tool_runs',
|
||||
['session_id', 'schedule_task_id', 'created_at'],
|
||||
unique=False,
|
||||
)
|
||||
op.create_index(op.f('ix_chat_tool_runs_agent_id'), 'chat_tool_runs', ['agent_id'], unique=False)
|
||||
op.create_index(op.f('ix_chat_tool_runs_created_at'), 'chat_tool_runs', ['created_at'], unique=False)
|
||||
op.create_index(op.f('ix_chat_tool_runs_session_id'), 'chat_tool_runs', ['session_id'], unique=False)
|
||||
op.create_index(op.f('ix_chat_tool_runs_user_id'), 'chat_tool_runs', ['user_id'], unique=False)
|
||||
|
||||
|
||||
def downgrade():
|
||||
bind = op.get_bind()
|
||||
insp = sa.inspect(bind)
|
||||
if 'chat_tool_runs' not in set(insp.get_table_names()):
|
||||
return
|
||||
op.drop_index(op.f('ix_chat_tool_runs_user_id'), table_name='chat_tool_runs')
|
||||
op.drop_index(op.f('ix_chat_tool_runs_session_id'), table_name='chat_tool_runs')
|
||||
op.drop_index(op.f('ix_chat_tool_runs_created_at'), table_name='chat_tool_runs')
|
||||
op.drop_index(op.f('ix_chat_tool_runs_agent_id'), table_name='chat_tool_runs')
|
||||
op.drop_index('ix_chat_tool_runs_session_task_created', table_name='chat_tool_runs')
|
||||
op.drop_index('ix_chat_tool_runs_schedule_run_id', table_name='chat_tool_runs')
|
||||
op.drop_index('ix_chat_tool_runs_chat_log_id', table_name='chat_tool_runs')
|
||||
op.drop_table('chat_tool_runs')
|
||||
Reference in new issue
Block a user