test: cover host skill tool scoping

This commit is contained in:
huanghuoguoguo
2026-06-07 07:48:56 +08:00
parent 80485b57ea
commit a9a2c18719
2 changed files with 25 additions and 0 deletions

View File

@@ -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 {}

View File

@@ -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()