You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Concurrent SDK run_async calls duplicate one persisted run and exceed its concurrency limit #3748
Two concurrent run_async calls on the same initialized scenario create independent executors/semaphores over one persisted run, duplicate work and exceed the configured concurrency cap.
Steps/Code to Reproduce
Initialize one scenario with six objectives and max_concurrency=2, then await two concurrent calls to run_async on that same instance with a counting deterministic target.
Additional reproduction details
Prepare one offline scenario with six objectives and max_concurrency=2, backed by a deterministic target that blocks until both calls enter; invoke await asyncio.gather(scenario.run_async(), scenario.run_async()) on the same initialized instance. Captured values: peak target concurrency 4, target calls 12, persisted attack results 12, number_tries=1, both calls returned ScenarioResult under the same run ID. No live model or external target is needed.
Expected Results
Reject or serialize a second execution before target work; planned units should execute once, concurrency remain at most two, and attempt accounting be atomic.
Actual Results
Both calls return ScenarioResult under the same persisted ID. Six objectives run twice, 12 attack results persist, peak target concurrency is four despite limit two, and number_tries remains 1 due to overlapping read/increment/write. API detail folds duplicates into six completed units and six retry attempts.
Proposed fix/regression: add same-run ownership/reentrancy guard released after worker cleanup; make attempt increments atomic; test concurrency, cancellation cleanup, and legitimate later resume with real SQLite.
Screenshots
Not applicable; counts/concurrency are inline.
Versions
Tested commit d3446e0, PyRIT 1.2.0.dev0, offline SDK/SQLite/deterministic-target scope. Evidence: files/evidence/round9/sdk-concurrent-same-run.json; local path is not an attachment.
I have reproduced and tested this behavior locally against an offline SQLite fixture, confirming the concurrency cap bypass and duplicated persisted runs. I'd like to take this on by adding a scenario-level re-entrancy guard, making attempt accounting atomic, and adding regression tests.
Activity
Kaap10 commentedon Nov 1, 2026
I have reproduced and tested this behavior locally against an offline SQLite fixture, confirming the concurrency cap bypass and duplicated persisted runs. I'd like to take this on by adding a scenario-level re-entrancy guard, making attempt accounting atomic, and adding regression tests.
TEST: Add event rendezvous and watchdog to parallel scenario test (mi…
FIX: Make scenario number_tries atomic and guard subclass pre-work (m…
TEST: Remove obsolete mock tests for AdversarialBenchmark.run_async (m…
FIX: Reject concurrent SDK scenario runs and make attempt accounting …