Skip to content

FIX Harden prompt target cancellation cleanup - #2483

Open
Roman Lutz (romanlutz) wants to merge 5 commits into
microsoft:mainfrom
romanlutz:romanlutz-cancellation-hardening
Open

FIX Harden prompt target cancellation cleanup#2483
Roman Lutz (romanlutz) wants to merge 5 commits into
microsoft:mainfrom
romanlutz:romanlutz-cancellation-hardening

Conversation

@romanlutz

Copy link
Copy Markdown
Contributor

Description

Cancellation during provider setup or response handling can leave shared work cancelled or background resources running. This change makes target cleanup deterministic without changing the provider-attempt design.

  • Shield Hugging Face model loading so cancelling one send does not cancel the shared load task for other callers.
  • Remove and close partially configured OpenAI Realtime connections when setup is cancelled or fails.
  • Cancel and await unfinished Realtime receive tasks when text or audio sends fail, preventing orphaned listeners.

Tests and Documentation

  • Added unit coverage for cancellation during Realtime session configuration.
  • Added unit coverage for receive-task cleanup after response creation fails.
  • Added unit coverage confirming send cancellation preserves shared Hugging Face model loading.
  • Ran both focused target test modules: 120 passed.
  • Ran Ruff check and format checks, changed-file pre-commit hooks including ty, and git diff --check.
  • Documentation: N/A. This is an internal lifecycle cleanup fix with no public API change.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@hannahwestra25 hannahwestra25 self-assigned this Aug 25, 2026
Comment thread pyrit/prompt_target/openai/openai_realtime_target.py
Comment thread pyrit/prompt_target/openai/openai_realtime_target.py Outdated
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 0648637d-4c2e-4707-a85a-64a13e6cdfd9
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 0648637d-4c2e-4707-a85a-64a13e6cdfd9
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