mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-06-07 14:26:03 +00:00
test: cover host skill tool scoping
This commit is contained in:
@@ -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 {}
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user