Skip to content

Commit 0fe39ff

Browse files
committed
Update test_agent_e2e.py
1 parent 533b97d commit 0fe39ff

File tree

1 file changed

+17
-20
lines changed

1 file changed

+17
-20
lines changed

tests/test_agent_e2e.py

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -245,42 +245,39 @@ def create_mock_openai_client_for_sgr_tool_calling_agent(action_tool_1: Type, ac
245245
action_count = {"count": 0}
246246

247247
def mock_stream(**kwargs):
248-
"""Mock stream function that determines reasoning vs action phase.
249-
250-
Checks the first tool name in the tools list to determine the
251-
phase.
252-
"""
248+
"""Mock stream function that returns appropriate tool based on tool
249+
name."""
253250
tools_param = kwargs.get("tools", [])
254251

255-
# Check first tool name - if it's ReasoningTool, it's reasoning phase
252+
# Validate that tools is a list
253+
if not isinstance(tools_param, list):
254+
raise TypeError(
255+
f"SGRToolCallingAgent._prepare_tools() must return a list, "
256+
f"but got {type(tools_param).__name__}. "
257+
f"Override _prepare_tools() to return list instead of NextStepToolStub."
258+
)
259+
260+
# Get tool name from first tool in the list
256261
tool_name = None
257-
if isinstance(tools_param, list) and tools_param:
262+
if tools_param:
258263
first_tool = tools_param[0]
259264
if isinstance(first_tool, dict):
260265
tool_name = first_tool.get("function", {}).get("name")
261266

262-
is_reasoning = tool_name == ReasoningTool.tool_name
263-
264-
if is_reasoning:
267+
# Return appropriate tool based on name
268+
if tool_name == ReasoningTool.tool_name:
265269
reasoning_count["count"] += 1
266270
tool = reasoning_tools[reasoning_count["count"] - 1]
267-
call_id = f"{reasoning_count['count']}-reasoning"
268271
else:
269-
# Validate that tools is a list (for action phase)
270-
if not isinstance(tools_param, list):
271-
raise TypeError(
272-
f"SGRToolCallingAgent._prepare_tools() must return a list, "
273-
f"but got {type(tools_param).__name__}. "
274-
f"Override _prepare_tools() to return list instead of NextStepToolStub."
275-
)
272+
# Action tool - use counter to select from action_tools list
276273
action_count["count"] += 1
277274
tool = action_tools[action_count["count"] - 1]
278-
call_id = f"{action_count['count']}-action"
279275

276+
# call_id is not used by agent, just needed for valid OpenAI API structure
280277
return MockStream(
281278
final_completion_data={
282279
"content": None,
283-
"tool_calls": [_create_tool_call(tool, call_id)],
280+
"tool_calls": [_create_tool_call(tool, "mock-call-id")],
284281
}
285282
)
286283

0 commit comments

Comments
 (0)