#6327·opensre

[BUG] Bug: test_same_session_concurrent_appends_remain_line_parseable fails at limit 4

Author: suryaprkash778-dotCreated Sep 21, 2026Updated Sep 24, 2026
Labelsbug

Summary

Command Run

I ran this command on a 16-core Windows machine to test concurrency limits, Failed 1 out of 3 times.

powershell
$env:OPENSRE_MAX_CONCURRENT_TURNS=4
& "$HOME\.local\bin\\\uv.exe" run python -m pytest `
  gateway/tests/runtime/test_concurrency_gate.py `
  gateway/tests/runtime/test_session_agents.py `
  gateway/tests/runtime/test_turn_runner.py `
  gateway/tests/test_multi_actor_concurrency.py `
  tests/infrastructure/test_turn_capacity.py -q, 

### Expected vs actual behavior

 actual:-
____________________________________________ test_same_session_concurrent_appends_remain_line_parseable ============================================================== short test summary info ==============================================================
FAILED gateway/tests/test_multi_actor_concurrency.py::test_same_session_concurrent_appends_remain_line_parseable - AssertionError: assert 79 == 80
=========================================================== 1 failed, 63 passed in 18.84s ===========================================================
PS C:\Users\Surya Prakash\OneDrive\Desktop\my code\opensre> 

### Steps to reproduce

1. Set the concurrency limit environment variable to 4.
2. Run the specific pytest suite using `uv`. (Note: I ran this on a 16-core Windows machine via PowerShell).
3. Repeat the command multiple times, as the failure is an intermittent race condition.

**Exact command used:**
```powershell
$env:OPENSRE_MAX_CONCURRENT_TURNS=4
& "$HOME\.local\bin\\\uv.exe" run python -m pytest `
  gateway/tests/runtime/test_concurrency_gate.py `
  gateway/tests/runtime/test_session_agents.py `
  gateway/tests/runtime/test_turn_runner.py `
  gateway/tests/test_multi_actor_concurrency.py `
  tests/infrastructure/test_turn_capacity.py -q

### Can you reproduce it consistently?

Sometimes

### How often does it occur?

Intermittent

### Operating system

Windows

### Logs and error output

PS C:\Users\Surya Prakash\OneDrive\Desktop\my code\opensre> & "$HOME\.local\bin\\\uv.exe" --version
uv 0.12.17 (635500036 2026-09-18 x86_64-pc-windows-msvc)
PS C:\Users\Surya Prakash\OneDrive\Desktop\my code\opensre> $env:OPENSRE_MAX_CONCURRENT_TURNS=4
>> & "$HOME\.local\bin\\\uv.exe" run python -m pytest `
>>   gateway/tests/runtime/test_concurrency_gate.py `
>>   gateway/tests/runtime/test_session_agents.py `
>>   gateway/tests/runtime/test_turn_runner.py `
>>   gateway/tests/test_multi_actor_concurrency.py `
>>   tests/infrastructure/test_turn_capacity.py -q
Using CPython 3.14.0 interpreter at: C:\Users\Surya                                                           
Installed 152 packages in 2.39s
================================================================ test session starts ================================================================
platform win32 -- Python 3.14.0, pytest-9.0.3, pluggy-1.6.0
rootdir: C:\Users\Surya Prakash\OneDrive\Desktop\my code\opensre
configfile: pytest.ini
plugins: anyio-4.14.2, cov-7.1.0, timeout-2.4.0
timeout: 600.0s
timeout method: thread
timeout func_only: False
collected 64 items                                                                                                                                   

gateway\tests\runtime\test_concurrency_gate.py ..........                                                                                      [ 15%]
gateway\tests\runtime\test_session_agents.py ................                                                                                  [ 40%]
gateway\tests\runtime\test_turn_runner.py ...........................                                                                          [ 82%]
gateway\tests\test_multi_actor_concurrency.py .....F.                                                                                          [ 93%]
tests\infrastructure\test_turn_capacity.py ....                                                                                                [100%]

