Skip to content

Commit ba04868

Browse files
committed
test: add test for Agent.create_turn non-streaming response
Summary: This tests the fix to the SDK in llamastack/llama-stack-client-python#141 Test Plan: LLAMA_STACK_CONFIG=fireworks pytest -s -v tests/client-sdk/ --safety-shield meta-llama/Llama-Guard-3-8B
1 parent d8a20e0 commit ba04868

File tree

1 file changed

+32
-2
lines changed

1 file changed

+32
-2
lines changed

tests/client-sdk/agents/test_agents.py

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ def test_custom_tool(llama_stack_client, agent_config):
317317
logs = [str(log) for log in EventLogger().log(response) if log is not None]
318318
logs_str = "".join(logs)
319319
assert "-100" in logs_str
320-
assert "CustomTool" in logs_str
320+
assert "get_boiling_point" in logs_str
321321

322322

323323
# TODO: fix this flaky test
@@ -401,7 +401,7 @@ def xtest_override_system_message_behavior(llama_stack_client, agent_config):
401401
logs_str = "".join(logs)
402402
print(logs_str)
403403
assert "-100" in logs_str
404-
assert "CustomTool" in logs_str
404+
assert "get_boiling_point" in logs_str
405405

406406

407407
def test_rag_agent(llama_stack_client, agent_config):
@@ -525,3 +525,33 @@ def test_rag_and_code_agent(llama_stack_client, agent_config):
525525
logs = [str(log) for log in EventLogger().log(response) if log is not None]
526526
logs_str = "".join(logs)
527527
assert f"Tool:{tool_name}" in logs_str
528+
529+
530+
def test_create_turn_response(llama_stack_client, agent_config):
531+
client_tool = TestClientTool()
532+
agent_config = {
533+
**agent_config,
534+
"input_shields": [],
535+
"output_shields": [],
536+
"client_tools": [client_tool.get_tool_definition()],
537+
}
538+
539+
agent = Agent(llama_stack_client, agent_config, client_tools=(client_tool,))
540+
session_id = agent.create_session(f"test-session-{uuid4()}")
541+
542+
response = agent.create_turn(
543+
messages=[
544+
{
545+
"role": "user",
546+
"content": "What is the boiling point of polyjuice?",
547+
},
548+
],
549+
session_id=session_id,
550+
stream=False,
551+
)
552+
steps = response.steps
553+
assert len(steps) == 3
554+
assert steps[0].step_type == "inference"
555+
assert steps[1].step_type == "tool_execution"
556+
assert steps[1].tool_calls[0].tool_name == "get_boiling_point"
557+
assert steps[2].step_type == "inference"

0 commit comments

Comments
 (0)