feat(deep-research): 强化任务链路可靠性并接入 agentfx 报告助手种子

功能说明:\n- 重构 Deep Research 调度与执行链,补齐 dispatcher、executor、live hub 与依赖注入入口,提升任务下发、执行、回调的稳定性\n- 增强运行时持久化与恢复能力,接入业务映射、任务来源与任务事件日志模型,覆盖持久化与执行可靠性关键路径测试\n- 新增 agentfx 报告助手 seed 与任务报告导入脚本配置,支持离线环境快速初始化与任务流模板回填\n- 完善 deep-research 与 thread_runs 路由参数编排,兼容不同业务映射与运行入口的前后端联动\n- 补充前端 agentfx deep-link 解析,保证 deep-research 场景下的登录跳转与任务上下文一致
This commit is contained in:
董宏凯 committed 2026-09-04 23:18:52 +08:00
1 parent 438772f0b7
commit 5c75e1af16
36 files changed
+3163 -312

No files matched your search

@@ -137,6 +137,38 @@ class DeepResearchJobRepository:
# Should not happen in practice.
raise RuntimeError("try_create_or_get_active: race condition not resolved after retries")
async def replace_input_snapshot(self, job_id: str, input_snapshot: dict[str, Any]) -> dict[str, Any] | None:
"""Overwrite the frozen start payload on a still-queued job.
Idempotent retries used to keep the first snapshot forever. A first
write that raced ahead of the browser evidence (or a reused empty
job) then ran without ``collector_materials`` even though the later
request carried them.
"""
async with self._sf() as session:
result = await session.execute(
update(DeepResearchJobRow)
.where(
DeepResearchJobRow.id == job_id,
DeepResearchJobRow.status.in_(("queued", "running")),
)
.values(
input_snapshot=_dumps(input_snapshot),
updated_at=datetime.now(UTC),
)
)
if result.rowcount == 0:
await session.rollback()
return None
row = (
await session.execute(
select(DeepResearchJobRow).where(DeepResearchJobRow.id == job_id)
)
).scalar_one_or_none()
snapshot = self._row_to_dict(row) if row else None
await session.commit()
return snapshot
async def _get_by_dedupe_key(self, dedupe_key: str) -> dict[str, Any] | None:
async with self._sf() as session:
row = (
@@ -198,12 +230,13 @@ class DeepResearchJobRepository:
stmt = (
select(DeepResearchJobRow.id)
.where(
DeepResearchJobRow.cancel_requested.is_(False),
or_(
DeepResearchJobRow.status == "queued",
(DeepResearchJobRow.status == "running")
& DeepResearchJobRow.lease_until.is_not(None)
& (DeepResearchJobRow.lease_until < now),
)
),
)
.order_by(DeepResearchJobRow.updated_at.asc())
.limit(limit)
@@ -227,6 +260,7 @@ class DeepResearchJobRepository:
}
where = [
DeepResearchJobRow.id == job_id,
DeepResearchJobRow.cancel_requested.is_(False),
or_(
DeepResearchJobRow.status == "queued",
(DeepResearchJobRow.status == "running")