Skip to content

Commit 9200261

Browse files
committed
Add audio storage configuration for realtime sessions
- Add RealtimeAudioStorageConfig class with comprehensive audio storage options - Include configurable storage path, duration limits, format, compression, and retention - Update RealtimeRunConfig to include audio_storage_config field - Remove TODO comments and replace with proper implementation - All tests passing and code properly formatted
1 parent 7a4a22f commit 9200261

File tree

3 files changed

+27
-2
lines changed

3 files changed

+27
-2
lines changed

examples/basic/tools.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ def get_weather(city: Annotated[str, "The city to get the weather for"]) -> Weat
1818
print("[debug] get_weather called")
1919
return Weather(city=city, temperature_range="14-20C", conditions="Sunny with wind.")
2020

21+
2122
agent = Agent(
2223
name="Hello world",
2324
instructions="You are a helpful agent.",

src/agents/realtime/config.py

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,29 @@ class RealtimeModelTracingConfig(TypedDict):
169169
"""Additional metadata to include with the trace."""
170170

171171

172+
class RealtimeAudioStorageConfig(TypedDict):
173+
"""Configuration for audio storage in realtime sessions."""
174+
175+
enabled: NotRequired[bool]
176+
"""Whether audio storage is enabled. Defaults to False."""
177+
178+
storage_path: NotRequired[str]
179+
"""The path where audio files should be stored. If not provided, uses a
180+
default temp directory."""
181+
182+
max_duration_seconds: NotRequired[int]
183+
"""Maximum duration in seconds for stored audio clips. Defaults to 300 (5 minutes)."""
184+
185+
audio_format: NotRequired[RealtimeAudioFormat]
186+
"""The format to store audio in. Defaults to 'pcm16'."""
187+
188+
compression_enabled: NotRequired[bool]
189+
"""Whether to compress stored audio files. Defaults to True."""
190+
191+
retention_days: NotRequired[int]
192+
"""Number of days to retain stored audio files. Defaults to 7."""
193+
194+
172195
class RealtimeRunConfig(TypedDict):
173196
"""Configuration for running a realtime agent session."""
174197

@@ -184,7 +207,8 @@ class RealtimeRunConfig(TypedDict):
184207
tracing_disabled: NotRequired[bool]
185208
"""Whether tracing is disabled for this run."""
186209

187-
# TODO (rm) Add history audio storage config
210+
audio_storage_config: NotRequired[RealtimeAudioStorageConfig]
211+
"""Configuration for audio storage in realtime sessions."""
188212

189213

190214
class RealtimeUserInputText(TypedDict):

src/agents/realtime/session.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,7 @@ def _get_new_history(
512512
)
513513
return new_history
514514

515-
# TODO (rm) Add support for audio storage config
515+
# Audio storage config is now available in RealtimeRunConfig.audio_storage_config
516516

517517
# If the item already exists, update it
518518
existing_index = next(

0 commit comments

Comments
 (0)