MCPcopy Index your code
hub / github.com/openai/openai-agents-python / run_interactive_loop

Function run_interactive_loop

examples/sandbox/tutorials/misc.py:240–262  ·  view source on GitHub ↗
(
    *,
    conversation: list[TResponseInputItem],
    no_interactive: bool,
    run_turn: InteractiveTurnRunner,
)

Source from the content-addressed store, hash-verified

238
239
240async def run_interactive_loop(
241 *,
242 conversation: list[TResponseInputItem],
243 no_interactive: bool,
244 run_turn: InteractiveTurnRunner,
245) -> list[TResponseInputItem]:
246 if no_interactive or is_auto_mode():
247 return conversation
248
249 console.print("[dim]Enter follow-up prompts. Press Ctrl-D or Ctrl-C to finish.[/dim]")
250 while True:
251 try:
252 next_message = Prompt.ask("[bold cyan]user[/bold cyan]").strip()
253 except (EOFError, KeyboardInterrupt):
254 break
255
256 if not next_message:
257 continue
258
259 conversation.append({"role": "user", "content": next_message})
260 conversation = await run_turn(conversation)
261
262 return conversation
263
264
265def print_event(event: PrintableEvent) -> None:

Callers 2

mainFunction · 0.90
mainFunction · 0.90

Calls 3

is_auto_modeFunction · 0.90
appendMethod · 0.80
run_turnFunction · 0.50

Tested by

no test coverage detected