diff --git a/examples/basic/tools.py b/examples/basic/tools.py index 1c4496603..2052d9427 100644 --- a/examples/basic/tools.py +++ b/examples/basic/tools.py @@ -18,6 +18,7 @@ def get_weather(city: Annotated[str, "The city to get the weather for"]) -> Weat print("[debug] get_weather called") return Weather(city=city, temperature_range="14-20C", conditions="Sunny with wind.") + agent = Agent( name="Hello world", instructions="You are a helpful agent.", diff --git a/src/agents/realtime/config.py b/src/agents/realtime/config.py index ddbf48bab..99b09efed 100644 --- a/src/agents/realtime/config.py +++ b/src/agents/realtime/config.py @@ -169,6 +169,29 @@ class RealtimeModelTracingConfig(TypedDict): """Additional metadata to include with the trace.""" +class RealtimeAudioStorageConfig(TypedDict): + """Configuration for audio storage in realtime sessions.""" + + enabled: NotRequired[bool] + """Whether audio storage is enabled. Defaults to False.""" + + storage_path: NotRequired[str] + """The path where audio files should be stored. If not provided, uses a + default temp directory.""" + + max_duration_seconds: NotRequired[int] + """Maximum duration in seconds for stored audio clips. Defaults to 300 (5 minutes).""" + + audio_format: NotRequired[RealtimeAudioFormat] + """The format to store audio in. Defaults to 'pcm16'.""" + + compression_enabled: NotRequired[bool] + """Whether to compress stored audio files. Defaults to True.""" + + retention_days: NotRequired[int] + """Number of days to retain stored audio files. Defaults to 7.""" + + class RealtimeRunConfig(TypedDict): """Configuration for running a realtime agent session.""" @@ -184,7 +207,8 @@ class RealtimeRunConfig(TypedDict): tracing_disabled: NotRequired[bool] """Whether tracing is disabled for this run.""" - # TODO (rm) Add history audio storage config + audio_storage_config: NotRequired[RealtimeAudioStorageConfig] + """Configuration for audio storage in realtime sessions.""" class RealtimeUserInputText(TypedDict): diff --git a/src/agents/realtime/session.py b/src/agents/realtime/session.py index 62adc529c..e558319e3 100644 --- a/src/agents/realtime/session.py +++ b/src/agents/realtime/session.py @@ -512,7 +512,7 @@ def _get_new_history( ) return new_history - # TODO (rm) Add support for audio storage config + # Audio storage config is now available in RealtimeRunConfig.audio_storage_config # If the item already exists, update it existing_index = next(