Skip to content

The agent engineering platform.

test(core): increase `delta_time` for flaky test (#34982)

Mason Daughertyae5b50f37f4c
diff --git a/libs/core/tests/unit_tests/tracers/test_memory_stream.py b/libs/core/tests/unit_tests/tracers/test_memory_stream.py
index da96e6d7bb..ba9daa913c 100644
--- a/libs/core/tests/unit_tests/tracers/test_memory_stream.py
+++ b/libs/core/tests/unit_tests/tracers/test_memory_stream.py
@@ -102,15 +102,12 @@ async def test_queue_for_streaming_via_sync_call() -> None:
for item in items:
delta_time = item["receive_time"] - item["produce_time"]
- # Allow a generous 10ms of delay
- # The test is meant to verify that the producer and consumer are running in
- # parallel despite the fact that the producer is running from another thread.
- # abs_tol is used to allow for some delay in the producer and consumer
- # due to overhead.
- # To verify that the producer and consumer are running in parallel, we
- # expect the delta_time to be smaller than the sleep delay in the producer
- # * # of items = 30 ms
- assert math.isclose(delta_time, 0, abs_tol=0.020) is True, (
+ # The test verifies that the producer and consumer are running in parallel
+ # despite the producer running from another thread via asyncio.to_thread.
+ # Cross-thread communication has overhead that varies with system load,
+ # so we use a tolerance of 150ms. This still proves parallelism because
+ # serial execution would show deltas of 200ms+ (the sleep interval).
+ assert math.isclose(delta_time, 0, abs_tol=0.15) is True, (
f"delta_time: {delta_time}"
)