fix(agent): close async chat persistence lifecycle

This commit is contained in:
InfinityPacer
2026-08-23 11:44:18 +08:00
parent 6f5ee96152
commit 0ba4a7e5e3
14 changed files with 448 additions and 72 deletions
+9
View File
@@ -4,6 +4,7 @@ from fastapi import Depends
from sqlalchemy.ext.asyncio import AsyncSession
from app.api.context import (
get_agent_chat_runtime,
get_agent_chat_repository,
get_agent_chat_transaction,
get_async_session,
@@ -11,6 +12,7 @@ from app.api.context import (
)
from app.application.messaging.chat import (
AgentChatService,
AgentChatPersistenceService,
AsyncAgentChatRepository,
AsyncUnitOfWork,
)
@@ -26,6 +28,13 @@ def get_agent_chat_service(
return AgentChatService(chat_repository, unit_of_work)
def get_agent_chat_persistence(
runtime: HostRuntime = Depends(get_agent_chat_runtime),
) -> AgentChatPersistenceService:
"""从类型化 Agent 运行时获取有界会话写入端口。"""
return runtime.persistence
def get_message_query_service(
db: AsyncSession = Depends(get_async_session),
runtime: HostRuntime = Depends(get_host_runtime),