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 -18
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,
)
import asyncio
import threading
import time
@@ -278,14 +263,15 @@ class TestTelegramTypingLifecycle(unittest.TestCase):
) as start_status, patch(
"app.chain.message.settings.AI_AGENT_ENABLE", True
), 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(), Mock())[1],
), patch.object(
chain, "_mark_message_processing_finished"
) as finish_status:
process_message = AsyncMock()
get_running_manager.return_value.process_message = process_message
chain.handle_message(
channel=MessageChannel.Telegram,
source="telegram-test",