File tree Expand file tree Collapse file tree 3 files changed +36
-4
lines changed Expand file tree Collapse file tree 3 files changed +36
-4
lines changed Original file line number Diff line number Diff line change 49
49
DEFAULT_RUNNER : Runner | None = None
50
50
51
51
52
- def set_default_runner (runner : Runner ) -> None :
52
+ def set_default_runner (runner : Runner | None ) -> None :
53
53
"""
54
54
Set the default runner to use for the agent run.
55
55
"""
@@ -146,7 +146,7 @@ def run_sync_impl(
146
146
pass
147
147
148
148
@abc .abstractmethod
149
- def run_streaming_impl (
149
+ def run_streamed_impl (
150
150
self ,
151
151
starting_agent : Agent [TContext ],
152
152
input : str | list [TResponseInputItem ],
@@ -297,7 +297,7 @@ def run_streamed(
297
297
A result object that contains data about the run, as well as a method to stream events.
298
298
"""
299
299
runner = DEFAULT_RUNNER or DefaultRunner ()
300
- return runner .run_streaming_impl (
300
+ return runner .run_streamed_impl (
301
301
starting_agent ,
302
302
input ,
303
303
context = context ,
@@ -511,7 +511,7 @@ def run_sync_impl(
511
511
)
512
512
)
513
513
514
- def run_streaming_impl (
514
+ def run_streamed_impl (
515
515
self ,
516
516
starting_agent : Agent [TContext ],
517
517
input : str | list [TResponseInputItem ],
Original file line number Diff line number Diff line change 5
5
from agents .models import _openai_shared
6
6
from agents .models .openai_chatcompletions import OpenAIChatCompletionsModel
7
7
from agents .models .openai_responses import OpenAIResponsesModel
8
+ from agents .run import set_default_runner
8
9
from agents .tracing import set_trace_processors
9
10
from agents .tracing .setup import GLOBAL_TRACE_PROVIDER
10
11
@@ -33,6 +34,11 @@ def clear_openai_settings():
33
34
_openai_shared ._use_responses_by_default = True
34
35
35
36
37
+ @pytest .fixture (autouse = True )
38
+ def clear_default_runner ():
39
+ set_default_runner (None )
40
+
41
+
36
42
# This fixture will run after all tests end
37
43
@pytest .fixture (autouse = True , scope = "session" )
38
44
def shutdown_trace_provider ():
Original file line number Diff line number Diff line change
1
+ from __future__ import annotations
2
+
3
+ from unittest import mock
4
+
5
+ import pytest
6
+
7
+ from agents import Agent , Runner
8
+ from agents .run import set_default_runner
9
+
10
+ from .fake_model import FakeModel
11
+
12
+
13
+ @pytest .mark .asyncio
14
+ async def test_static_run_methods_call_into_default_runner () -> None :
15
+ runner = mock .Mock (spec = Runner )
16
+ set_default_runner (runner )
17
+
18
+ agent = Agent (name = "test" , model = FakeModel ())
19
+ await Runner .run (agent , input = "test" )
20
+ runner .run_impl .assert_called_once ()
21
+
22
+ Runner .run_streamed (agent , input = "test" )
23
+ runner .run_streamed_impl .assert_called_once ()
24
+
25
+ Runner .run_sync (agent , input = "test" )
26
+ runner .run_sync_impl .assert_called_once ()
You can’t perform that action at this time.
0 commit comments