mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-04 23:17:20 +08:00
fix(agent): keep chat reads on native async path
This commit is contained in:
@@ -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 []
|
||||
|
||||
@@ -82,6 +82,7 @@ def _get_plugin_tools_revision() -> int:
|
||||
from app.application.agentdata import AgentTaskPort as AgentTaskOper
|
||||
from app.application.agentdata import UserPort as UserOper
|
||||
from app.application.messaging.chat import (
|
||||
get_configured_agent_chat_service,
|
||||
get_configured_agent_chat_persistence,
|
||||
has_custom_agent_chat_title,
|
||||
)
|
||||
@@ -579,7 +580,7 @@ class MoviePilotAgent:
|
||||
return
|
||||
self._tool_context["chat_title_prepared"] = True
|
||||
try:
|
||||
chat = await get_configured_agent_chat_persistence().async_get(
|
||||
chat = await get_configured_agent_chat_service().get(
|
||||
session_id=self.session_id,
|
||||
user_id=self.user_id,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user