Skip to content

fix(realtime): scope delayed audio guardrail interruption - #4135

Merged
seratch merged 3 commits into
mainfrom
fix/realtime-audio-guardrail-interruption
Aug 4, 2026
Merged

fix(realtime): scope delayed audio guardrail interruption#4135
seratch merged 3 commits into
mainfrom
fix/realtime-audio-guardrail-interruption

Conversation

@seratch

@seratch seratch commented Aug 3, 2026

Copy link
Copy Markdown
Member

This pull request fixes delayed Realtime audio output guardrails so they interrupt only the buffered playback produced by their source response, without cancelling or clearing a newer response.

#3933 originally combined three distinct Realtime changes:

  1. Apply output guardrails to text deltas.
  2. Synchronize after-turn streaming cancellation with event consumption.
  3. Make delayed audio guardrail interruption response-scoped and bound the associated audio tracking lifecycle.

That pull request was closed so the work could be reviewed and landed as three focused changes. #4124 delivered text-output guardrails, and #4130 delivered after-turn streaming cancellation. This pull request completes the third and final part.

The implementation:

  • associates received audio and pending guardrail tasks with their source response;
  • uses response-scoped, playback-only interruption when an audio guardrail finishes after its source response has ended;
  • preserves newer response playback across asynchronous interruption listeners;
  • suppresses late audio deltas from an interrupted source response;
  • retains response audio indexes until guardrail work and local playback have settled;
  • releases timers, listeners, tombstones, and response indexes during terminal cleanup;
  • preserves existing custom RealtimeModel construction and positional dataclass behavior; and
  • documents that custom transports must honor response_id and playback_only to provide the same source-scoped behavior.

@seratch seratch added this to the 0.19.x milestone Aug 3, 2026
@seratch
seratch force-pushed the fix/realtime-audio-guardrail-interruption branch from da670a8 to b16e230 Compare August 3, 2026 02:36

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: da670a82ee

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/agents/realtime/openai_realtime.py Outdated
Comment thread src/agents/realtime/session.py
@seratch
seratch force-pushed the fix/realtime-audio-guardrail-interruption branch from b16e230 to a5dfe8c Compare August 4, 2026 03:04

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a5dfe8c8da

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/agents/realtime/openai_realtime.py Outdated
Comment thread src/agents/realtime/openai_realtime.py Outdated
@seratch
seratch merged commit 27c136c into main Aug 4, 2026
9 checks passed
@seratch
seratch deleted the fix/realtime-audio-guardrail-interruption branch August 4, 2026 04:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant