Skip to content

~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.

test(chat): de-flake per-user cap test (remove 30s wall-clock dependency) (#4549)

LearningCircuita986c8c93020
diff --git a/tests/chat/test_chat_send_message_followups.py b/tests/chat/test_chat_send_message_followups.py
index b61e827fef..6ac9b32d22 100644
--- a/tests/chat/test_chat_send_message_followups.py
+++ b/tests/chat/test_chat_send_message_followups.py
@@ -189,6 +189,21 @@ class TestGlobalPerUserCap:
# No-op the spawn so the first research stays "in progress"
# (its UserActiveResearch row is never cleaned up by completion).
patch("local_deep_research.chat.routes.start_research_process"),
+ # Treat the first research's (stubbed-spawn) thread as alive.
+ # The second send's cap path runs reclaim_stale_user_active_research,
+ # which flips IN_PROGRESS rows whose thread is dead — gated only by a
+ # 30s grace window on started_at. Because the spawn is stubbed, the
+ # first row has no real thread, so the row is protected ONLY by that
+ # wall-clock window. Under heavy CI load a >30s stall between these two
+ # sequential posts pushes the row past the window and it gets reclaimed,
+ # dropping the count to 0 → the second send wrongly succeeds (flaky 200
+ # instead of 429). Forcing thread-alive removes the timing dependency:
+ # reclaim short-circuits before the grace check, so this test now
+ # verifies the cap-counts-the-row invariant deterministically.
+ patch(
+ "local_deep_research.web.routes.globals.is_research_thread_alive",
+ return_value=True,
+ ),
):
first = authenticated_client.post(
f"/api/chat/sessions/{session_a}/messages",