Files
crewAI/lib
Matt Aitchison 654e738786 fix(events): gate RuntimeState recording to stop unbounded event-bus leak
The process-global event bus recorded every emitted event into a
RuntimeState (entity `root` list + `event_record`) on every kickoff,
unconditionally and with no eviction. Only the checkpoint/replay
machinery ever reads that recorder, so for the common "construct a
Flow/Crew, kickoff, discard" pattern it grew ~linearly with kickoff
count until a long-lived process (worker, request handler, scheduler)
was OOM-killed.

Gate recording behind an armed flag: the bus only registers entities and
records events once recording is enabled, which happens when a
CheckpointConfig is resolved on a Crew/Flow/Agent or when a state is
restored via set_runtime_state(). Plain and @persist kickoff loops now
record nothing; checkpoint/replay behavior is unchanged. Also expose a
public reset_runtime_state() so embedders that checkpoint but never
replay in-process can bound memory between runs.
2026-06-05 17:34:23 -05:00
..