From 9f097e17e81a3421c3b78e182449d500ef8de7a5 Mon Sep 17 00:00:00 2001 From: Joao Moura Date: Tue, 11 Aug 2026 17:05:12 -0700 Subject: [PATCH] test(flow): make the checkpoint-restore guard actually guard The test asserted that flow:resumed was absent from feature usage, but that signal moved onto the Flow Execution span. The assertion could no longer fail, so a regression that mis-tagged checkpoint restores as resumes would have gone unnoticed. Now asserts the resumed attribute, and waits for the handlers: the manual emit dispatches asynchronously, so the previous shape also read its result before the listener had run. Confirmed it discriminates - keying resumed off _is_execution_resuming again fails it with [('RestoredFlow', True)] == [('RestoredFlow', False)]. Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_01ASfWmW3RGy4qAQm6s8U9jH --- lib/crewai/tests/telemetry/test_flow_telemetry.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/crewai/tests/telemetry/test_flow_telemetry.py b/lib/crewai/tests/telemetry/test_flow_telemetry.py index 2e71f73722..df32834bf6 100644 --- a/lib/crewai/tests/telemetry/test_flow_telemetry.py +++ b/lib/crewai/tests/telemetry/test_flow_telemetry.py @@ -22,6 +22,8 @@ from crewai.flow.flow import Flow, listen, start from crewai.flow.human_feedback import human_feedback from crewai.flow.input_provider import InputResponse +from ..utils import wait_for_event_handlers + def _reregister_listener() -> None: """Re-subscribe the global listener to the event bus. @@ -589,9 +591,9 @@ def test_infrastructure_flows_do_not_pollute_outcome_signals( def test_a_checkpoint_restore_is_not_counted_as_a_resume( - features: list[str], + starts: list[tuple[str, bool]], ) -> None: - """Only a run restored from a human pause counts as resumed. + """Only a run restored from a human pause is marked resumed. ``_is_execution_resuming`` is also set by checkpoint restores that never paused for anyone. Counting those would push resumes above pauses and make @@ -610,5 +612,6 @@ def test_a_checkpoint_restore_is_not_counted_as_a_resume( assert flow._pending_feedback_context is None crewai_event_bus.emit(flow, FlowStartedEvent(flow_name="RestoredFlow")) + wait_for_event_handlers() - assert "flow:resumed" not in features + assert starts == [("RestoredFlow", False)]