refactor(agent): 按需加载 Agent 运行时 (#6336)

This commit is contained in:
InfinityPacer
2026-08-16 19:25:24 +08:00
committed by GitHub
parent e5f0c53069
commit 5b367011c5
56 changed files with 5059 additions and 628 deletions
+4 -17
View File
@@ -1,18 +1,3 @@
# 把真实 Agent 服务注册进 application 门面(幂等),供测试 patch 门面背后的单例方法。
from app.agent.llm import AgentCapabilityManager, LLMHelper
from app.agent.orchestrator import agent_manager
from app.agent.prompt import prompt_manager
from app.agent.prompt.transfer_redo import build_manual_redo_prompt
from app.application.agent import register_agent_services
register_agent_services(
agent_manager=agent_manager,
prompt_manager=prompt_manager,
capability_manager=AgentCapabilityManager,
llm_helper=LLMHelper,
manual_redo_prompt_builder=build_manual_redo_prompt,
)
from unittest.mock import AsyncMock, patch
from app.agent import MoviePilotAgent
@@ -84,11 +69,13 @@ def test_handle_ai_message_routes_text_only_model_images_to_files(monkeypatch):
}
],
) as prepare_files, patch(
"app.application.agent._agent_manager.process_message", new_callable=AsyncMock
) as process_message, patch(
"app.chain.message.get_running_agent_manager"
) as get_running_manager, patch(
"app.chain.message.asyncio.run_coroutine_threadsafe",
side_effect=lambda coro, _loop: coro.close(),
):
process_message = AsyncMock()
get_running_manager.return_value.process_message = process_message
chain._handle_ai_message(
text="/ai 帮我看看这张图",
channel=MessageChannel.Telegram,