Skip to content

Commit 2002dd9

Browse files
committed
LLM: rename Runner execution methods to use leading underscores
This commit renames the abstract and concrete methods run_impl, run_sync_impl, and run_streamed_impl in the Runner and DefaultRunner classes to _run_impl, _run_sync_impl, and _run_streamed_impl (or _start_streaming as appropriate) for improved naming consistency. Updates all method calls and test mocks accordingly. No behavior changes.
1 parent a10f945 commit 2002dd9

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

src/agents/run.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ class RunConfig:
118118

119119
class Runner(abc.ABC):
120120
@abc.abstractmethod
121-
async def run_impl(
121+
async def _run_impl(
122122
self,
123123
starting_agent: Agent[TContext],
124124
input: str | list[TResponseInputItem],
@@ -132,7 +132,7 @@ async def run_impl(
132132
pass
133133

134134
@abc.abstractmethod
135-
def run_sync_impl(
135+
def _run_sync_impl(
136136
self,
137137
starting_agent: Agent[TContext],
138138
input: str | list[TResponseInputItem],
@@ -146,7 +146,7 @@ def run_sync_impl(
146146
pass
147147

148148
@abc.abstractmethod
149-
def run_streamed_impl(
149+
def _run_streamed_impl(
150150
self,
151151
starting_agent: Agent[TContext],
152152
input: str | list[TResponseInputItem],
@@ -197,7 +197,7 @@ async def run(
197197
agent. Agents may perform handoffs, so we don't know the specific type of the output.
198198
"""
199199
runner = DEFAULT_RUNNER or DefaultRunner()
200-
return await runner.run_impl(
200+
return await runner._run_impl(
201201
starting_agent,
202202
input,
203203
context=context,
@@ -249,7 +249,7 @@ def run_sync(
249249
agent. Agents may perform handoffs, so we don't know the specific type of the output.
250250
"""
251251
runner = DEFAULT_RUNNER or DefaultRunner()
252-
return runner.run_sync_impl(
252+
return runner._run_sync_impl(
253253
starting_agent,
254254
input,
255255
context=context,
@@ -297,7 +297,7 @@ def run_streamed(
297297
A result object that contains data about the run, as well as a method to stream events.
298298
"""
299299
runner = DEFAULT_RUNNER or DefaultRunner()
300-
return runner.run_streamed_impl(
300+
return runner._run_streamed_impl(
301301
starting_agent,
302302
input,
303303
context=context,
@@ -339,7 +339,7 @@ def _get_model(cls, agent: Agent[Any], run_config: RunConfig) -> Model:
339339

340340

341341
class DefaultRunner(Runner):
342-
async def run_impl(
342+
async def _run_impl(
343343
self,
344344
starting_agent: Agent[TContext],
345345
input: str | list[TResponseInputItem],
@@ -488,7 +488,7 @@ async def run_impl(
488488
if current_span:
489489
current_span.finish(reset_current=True)
490490

491-
def run_sync_impl(
491+
def _run_sync_impl(
492492
self,
493493
starting_agent: Agent[TContext],
494494
input: str | list[TResponseInputItem],
@@ -511,7 +511,7 @@ def run_sync_impl(
511511
)
512512
)
513513

514-
def run_streamed_impl(
514+
def _run_streamed_impl(
515515
self,
516516
starting_agent: Agent[TContext],
517517
input: str | list[TResponseInputItem],
@@ -564,7 +564,7 @@ def run_streamed_impl(
564564

565565
# Kick off the actual agent loop in the background and return the streamed result object.
566566
streamed_result._run_impl_task = asyncio.create_task(
567-
self._run_streamed_impl(
567+
self._start_streaming(
568568
starting_input=input,
569569
streamed_result=streamed_result,
570570
starting_agent=starting_agent,
@@ -621,7 +621,7 @@ async def _run_input_guardrails_with_queue(
621621
streamed_result.input_guardrail_results = guardrail_results
622622

623623
@classmethod
624-
async def _run_streamed_impl(
624+
async def _start_streaming(
625625
cls,
626626
starting_input: str | list[TResponseInputItem],
627627
streamed_result: RunResultStreaming,

tests/test_run.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ async def test_static_run_methods_call_into_default_runner() -> None:
1717

1818
agent = Agent(name="test", model=FakeModel())
1919
await Runner.run(agent, input="test")
20-
runner.run_impl.assert_called_once()
20+
runner._run_impl.assert_called_once()
2121

2222
Runner.run_streamed(agent, input="test")
23-
runner.run_streamed_impl.assert_called_once()
23+
runner._run_streamed_impl.assert_called_once()
2424

2525
Runner.run_sync(agent, input="test")
26-
runner.run_sync_impl.assert_called_once()
26+
runner._run_sync_impl.assert_called_once()

0 commit comments

Comments
 (0)