fix(db): 修复数据库会话获取失败时的处理逻辑

在 `db_query` 和 `db_save` 函数中,增加了对数据库会话(session)获取失败的检查。当无法获取会话时,记录错误日志并返回 None 或空列表,避免了后续操作因会话为空而引发的异常。

同时,修复了 `proactive_thinker_executor` 中因数据库查询返回 None 而导致处理 `action_history` 时出错的问题。
This commit is contained in:
minecraft1024a
2025-10-02 17:08:30 +08:00
parent 209960b788
commit 920396a0fc
2 changed files with 11 additions and 2 deletions

View File

@@ -128,7 +128,9 @@ class ProactiveThinkerExecutor:
limit=3,
order_by=["-time"]
)
action_history_context = "\n".join([f"- {a['action_data']}" for a in action_history]) if action_history else ""
action_history_context = ""
if isinstance(action_history, list):
action_history_context = "\n".join([f"- {a['action_data']}" for a in action_history if isinstance(a, dict)]) or ""
return {
"person_id": person_id,