Skip to content

Commit fb4615a

Browse files
committed
Remove unused client parameter from prepare_tools
1 parent 5822294 commit fb4615a

5 files changed

Lines changed: 15 additions & 107 deletions

File tree

src/utils/responses.py

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@
8181
from llama_stack_client import APIConnectionError, APIStatusError, AsyncLlamaStackClient
8282

8383
import constants
84-
from client import AsyncLlamaStackClientHolder
8584
from configuration import configuration
8685
from constants import DEFAULT_RAG_TOOL
8786
from log import get_logger
@@ -219,8 +218,7 @@ async def maybe_get_topic_summary(
219218
return await get_topic_summary(input_text, client, model_id)
220219

221220

222-
async def prepare_tools( # pylint: disable=too-many-arguments,too-many-positional-arguments,unused-argument
223-
client: AsyncLlamaStackClient,
221+
async def prepare_tools( # pylint: disable=too-many-arguments,too-many-positional-arguments
224222
vector_store_ids: Optional[list[str]],
225223
no_tools: Optional[bool],
226224
token: str,
@@ -230,7 +228,6 @@ async def prepare_tools( # pylint: disable=too-many-arguments,too-many-position
230228
"""Prepare tools for Responses API including RAG and MCP tools.
231229
232230
Args:
233-
client: The Llama Stack client instance
234231
vector_store_ids: The list of vector store IDs to use for RAG tools
235232
or None to fall back to rag.tool configuration
236233
no_tools: Whether to skip tool preparation
@@ -360,7 +357,6 @@ async def prepare_responses_params( # pylint: disable=too-many-arguments,too-ma
360357

361358
# Prepare tools for responses API
362359
tools = await prepare_tools(
363-
client,
364360
query_request.vector_store_ids,
365361
query_request.no_tools,
366362
token,
@@ -1739,9 +1735,7 @@ async def _resolve_client_tools(
17391735

17401736
# Optionally merge server-configured tools (RAG, MCP) with client tools
17411737
if merge_server_tools:
1742-
client = AsyncLlamaStackClientHolder().get_client()
17431738
server_tools = await prepare_tools(
1744-
client=client,
17451739
vector_store_ids=vector_store_ids,
17461740
no_tools=False,
17471741
token=token,
@@ -1769,9 +1763,7 @@ async def _resolve_server_tools(
17691763
Returns:
17701764
List of server-configured tools, or None if none are configured.
17711765
"""
1772-
client = AsyncLlamaStackClientHolder().get_client()
17731766
return await prepare_tools(
1774-
client=client,
17751767
vector_store_ids=None, # allow all vector stores configured
17761768
no_tools=False,
17771769
token=token,
@@ -1815,9 +1807,7 @@ async def resolve_tool_choice(
18151807

18161808
if tools is None:
18171809
# Register all tools configured in LCORE configuration
1818-
client = AsyncLlamaStackClientHolder().get_client()
18191810
prepared_tools = await prepare_tools(
1820-
client=client,
18211811
vector_store_ids=None, # allow all vector stores configured
18221812
no_tools=False,
18231813
token=token,

tests/integration/endpoints/test_query_integration.py

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
# pylint: disable=too-many-arguments # Integration tests need many fixtures
55
# pylint: disable=too-many-positional-arguments # Integration tests need many fixtures
66

7-
87
import pytest
98
from fastapi import HTTPException, Request, status
109
from llama_stack_client import APIConnectionError
@@ -707,18 +706,10 @@ async def test_query_v2_endpoint_uses_tools_when_available(
707706
-------
708707
None
709708
"""
710-
_ = test_config
709+
# prepare_tools does not require llama-stack client anymore so the way to enable RAG tools is through config
710+
test_config.rag.tool = ["vs-test-123"]
711711
_ = patch_db_session
712712

713-
# Mock vector stores to be available (simulating RAG tools)
714-
mock_vector_store = mocker.MagicMock()
715-
mock_vector_store.id = "vs-test-123"
716-
717-
mock_list_result = mocker.MagicMock()
718-
mock_list_result.data = [mock_vector_store]
719-
720-
mock_llama_stack_client.vector_stores.list.return_value = mock_list_result
721-
722713
query_request = QueryRequest(query="What is Ansible?", no_tools=False)
723714

724715
response = await query_endpoint_handler(

tests/integration/endpoints/test_responses_byok_integration.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ def _patch_all_client_holders(mocker: MockerFixture, mock_client: Any) -> None:
7979
for module in (
8080
"app.endpoints.responses",
8181
"utils.endpoints",
82-
"utils.responses",
8382
):
8483
holder = mocker.patch(f"{module}.AsyncLlamaStackClientHolder")
8584
holder.return_value.get_client.return_value = mock_client

tests/unit/app/endpoints/test_responses.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -122,12 +122,6 @@ def _patch_base(mocker: MockerFixture, config: AppConfig) -> None:
122122
mocker.patch(f"{MODULE}.check_configuration_loaded")
123123
mocker.patch(f"{MODULE}.check_tokens_available")
124124
mocker.patch(f"{MODULE}.validate_model_provider_override")
125-
mock_holder = mocker.Mock()
126-
mock_holder.get_client.return_value = mocker.Mock()
127-
mocker.patch(
128-
f"{UTILS_RESPONSES_MODULE}.AsyncLlamaStackClientHolder",
129-
return_value=mock_holder,
130-
)
131125
mocker.patch(
132126
f"{UTILS_RESPONSES_MODULE}.prepare_tools",
133127
new=mocker.AsyncMock(return_value=None),

0 commit comments

Comments
 (0)