===================================================================== FAILURES ======================================================================
____________________________________________ test_same_session_concurrent_appends_remain_line_parseable _____________________________________________
gateway\tests\test_multi_actor_concurrency.py:363: in test_same_session_concurrent_appends_remain_line_parseable
    assert len(messages) == 80
E   AssertionError: assert 79 == 80
E    +  where 79 = len([{'content': 'a-0', 'id': '971f9772f5ad4803a861691190793491', 'metadata': {'kind': 'chat'}, 'parent_id': None, ...}, {...8d0649c45c0bfc37482d5875182', 'metadata': {'kind': 'chat'}, 'parent_id': 'f71191f304044b02bb2b9d467336dd86', ...}, ...])
=============================================================== slowest 20 durations ================================================================
3.55s setup    gateway/tests/runtime/test_concurrency_gate.py::test_profile_limits[SMALL-1]
1.89s call     gateway/tests/test_multi_actor_concurrency.py::test_fanout_three_transports_one_capacity_sentence_and_bindings_survive
0.71s call     gateway/tests/test_multi_actor_concurrency.py::test_multiprocess_alice_bob_bind_no_corrupt_json
0.60s call     gateway/tests/test_multi_actor_concurrency.py::test_concurrent_many_actors_all_bindings_survive
0.57s call     gateway/tests/runtime/test_turn_runner.py::test_turn_runner_same_session_turns_do_not_interleave
0.52s call     gateway/tests/runtime/test_session_agents.py::test_same_session_turns_do_not_interleave
0.42s call     gateway/tests/test_multi_actor_concurrency.py::test_concurrent_rotate_same_actor_leaves_valid_document
0.37s setup    tests/infrastructure/test_turn_capacity.py::test_a_dropped_turn_never_holds_a_slot
0.26s call     gateway/tests/runtime/test_session_agents.py::test_pool_refreshes_session_after_acquiring_external_lease
0.26s call     gateway/tests/runtime/test_turn_runner.py::test_waiting_on_session_lease_does_not_consume_global_capacity
0.21s call     gateway/tests/runtime/test_session_agents.py::test_pool_waits_for_a_session_lease_held_by_another_host
0.09s call     gateway/tests/test_multi_actor_concurrency.py::test_concurrent_alice_bob_bind_same_thread_keeps_both_rows
0.06s call     gateway/tests/runtime/test_turn_runner.py::test_turn_runner_cancel_under_overlap_releases_slot_and_preserves_survivor[cancel-alpha-survive-beta]
0.05s call     gateway/tests/runtime/test_concurrency_gate.py::test_scheduler_runner_waits_for_the_same_chat_capacity
0.04s call     gateway/tests/test_multi_actor_concurrency.py::test_same_session_concurrent_appends_remain_line_parseable
0.03s call     gateway/tests/runtime/test_turn_runner.py::test_run_cancelled_during_successful_admission_still_starts_turn
0.03s call     gateway/tests/test_multi_actor_concurrency.py::test_concurrent_alice_bob_session_appends_do_not_mix
0.03s call     gateway/tests/runtime/test_turn_runner.py::test_turn_runner_cancel_under_overlap_releases_slot_and_preserves_survivor[cancel-beta-survive-alpha]
0.02s call     gateway/tests/runtime/test_turn_runner.py::test_turn_runner_flushes_session_goal_for_next_resolve
0.02s setup    gateway/tests/test_multi_actor_concurrency.py::test_multiprocess_alice_bob_bind_no_corrupt_json
============================================================== short test summary info ==============================================================
FAILED gateway/tests/test_multi_actor_concurrency.py::test_same_session_concurrent_appends_remain_line_parseable - AssertionError: assert 79 == 80
=========================================================== 1 failed, 63 passed in 18.84s ===========================================================
PS C:\Users\Surya Prakash\OneDrive\Desktop\my code\opensre> 

### Additional context

Found while working on #5492 (Run the concurrency suites with the turn limit raised).