RealtimeRunner
ARealtimeRunner is the equivalent ofRunner for realtime agents. It automaticallyhandles multiple turns by maintaining a persistent connection with the underlying modellayer.
The session manages the local history copy, executes tools, runs guardrails and facilitateshandoffs between agents.
Since this code runs on your server, it uses WebSockets by default. You can optionally createyour own custom model layer by implementing theRealtimeModel interface.
Source code insrc/agents/realtime/runner.py
__init__
__init__(starting_agent:RealtimeAgent,*,model:RealtimeModel|None=None,config:RealtimeRunConfig|None=None,)->NoneInitialize the realtime runner.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
starting_agent | RealtimeAgent | The agent to start the session with. | required |
context | The context to use for the session. | required | |
model | RealtimeModel | None | The model to use. If not provided, will use a default OpenAI realtime model. | None |
config | RealtimeRunConfig | None | Override parameters to use for the entire run. | None |
Source code insrc/agents/realtime/runner.py
runasync
run(*,context:TContext|None=None,model_config:RealtimeModelConfig|None=None,)->RealtimeSessionStart and returns a realtime session.
Returns:
| Name | Type | Description |
|---|---|---|
RealtimeSession | RealtimeSession | A session object that allows bidirectional communication with the |
RealtimeSession | realtime model. |