diff --git a/astrbot/core/astr_agent_tool_exec.py b/astrbot/core/astr_agent_tool_exec.py index 2a58597ca..4ed600bed 100644 --- a/astrbot/core/astr_agent_tool_exec.py +++ b/astrbot/core/astr_agent_tool_exec.py @@ -17,13 +17,6 @@ from astrbot.core.agent.run_context import ContextWrapper from astrbot.core.agent.tool import FunctionTool, ToolSet from astrbot.core.agent.tool_executor import BaseFunctionToolExecutor from astrbot.core.astr_agent_context import AstrAgentContext - -from astrbot.core.tools.prompts import ( - BACKGROUND_TASK_RESULT_WOKE_SYSTEM_PROMPT, - BACKGROUND_TASK_WOKE_USER_PROMPT, - CONVERSATION_HISTORY_INJECT_PREFIX, -) -from astrbot.core.tools.send_message import SEND_MESSAGE_TO_USER_TOOL from astrbot.core.cron.events import CronMessageEvent from astrbot.core.message.components import Image from astrbot.core.message.message_event_result import ( @@ -34,6 +27,12 @@ from astrbot.core.message.message_event_result import ( from astrbot.core.platform.message_session import MessageSession from astrbot.core.provider.entites import ProviderRequest from astrbot.core.provider.register import llm_tools +from astrbot.core.tools.prompts import ( + BACKGROUND_TASK_RESULT_WOKE_SYSTEM_PROMPT, + BACKGROUND_TASK_WOKE_USER_PROMPT, + CONVERSATION_HISTORY_INJECT_PREFIX, +) +from astrbot.core.tools.send_message import SEND_MESSAGE_TO_USER_TOOL from astrbot.core.utils.astrbot_path import get_astrbot_temp_path from astrbot.core.utils.history_saver import persist_agent_history from astrbot.core.utils.image_ref_utils import is_supported_image_ref diff --git a/astrbot/core/astr_main_agent.py b/astrbot/core/astr_main_agent.py index f4e1dce8f..a65e6109f 100644 --- a/astrbot/core/astr_main_agent.py +++ b/astrbot/core/astr_main_agent.py @@ -18,6 +18,18 @@ from astrbot.core.astr_agent_context import AgentContextWrapper, AstrAgentContex from astrbot.core.astr_agent_hooks import MAIN_AGENT_HOOKS from astrbot.core.astr_agent_run_util import AgentRunner from astrbot.core.astr_agent_tool_exec import FunctionToolExecutor +from astrbot.core.conversation_mgr import Conversation +from astrbot.core.message.components import File, Image, Reply +from astrbot.core.persona_error_reply import ( + extract_persona_custom_error_message_from_persona, + set_persona_custom_error_message_on_event, +) +from astrbot.core.platform.astr_message_event import AstrMessageEvent +from astrbot.core.provider import Provider +from astrbot.core.provider.entities import ProviderRequest +from astrbot.core.skills.skill_manager import SkillManager, build_skills_prompt +from astrbot.core.star.context import Context +from astrbot.core.star.star_handler import star_map from astrbot.core.tool_provider import ToolProvider, ToolProviderContext from astrbot.core.tools.kb_query import ( KNOWLEDGE_BASE_QUERY_TOOL, @@ -36,18 +48,6 @@ from astrbot.core.tools.prompts import ( WEBCHAT_TITLE_GENERATOR_USER_PROMPT, ) from astrbot.core.tools.send_message import SEND_MESSAGE_TO_USER_TOOL -from astrbot.core.conversation_mgr import Conversation -from astrbot.core.message.components import File, Image, Reply -from astrbot.core.persona_error_reply import ( - extract_persona_custom_error_message_from_persona, - set_persona_custom_error_message_on_event, -) -from astrbot.core.platform.astr_message_event import AstrMessageEvent -from astrbot.core.provider import Provider -from astrbot.core.provider.entities import ProviderRequest -from astrbot.core.skills.skill_manager import SkillManager, build_skills_prompt -from astrbot.core.star.context import Context -from astrbot.core.star.star_handler import star_map from astrbot.core.utils.file_extract import extract_file_moonshotai from astrbot.core.utils.llm_metadata import LLM_METADATAS from astrbot.core.utils.quoted_message.settings import ( diff --git a/astrbot/core/computer/computer_tool_provider.py b/astrbot/core/computer/computer_tool_provider.py index dedb3c019..36ced506f 100644 --- a/astrbot/core/computer/computer_tool_provider.py +++ b/astrbot/core/computer/computer_tool_provider.py @@ -13,7 +13,6 @@ does not require changes here. from __future__ import annotations import platform -from functools import cache from typing import TYPE_CHECKING from astrbot.api import logger diff --git a/tests/test_booter_decoupling.py b/tests/test_booter_decoupling.py index 1b106be35..5b19c32ab 100644 --- a/tests/test_booter_decoupling.py +++ b/tests/test_booter_decoupling.py @@ -231,7 +231,9 @@ class TestApplySandboxToolsRefactored: def test_neo_tools_registered_via_provider(self): """get_tools() returns full neo tool set (18 tools) for sandbox/neo config.""" try: - from astrbot.core.computer.computer_tool_provider import ComputerToolProvider + from astrbot.core.computer.computer_tool_provider import ( + ComputerToolProvider, + ) from astrbot.core.tool_provider import ToolProviderContext except ImportError: pytest.skip("circular import") @@ -250,7 +252,9 @@ class TestApplySandboxToolsRefactored: def test_neo_prompt_injected_via_provider(self): """get_system_prompt_addon() includes sandbox hint and neo-specific fragments.""" try: - from astrbot.core.computer.computer_tool_provider import ComputerToolProvider + from astrbot.core.computer.computer_tool_provider import ( + ComputerToolProvider, + ) from astrbot.core.tool_provider import ToolProviderContext except ImportError: pytest.skip("circular import") @@ -269,7 +273,9 @@ class TestApplySandboxToolsRefactored: def test_shipyard_no_neo_prompt_via_provider(self): """Shipyard config: get_tools returns 4 tools, prompt has no neo lifecycle text.""" try: - from astrbot.core.computer.computer_tool_provider import ComputerToolProvider + from astrbot.core.computer.computer_tool_provider import ( + ComputerToolProvider, + ) from astrbot.core.tool_provider import ToolProviderContext except ImportError: pytest.skip("circular import") @@ -305,7 +311,9 @@ class TestApplySandboxToolsRefactored: The executor rejects browser calls when the capability is absent. """ try: - from astrbot.core.computer.computer_tool_provider import ComputerToolProvider + from astrbot.core.computer.computer_tool_provider import ( + ComputerToolProvider, + ) from astrbot.core.tool_provider import ToolProviderContext except ImportError: pytest.skip("circular import") @@ -329,7 +337,9 @@ class TestApplySandboxToolsRefactored: def test_none_runtime_returns_empty(self): """runtime='none' must return no tools and no prompt addon.""" try: - from astrbot.core.computer.computer_tool_provider import ComputerToolProvider + from astrbot.core.computer.computer_tool_provider import ( + ComputerToolProvider, + ) from astrbot.core.tool_provider import ToolProviderContext except ImportError: pytest.skip("circular import") @@ -340,7 +350,9 @@ class TestApplySandboxToolsRefactored: def test_shipyard_missing_endpoint_returns_empty(self): """Shipyard config without endpoint/token must return [] (not crash).""" try: - from astrbot.core.computer.computer_tool_provider import ComputerToolProvider + from astrbot.core.computer.computer_tool_provider import ( + ComputerToolProvider, + ) from astrbot.core.tool_provider import ToolProviderContext except ImportError: pytest.skip("circular import")