mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-07-01 05:08:12 +00:00
A flow restored via Flow.from_pending() is a fresh instance whose _flow_match_id starts at None. When resume_async then attaches the LLMCallCompletedEvent listener, the handler filter (current_flow_id.get() != flow._flow_match_id) either absorbs unrelated events (when the contextvar is also None) or skips the flow's own LLM calls (when set to a different id). Seed instance._flow_match_id = instance.flow_id at the end of from_pending so the resume-phase aggregator has a real id to match against. The accumulator itself stays at zero on restore — any usage from before the pause was only observable on the original kickoff instance. Add an end-to-end test that pauses a flow, restores it via from_pending, emits one of its own LLM events and one belonging to a sibling flow during resume, and asserts only its own is counted.