Latest in AI
How to test Realtime output guardrails in OpenAI Agents SDK 0.26
OpenAI Agents SDK 0.26.0 checks pending Realtime output at turn end. Test short replies, unchecked tails, and buffered audio in your own app.
A short voice reply like “Sure” still needs to go through your app's output checks. OpenAI Agents SDK 0.26.0, released November 24, adds a turn-end check for Realtime output that hasn't been sent to the guardrail yet. The change covers model output text and the transcript of spoken output.
If you maintain a streaming app, test the short reply as well as the longer one. Then check what your player does when the verdict arrives after the model has stopped generating.
What gets checked at turn end
Realtime output checks are debounced: the SDK gathers text or transcript deltas and checks the accumulated text at thresholds rather than invoking the guardrail on every chunk. The tagged configuration defines guardrails_settings.debounce_text_length, which defaults to 100 characters.
The 0.26.0 change schedules a final check when a response ends with pending output. A short reply is checked at turn end. If the SDK already scheduled a check during the turn and more text arrived afterward, the final check receives the full accumulated item, including the tail. If there was no new text after the last scheduled check, the SDK doesn't schedule another one for the same text.
Build three checks into your test suite
Use a fake model transport and a guardrail that records the strings it receives and returns a passing result. Give the test a small debounce threshold so the fixtures stay readable. You don't need a live model, credentials or real conversation text to check the event sequence.
- Short reply: Send a single output delta below the threshold, then end the response. Expect one guardrail call with the complete reply after turn end.
- Response at the threshold: Send output that reaches the threshold and wait for its scheduled check. End the response and confirm that the callback doesn't receive the same text again.
- More text after a check: Reach the threshold and then append a short chunk. End the response and confirm the second call contains the earlier text and the new chunk together.
Run the cases once with output-text deltas and once with audio-transcript deltas. Wait for the asynchronous check to finish before making assertions. The SDK's regression tests also verify that a repeated turn-end event doesn't schedule duplicate work.
Test your player separately
A callback test tells you the guardrail ran. It doesn't tell you whether the app stopped audio already sitting in its playback queue. In a separate fixture, use a harmless marker that trips your test guardrail and verify that the app handles guardrail_tripped and stops the affected buffered playback on audio_interrupted.
The Realtime guide explains that the built-in transport can interrupt an earlier response's buffered audio after that response ends without cancelling a newer response. If you use a custom transport, test that response scoping instead of assuming it inherits the built-in behavior. Text-only responses don't emit a playback interruption.
A turn-end check can't take back words a user already heard. If your application must approve output before any of it is visible or audible, test a separate hold-before-release path and account for the added latency.
Need help documenting a developer release?
I'm Paras Madan. I help AI teams write technical guides that explain what changed and give developers a concrete way to test it. Book a 30-minute call.