fix(backend): remove leaked request variable causing SSE task execution failure

This commit is contained in:
lidf 2026-04-12 15:56:18 +08:00
parent 131a1bb33b
commit bcdd6e36ff

View File

@ -528,16 +528,13 @@ class DeepviewSSEServer:
db = SessionDB() db = SessionDB()
loop = asyncio.get_event_loop() loop = asyncio.get_event_loop()
# 此处获取 user 的 userId
userObj = await self._extractUser(request)
userId = userObj.get("sub", "unknown") if userObj else "unknown"
# 从环境变量获取存储根目录,并获取用户专属沙箱与机构知识域 # 从环境变量获取存储根目录,并获取用户专属沙箱与机构知识域
storageDir = os.getenv("DEEPVIEW_STORAGE_DIR", os.path.expanduser("~/Downloads/Coding/医生助理智能体/backend/storage")) storageDir = os.getenv("DEEPVIEW_STORAGE_DIR", os.path.expanduser("~/Downloads/Coding/医生助理智能体/backend/storage"))
userDir = self._getUserStorageDir(userId) userDir = self._getUserStorageDir(userId)
# 解析 orgId # 解析 orgId
orgId = userObj.get("org", "org_001") if userObj else "org_001" orgId = "org_001"
orgDir = self._getOrgStorageDir(orgId) orgDir = self._getOrgStorageDir(orgId)
platformDir = os.path.join(storageDir, "platform") platformDir = os.path.join(storageDir, "platform")
@ -984,6 +981,11 @@ xray.module5: track1(数组,每项含node/action/strategy/purpose), track2(数
reportData = json.loads(row[0]) reportData = json.loads(row[0])
clientId = row[2] clientId = row[2]
# Hot patch reportCode for older generated reports that might have hallucinated ones
reportData["reportCode"] = f"DW-AMXG-{reportId[4:].upper()}"
reportData["id"] = reportId
# Attach clientId into the data payload so the frontend knows if it's archived # Attach clientId into the data payload so the frontend knows if it's archived
if clientId: if clientId:
reportData["clientId"] = clientId reportData["clientId"] = clientId