How to run a single method starting from a persisted state

I have a flow with a sequence of methods that depend on each other:

Method 1 → Method 2 → Method 3

I’d like to persist the state of the flow and run only method 3 from the state generated by methods 1 and 2. I’m doing this because I’m developing method 3 and I don’t want to waste time and resources recalculating methods 1 and 2 each time.

What’s the best way of achieving this with crewai?

Thanks!

  1. Step #1 kicks off; it checks if a specific key (related to its output) is populated. Since there’s nothing in that key, Step #1 executes, and its result is saved to the corresponding key. The state is then persisted (saved).
  2. Step #2 kicks off; it checks if a specific key (related to its output) is populated. Since there’s nothing in that key, Step #2 executes, and its result is saved to the corresponding key. The state is then persisted.
  3. When Step #3 is finally ready, you run the Flow again (using a fixed id to ensure the state is retrieved). This time, Steps #1 and #2 will be skipped, as the keys representing their outputs are already present and their values are reused. Then, Step #3 kicks off, checks if its output key is populated, and since it’s still empty, the step executes, and its result is saved. Finally, the state is persisted.

I got it! I guess I’ll have to write the conditions manually. I was thinking about it, but I wanted to make sure it was the right thing. It would be great if you could just call a method and the run continues from that point on based on previously saved state.

Thank you!