diff --git a/backend/app/services/file_check_tools/chat_log_run_resolver.py b/backend/app/services/file_check_tools/chat_log_run_resolver.py
index f1ab478a..2ee5d402 100644
--- a/backend/app/services/file_check_tools/chat_log_run_resolver.py
+++ b/backend/app/services/file_check_tools/chat_log_run_resolver.py
@@ -2,13 +2,17 @@
services/file_check_tools/chat_log_run_resolver.py
用途:按 ChatLog.run_id 解析文件检核进度(按轮问答)。
-依赖:ChatLog、ScheduleRun。
-逻辑:由 for-log API 调用;run_id 在 message_end 写入 chat_logs 表。
+依赖:ChatLog、ScheduleRun、chat_log_run_binding、chat_turn_registry。
+逻辑:for-log API 调用;优先读 chat_logs.run_id,缺失时按 session/query 兜底匹配并懒回写。
"""
from __future__ import annotations
from app import db
from app.models import ChatLog, ScheduleRun
+from app.services.file_check_tools.chat_log_run_binding import (
+ resolve_run_id_for_chat_log,
+ update_chat_log_run_id,
+)
def find_run_for_chat_log(
@@ -30,10 +34,24 @@ def find_run_for_chat_log(
return None
log = db.session.get(ChatLog, chat_log_id)
- if not log or not log.run_id:
+ if not log:
return None
- run = db.session.get(ScheduleRun, log.run_id)
+ run_id = int(log.run_id) if log.run_id else None
+ if not run_id:
+ # [STEP 1] message_end 可能早于 Tool 启动完成,按 session/query 从注册表或 ScheduleRun 兜底
+ resolved = resolve_run_id_for_chat_log(
+ session_id=log.session_id,
+ query=log.query,
+ )
+ if resolved:
+ update_chat_log_run_id(chat_log_id, resolved)
+ run_id = resolved
+
+ if not run_id:
+ return None
+
+ run = db.session.get(ScheduleRun, run_id)
if run and run.schedule_task_id == task_id:
return run
return None
diff --git a/backend/tests/test_file_check_tools.py b/backend/tests/test_file_check_tools.py
index 1d80c292..3f419e0a 100644
--- a/backend/tests/test_file_check_tools.py
+++ b/backend/tests/test_file_check_tools.py
@@ -653,6 +653,51 @@ def test_workspace_file_check_run_for_log_returns_null_when_unbound(app, client)
assert payload.get('match_source') is None
+def test_workspace_file_check_run_for_log_lazy_binds_via_session_query(app, client):
+ """chat_log 尚无 run_id 时,for-log 应按 session/query 兜底匹配并回写。"""
+ with app.app_context():
+ admin = _mk_admin()
+ db.session.commit()
+ task = _mk_check_task(admin.id)
+ run = ScheduleRun(
+ run_no='RUN-ROHS-LAZY',
+ schedule_task_id=task.id,
+ status='running',
+ trigger_type='dify_chatflow',
+ api_request_json={
+ 'bind_session_id': 'sess-lazy-bind',
+ 'bind_user_message': '立即执行文件检核',
+ },
+ )
+ db.session.add(run)
+ db.session.commit()
+ log = ChatLog(
+ user_id=admin.id,
+ agent_id=1,
+ query='立即执行文件检核',
+ answer='检核已启动',
+ session_id='sess-lazy-bind',
+ )
+ db.session.add(log)
+ db.session.commit()
+ task_id = task.id
+ chat_log_id = log.id
+ run_id = run.id
+
+ res = client.get(
+ f'/api/workspace/file-check/runs/for-log?task_id={task_id}&chat_log_id={chat_log_id}',
+ headers={'X-Username': 'admin'},
+ )
+ assert res.status_code == 200
+ payload = res.get_json()
+ assert payload['run']['run_id'] == run_id
+ assert payload['match_source'] == 'chat_log'
+
+ with app.app_context():
+ rebound = db.session.get(ChatLog, chat_log_id)
+ assert rebound.run_id == run_id
+
+
def test_workspace_file_check_run_for_log_reads_bound_run_id(app, client):
with app.app_context():
admin = _mk_admin()
diff --git a/frontend/src/features/admin/modules/agents/AgentsPage.vue b/frontend/src/features/admin/modules/agents/AgentsPage.vue
index 05cda23b..177861bd 100644
--- a/frontend/src/features/admin/modules/agents/AgentsPage.vue
+++ b/frontend/src/features/admin/modules/agents/AgentsPage.vue
@@ -12,12 +12,14 @@ import { Bot, Plus, Trash2, Users } from 'lucide-vue-next';
import DeleteConfirmDialog from '@/shared/components/DeleteConfirmDialog.vue';
import AgentPermissionModal from './components/AgentPermissionModal.vue';
import AgentTestModal from './components/AgentTestModal.vue';
+import AgentToolRunProgressConfig from './components/AgentToolRunProgressConfig.vue';
import { useAgentsAdmin } from './composables/useAgentsAdmin';
const { t } = useI18n();
const {
agents,
+ scheduleTasks,
activeUsers,
isLoading,
isSaving,
@@ -195,6 +197,12 @@ onMounted(() => {
+
+