diff --git a/llama_stack/providers/inline/tool_runtime/rag/memory.py b/llama_stack/providers/inline/tool_runtime/rag/memory.py index df0257718..968f93354 100644 --- a/llama_stack/providers/inline/tool_runtime/rag/memory.py +++ b/llama_stack/providers/inline/tool_runtime/rag/memory.py @@ -105,7 +105,9 @@ class MemoryToolRuntimeImpl(ToolsProtocolPrivate, ToolRuntime, RAGToolRuntime): query_config: RAGQueryConfig | None = None, ) -> RAGQueryResult: if not vector_db_ids: - return RAGQueryResult(content=None) + raise ValueError( + "No vector DBs were provided to the knowledge search tool. Please provide at least one vector DB ID." + ) query_config = query_config or RAGQueryConfig() query = await generate_rag_query( diff --git a/tests/unit/rag/test_rag_query.py b/tests/unit/rag/test_rag_query.py new file mode 100644 index 000000000..b9fd8cca4 --- /dev/null +++ b/tests/unit/rag/test_rag_query.py @@ -0,0 +1,19 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the terms described in the LICENSE file in +# the root directory of this source tree. + +from unittest.mock import MagicMock + +import pytest + +from llama_stack.providers.inline.tool_runtime.rag.memory import MemoryToolRuntimeImpl + + +class TestRagQuery: + @pytest.mark.asyncio + async def test_query_raises_on_empty_vector_db_ids(self): + rag_tool = MemoryToolRuntimeImpl(config=MagicMock(), vector_io_api=MagicMock(), inference_api=MagicMock()) + with pytest.raises(ValueError): + await rag_tool.query(content=MagicMock(), vector_db_ids=[])