Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/agents/repl.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from openai.types.responses.response_text_delta_event import ResponseTextDeltaEvent

from . import Session
from .agent import Agent
from .items import TResponseInputItem
from .result import RunResultBase
Expand All @@ -13,7 +14,7 @@


async def run_demo_loop(
agent: Agent[Any], *, stream: bool = True, context: TContext | None = None
agent: Agent[Any], *, stream: bool = True, context: TContext | None = None, session: Session | None = None
) -> None:
"""Run a simple REPL loop with the given agent.

Expand All @@ -25,6 +26,7 @@ async def run_demo_loop(
agent: The starting agent to run.
stream: Whether to stream the agent output.
context: Additional context information to pass to the runner.
session: The Session to manage conversation history.
"""

current_agent = agent
Expand All @@ -44,7 +46,7 @@ async def run_demo_loop(

result: RunResultBase
if stream:
result = Runner.run_streamed(current_agent, input=input_items, context=context)
result = Runner.run_streamed(current_agent, input=input_items, context=context, session=session)
async for event in result.stream_events():
if isinstance(event, RawResponsesStreamEvent):
if isinstance(event.data, ResponseTextDeltaEvent):
Expand Down
1 change: 1 addition & 0 deletions src/agents/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,7 @@ def run_streamed(
previous_response_id: The ID of the previous response, if using OpenAI models via the
Responses API, this allows you to skip passing in input from the previous turn.
conversation_id: The ID of the stored conversation, if any.
session: The Session to manage conversation history.
Returns:
A result object that contains data about the run, as well as a method to stream events.
"""
Expand Down