fix(agent): keep chat reads on native async path

This commit is contained in:
InfinityPacer
2026-08-23 11:43:07 +08:00
parent 21ce70fbfc
commit f560c19d65
9 changed files with 106 additions and 66 deletions
+8 -5
View File
@@ -10,7 +10,10 @@ from app.runtime.settings import RuntimeSettingsCompat
settings = RuntimeSettingsCompat()
from app.application.agentdata import AgentChatPort as AgentChatOper
from app.application.messaging.chat import get_configured_agent_chat_persistence
from app.application.messaging.chat import (
get_configured_agent_chat_persistence,
get_configured_agent_chat_service,
)
from app.runtime.log import logger
from app.schemas.agent import ConversationMemory
@@ -109,19 +112,19 @@ class MemoryManager:
async def async_get_agent_messages(
self, session_id: str, user_id: str
) -> List[BaseMessage]:
"""异步恢复 Agent 消息,持久化读取经有界数据库 worker 承接"""
"""异步恢复 Agent 消息,查询与会话应用服务保持同一异步端口"""
memory = self.get_memory(session_id, user_id)
if memory:
return memory.messages
try:
persistence = get_configured_agent_chat_persistence()
chat = await persistence.async_get(
service = get_configured_agent_chat_service()
chat = await service.get(
session_id=session_id,
user_id=user_id,
)
if not chat:
chat = await persistence.async_get(session_id=session_id)
chat = await service.get(session_id=session_id)
except Exception as e:
logger.debug(f"读取持久化Agent会话失败: {e}")
return []