Skip to content

Commit ae2d522

Browse files
committed
Adjust tools resolution
1 parent 28227a1 commit ae2d522

5 files changed

Lines changed: 31 additions & 8 deletions

File tree

docs/responses.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -841,4 +841,4 @@ User’s decision on an [mcp_approval_request](#mcp_approval_request): approve o
841841

842842
```json
843843
{ "input": [{ "type": "mcp_approval_response", "approval_request_id": "mar_1", "approve": true }] }
844-
```
844+
```

src/app/endpoints/responses.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -247,15 +247,14 @@ async def responses_endpoint_handler(
247247
request.headers,
248248
)
249249

250-
#Build RAG context from Inline RAG sources
250+
# Build RAG context from Inline RAG sources
251251
inline_rag_context = await build_rag_context(
252252
client,
253253
moderation_result.decision,
254254
input_text,
255255
vector_store_ids,
256256
responses_request.solr,
257257
)
258-
259258
if moderation_result.decision == "passed":
260259
responses_request.input = append_inline_rag_context_to_responses_input(
261260
responses_request.input, inline_rag_context.context_text
@@ -676,7 +675,6 @@ async def handle_non_streaming_response(
676675
)
677676
else:
678677
try:
679-
print("API Params: ", api_params.model_dump(exclude_none=True))
680678
api_response = cast(
681679
OpenAIResponseObject,
682680
await client.responses.create(

src/app/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,5 +229,5 @@ async def send_wrapper(message: Message) -> None:
229229
# RestApiMetricsMiddleware (registered last) is outermost. This ensures metrics
230230
# always observe a status code — including 500s synthesised by the exception
231231
# middleware — rather than seeing a raw exception with no response.
232-
#app.add_middleware(GlobalExceptionMiddleware)
232+
app.add_middleware(GlobalExceptionMiddleware)
233233
app.add_middleware(RestApiMetricsMiddleware)

tests/e2e/features/responses.feature

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ Feature: Responses endpoint API tests
429429
And The body of the response contains Unable to connect to Llama Stack
430430

431431

432-
Scenario: Check if responses endpoint with tool_choice none answers knowledge question without file search usage
432+
Scenario: Responses endpoint with tool_choice none answers knowledge question without file search usage
433433
Given The system is in default state
434434
And I set the Authorization header to Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6Ikpva
435435
And I capture the current token metrics
@@ -572,4 +572,27 @@ Scenario: Check if responses endpoint with tool_choice none answers knowledge qu
572572
"""
573573
Then The status code of the response is 200
574574
And The responses output should not include an item with type "file_search_call"
575-
And The token metrics should have increased
575+
And The token metrics should have increased
576+
577+
Scenario: Required allowed_tools with invalid filter returns no tool invocations on knowledge question
578+
Given The system is in default state
579+
And I set the Authorization header to Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6Ikpva
580+
And I capture the current token metrics
581+
When I use "responses" to ask question with authorization header
582+
"""
583+
{
584+
"input": "What is the title of the article from Paul?",
585+
"model": "{PROVIDER}/{MODEL}",
586+
"stream": false,
587+
"instructions": "You are an assistant. You MUST use the file_search tool to answer. Answer in lowercase.",
588+
"tools": [],
589+
"tool_choice": {
590+
"type": "allowed_tools",
591+
"mode": "required",
592+
"tools": [{"non-existing": "tool"}]
593+
}
594+
}
595+
"""
596+
Then The status code of the response is 200
597+
And The responses output should not include any tool invocation item types
598+
And The token metrics should have increased

tests/e2e/features/steps/llm_query_response.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@ def responses_output_should_include_item_type(context: Context, item_type: str)
5757

5858

5959
@then('The responses output should not include an item with type "{item_type}"')
60-
def responses_output_should_not_include_item_type(context: Context, item_type: str) -> None:
60+
def responses_output_should_not_include_item_type(
61+
context: Context, item_type: str
62+
) -> None:
6163
"""Assert no ``output`` item has the given ``type``."""
6264
assert context.response is not None, "Request needs to be performed first"
6365
response_json = cast(dict[str, Any], context.response.json())

0 commit comments

Comments
 (0)