File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -261,6 +261,12 @@ agent = RealtimeAgent(
261261)
262262```
263263
264+ When a realtime output guardrail trips, the session interrupts the active response, forces
265+ ` response.cancel ` , emits ` guardrail_tripped ` , and sends a follow-up user message that names the
266+ triggered guardrail so the model can produce a replacement response. Your audio player should still
267+ listen for ` audio_interrupted ` and stop local playback immediately, because guardrails run on
268+ debounced transcript text and some audio may already be buffered when the tripwire fires.
269+
264270## SIP and telephony
265271
266272The Python SDK includes a first-class SIP attach flow via [ ` OpenAIRealtimeSIPModel ` ] [ agents.realtime.openai_realtime.OpenAIRealtimeSIPModel ] .
Original file line number Diff line number Diff line change @@ -1764,8 +1764,14 @@ async def test_transcript_delta_triggers_guardrail_at_threshold(
17641764
17651765 # Should have triggered guardrail and interrupted
17661766 assert mock_model .interrupts_called == 1
1767+ interrupt_event = next (
1768+ event
1769+ for event in mock_model .sent_events
1770+ if isinstance (event , RealtimeModelSendInterrupt )
1771+ )
1772+ assert interrupt_event .force_response_cancel is True
17671773 assert len (mock_model .sent_messages ) == 1
1768- assert "triggered_guardrail" in mock_model .sent_messages [0 ]
1774+ assert mock_model .sent_messages [0 ] == "guardrail triggered: triggered_guardrail"
17691775
17701776 # Should have emitted guardrail_tripped event
17711777 events = []
You can’t perform that action at this time.
0 commit comments