Skip to content

FIX: Fix multi-turn attacks using RealtimeTarget#1638

Merged
jsong468 merged 2 commits into
microsoft:mainfrom
jsong468:realtime_multiturn_fix
Apr 22, 2026
Merged

FIX: Fix multi-turn attacks using RealtimeTarget#1638
jsong468 merged 2 commits into
microsoft:mainfrom
jsong468:realtime_multiturn_fix

Conversation

@jsong468
Copy link
Copy Markdown
Contributor

@jsong468 jsong468 commented Apr 22, 2026

Description

This PR addresses the bug where executing multi-turn attacks against RealtimeTarget would not work properly because previous turn context was getting lost. The bug was caused by forced connection closes and reconnections to the OpenAI/AzureOpenAI server in send_text_async and send_audio_async, which caused all server-side conversation context to be lost.

  • Removes the reconnection blocks from send_text_async and send_audio_async, and the WebSocket connection now persists across turns, preserving server-side conversation state
  • Added guard on response.done event: skips the event if it's the very first event received (using current_turn_event_count tracking variable) and contains no audio. This occurs when an unconsumed response.done event is left in the WebSocket buffer from a prior turn's soft-finish when an audio.done event was received but no response.done after 1 second grace period. The method breaks normally if preceded by other events or if audio data is present
  • Changed event type checks from if to elif since event types are mutually exclusive

Tests and Documentation

Added tests for multi-turn attacks with RealtimeTarget and re-ran notebook.

@jsong468 jsong468 marked this pull request as ready for review April 22, 2026 19:42
Comment thread tests/unit/prompt_target/target/test_realtime_target.py
@romanlutz
Copy link
Copy Markdown
Contributor

Did you check the GUI? Does it work there? It should, just asking.

@jsong468 jsong468 merged commit 66afba2 into microsoft:main Apr 22, 2026
39 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants