From a9a2c187197a9951f9d94ace76bc0e4609a34a9b Mon Sep 17 00:00:00 2001 From: huanghuoguoguo <1051233107@qq.com> Date: Sun, 7 Jun 2026 07:48:56 +0800 Subject: [PATCH] test: cover host skill tool scoping --- src/langbot/pkg/plugin/handler.py | 3 +++ tests/unit_tests/test_preproc.py | 22 ++++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/src/langbot/pkg/plugin/handler.py b/src/langbot/pkg/plugin/handler.py index 8605be55..4e797e08 100644 --- a/src/langbot/pkg/plugin/handler.py +++ b/src/langbot/pkg/plugin/handler.py @@ -71,6 +71,9 @@ def _i18n_to_text(value: Any) -> str: def _build_tool_detail(tool: Any, requested_tool_name: str | None = None) -> dict[str, Any]: """Normalize LLMTool and plugin ComponentManifest objects for tool detail APIs.""" + # TODO(litellm): This handler-local adapter is temporary. Once LiteLLM-backed + # tool schema normalization owns tool detail generation, simplify GET_TOOL_DETAIL + # and make ToolManager return one host-level tool detail shape. if hasattr(tool, 'metadata') and hasattr(tool, 'spec'): metadata = tool.metadata spec = tool.spec or {} diff --git a/tests/unit_tests/test_preproc.py b/tests/unit_tests/test_preproc.py index 079a5201..0b082e25 100644 --- a/tests/unit_tests/test_preproc.py +++ b/tests/unit_tests/test_preproc.py @@ -159,6 +159,28 @@ async def test_preproc_enables_skill_authoring_tools_when_skill_service_availabl app.tool_mgr.get_all_tools.assert_awaited_once_with(None, None, include_skill_authoring=True) +@pytest.mark.asyncio +async def test_preproc_puts_host_skill_tools_into_query_scope(): + """AgentRunner resource authorization consumes the tools discovered by preproc.""" + preproc_module, entities_module = _import_preproc_modules() + + app = _make_app(skill_service=SimpleNamespace()) + app.tool_mgr.get_all_tools = AsyncMock( + return_value=[ + SimpleNamespace(name='activate'), + SimpleNamespace(name='register_skill'), + ] + ) + query = _make_query() + stage = preproc_module.PreProcessor(app) + + result = await stage.process(query, 'PreProcessor') + + assert result.result_type == entities_module.ResultType.CONTINUE + app.tool_mgr.get_all_tools.assert_awaited_once_with(None, None, include_skill_authoring=True) + assert [tool.name for tool in query.use_funcs] == ['activate', 'register_skill'] + + @pytest.mark.asyncio async def test_preproc_disables_skill_authoring_tools_when_skill_service_missing(): preproc_module, entities_module = _import_preproc_modules()