Skip to content

Commit f3c7048

Browse files
committed
fix tests
1 parent c6e0f50 commit f3c7048

File tree

4 files changed

+21
-16
lines changed

4 files changed

+21
-16
lines changed

tests/test_agent_runner.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -226,9 +226,9 @@ async def test_structured_output():
226226

227227
assert result.final_output == Foo(bar="baz")
228228
assert len(result.raw_responses) == 4, "should have four model responses"
229-
assert len(result.to_input_list()) == 11, (
230-
"should have input: 2 orig inputs, function call, function call result, message, handoff, "
231-
"handoff output, preamble message, tool call, tool call result, final output"
229+
assert len(result.to_input_list()) == 10, (
230+
"should have input: conversation summary, function call, function call result, message, "
231+
"handoff, handoff output, preamble message, tool call, tool call result, final output"
232232
)
233233

234234
assert result.last_agent == agent_1, "should have handed off to agent_1"

tests/test_agent_runner_streamed.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -231,9 +231,9 @@ async def test_structured_output():
231231

232232
assert result.final_output == Foo(bar="baz")
233233
assert len(result.raw_responses) == 4, "should have four model responses"
234-
assert len(result.to_input_list()) == 11, (
235-
"should have input: 2 orig inputs, function call, function call result, message, handoff, "
236-
"handoff output, preamble message, tool call, tool call result, final output"
234+
assert len(result.to_input_list()) == 10, (
235+
"should have input: conversation summary, function call, function call result, message, "
236+
"handoff, handoff output, preamble message, tool call, tool call result, final output"
237237
)
238238

239239
assert result.last_agent == agent_1, "should have handed off to agent_1"
@@ -717,9 +717,9 @@ async def test_streaming_events():
717717

718718
assert result.final_output == Foo(bar="baz")
719719
assert len(result.raw_responses) == 4, "should have four model responses"
720-
assert len(result.to_input_list()) == 10, (
721-
"should have input: 2 orig inputs, function call, function call result, message, handoff, "
722-
"handoff output, tool call, tool call result, final output"
720+
assert len(result.to_input_list()) == 9, (
721+
"should have input: conversation summary, function call, function call result, message, "
722+
"handoff, handoff output, tool call, tool call result, final output"
723723
)
724724

725725
assert result.last_agent == agent_1, "should have handed off to agent_1"

tests/test_extension_filters.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,11 @@ def test_nest_handoff_history_honors_custom_wrappers() -> None:
350350
summary = _as_message(nested.input_history[0])
351351
summary_content = summary["content"]
352352
assert isinstance(summary_content, str)
353-
assert summary_content.startswith("<<START>>")
353+
lines = summary_content.splitlines()
354+
assert lines[0] == (
355+
"For context, here is the conversation so far between the user and the previous agent:"
356+
)
357+
assert lines[1].startswith("<<START>>")
354358
assert summary_content.endswith("<<END>>")
355359

356360
# Ensure the custom markers are parsed correctly when nesting again.

tests/test_run_step_processing.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
from __future__ import annotations
22

3-
from typing import Any
3+
from typing import Any, cast
44

55
import pytest
66
from openai.types.responses import (
77
ResponseComputerToolCall,
88
ResponseFileSearchToolCall,
9+
ResponseFunctionToolCall,
910
ResponseFunctionWebSearch,
1011
)
1112
from openai.types.responses.response_computer_tool_call import ActionClick
@@ -30,7 +31,7 @@
3031
handoff,
3132
)
3233
from agents._run_impl import RunImpl, ToolRunHandoff
33-
from agents.lifecycle import RunHooksBase
34+
from agents import RunHooks
3435
from agents.run import AgentRunner
3536

3637
from .test_responses import (
@@ -215,11 +216,11 @@ async def test_handoff_can_disable_run_level_history_nesting(monkeypatch: pytest
215216
source_agent = Agent(name="source")
216217
target_agent = Agent(name="target")
217218
override_handoff = handoff(target_agent, nest_handoff_history=False)
218-
tool_call = get_handoff_tool_call(target_agent)
219+
tool_call = cast(ResponseFunctionToolCall, get_handoff_tool_call(target_agent))
219220
run_handoffs = [ToolRunHandoff(handoff=override_handoff, tool_call=tool_call)]
220221
run_config = RunConfig(nest_handoff_history=True)
221222
context_wrapper = RunContextWrapper(context=None)
222-
hooks = RunHooksBase()
223+
hooks = RunHooks()
223224
original_input = [get_text_input_item("hello")]
224225
pre_step_items: list[RunItem] = []
225226
new_step_items: list[RunItem] = []
@@ -258,11 +259,11 @@ async def test_handoff_can_enable_history_nesting(monkeypatch: pytest.MonkeyPatc
258259
source_agent = Agent(name="source")
259260
target_agent = Agent(name="target")
260261
override_handoff = handoff(target_agent, nest_handoff_history=True)
261-
tool_call = get_handoff_tool_call(target_agent)
262+
tool_call = cast(ResponseFunctionToolCall, get_handoff_tool_call(target_agent))
262263
run_handoffs = [ToolRunHandoff(handoff=override_handoff, tool_call=tool_call)]
263264
run_config = RunConfig(nest_handoff_history=False)
264265
context_wrapper = RunContextWrapper(context=None)
265-
hooks = RunHooksBase()
266+
hooks = RunHooks()
266267
original_input = [get_text_input_item("hello")]
267268
pre_step_items: list[RunItem] = []
268269
new_step_items: list[RunItem] = []

0 commit comments

Comments
 (0)