fix(responses): fix subtle bugs in non-function tool calling

This commit is contained in:
Ashwin Bharambe 2025-10-15 13:27:22 -07:00
parent d709eeb33f
commit 571276f88c
9 changed files with 5171 additions and 22 deletions

View file

@ -82,9 +82,11 @@ def test_mcp_invocation(llama_stack_client, text_model_id, mcp_server):
"server_label": test_toolgroup_id,
"require_approval": "never",
"allowed_tools": [tool.name for tool in tools_list],
"headers": {
"Authorization": f"Bearer {AUTH_TOKEN}",
},
}
]
agent = Agent(
client=llama_stack_client,
model=text_model_id,
@ -111,20 +113,23 @@ def test_mcp_invocation(llama_stack_client, text_model_id, mcp_server):
extra_headers=auth_headers,
)
)
events = [chunk.event for chunk in chunks]
final_response = next((chunk.response for chunk in reversed(chunks) if chunk.response), None)
assert final_response is not None
issued_calls = [
event for event in events if isinstance(event, StepProgress) and isinstance(event.delta, ToolCallIssuedDelta)
]
assert issued_calls and issued_calls[0].delta.tool_name == "greet_everyone"
assert issued_calls
assert issued_calls[-1].delta.tool_name == "greet_everyone"
tool_events = [
event for event in events if isinstance(event, StepCompleted) and event.step_type == "tool_execution"
]
assert tool_events and tool_events[0].result.tool_calls[0].tool_name == "greet_everyone"
assert tool_events
assert tool_events[-1].result.tool_calls[0].tool_name == "greet_everyone"
assert "hello" in final_response.output_text.lower()