mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-08-10 16:32:28 +00:00
`_emit_flow_failed` returned early whenever `defer_trace_finalization` was on, mirroring the success path where the terminal event is owed to a later `finalize_session_traces()`. A failed turn never reaches that call, so the session's `flow_started` was left open and tracing closed the root span as orphaned. The event is now emitted for deferred sessions too, clearing the stashed started-event id so a later finalization does not emit a second terminal event, while batch finalization stays with whoever owns the session.