refactor: unify host agent runtime access

This commit is contained in:
jxxghp
2026-08-24 06:42:07 +08:00
parent 46c5eec54e
commit 8e669d415e
11 changed files with 55 additions and 23 deletions
+2 -4
View File
@@ -37,10 +37,8 @@ from app.api.presentation.sse import build_sse_error_response, build_sse_respons
from app.agent.contracts import ReplyMode, build_display_message
from app.agent.llm.capability import AgentCapabilityManager
from app.agent.mcp import agent_mcp_manager
from app.agent.runtime_loader import (
get_moviepilot_agent_type,
get_running_agent_manager,
)
from app.agent.runtime_loader import get_moviepilot_agent_type
from app.application.agent import get_running_agent_manager
from app.chain.message import MessageChain
from app.application.commands import get_command, get_commands
from app.runtime.config import global_vars
+1 -1
View File
@@ -22,7 +22,7 @@ from app.api.openai_utils import (
build_session_id,
)
from app.api.presentation.sse import build_sse_response, encode_named_event
from app.agent.runtime_loader import get_running_agent_manager
from app.application.agent import get_running_agent_manager
from app.application.configuration import get_api_runtime_config_snapshot
from app.adapters.web.security.access import anthropic_api_key_header
from app.api.context import (
+1 -1
View File
@@ -14,7 +14,7 @@ from app.schemas.token import TokenPayload as _SchemaTokenPayload
from app.schemas.history import DownloadHistory as _SchemaDownloadHistory
from app.api.response import ResponseAPIRouter
from app.agent.contracts import ReplyMode
from app.agent.runtime_loader import get_running_agent_manager
from app.application.agent import get_running_agent_manager
from app.agent.prompt.transfer_redo import (
build_batch_manual_redo_prompt,
build_manual_redo_prompt,
+2 -4
View File
@@ -26,10 +26,8 @@ from app.api.openai_utils import (
build_session_id,
)
from app.api.presentation.sse import build_sse_response, encode_data_event
from app.agent.runtime_loader import (
get_moviepilot_agent_type,
get_running_agent_manager,
)
from app.agent.runtime_loader import get_moviepilot_agent_type
from app.application.agent import get_running_agent_manager
from app.agent.contracts import ReplyMode
from app.application.configuration import get_api_runtime_config_snapshot
from app.adapters.web.security.access import openai_bearer_scheme
+2
View File
@@ -78,6 +78,8 @@ def get_agent_manager() -> Any:
def get_running_agent_manager() -> Any | None:
"""返回已进入 RUNNING 的 AgentManager,不触发实现物化。"""
if _running_agent_manager_provider is None:
return None
return _resolve(_running_agent_manager_provider, "running_agent_manager")
+2 -2
View File
@@ -1580,7 +1580,7 @@ class Scheduler(ConfigReloadMixin, metaclass=SingletonClass):
:param trigger_source: 触发入口,scheduled-自动调度,manual-显式立即执行
:return: 执行是否成功及结果摘要
"""
from app.agent.runtime_loader import get_running_agent_manager
from app.application.agent import get_running_agent_manager
try:
manager = get_running_agent_manager()
@@ -1993,7 +1993,7 @@ class Scheduler(ConfigReloadMixin, metaclass=SingletonClass):
"""
智能体心跳唤醒:检查并执行待处理的定时任务
"""
from app.agent.runtime_loader import get_running_agent_manager
from app.application.agent import get_running_agent_manager
manager = get_running_agent_manager()
if manager is None: