When defining a task and agent for a flow, I can define a a state in code and refer to it in flow inside the code. Is it possible to refer to it directly in YAML or do I have to write the code to pass this information and run the task in a flow function?
Essentially what I want to do is search the web for a list of trending topics. Then write an article. Later I don’t want to select the same topic so I want to give the list of topics to avoid to the researcher task.
You’ll likely run each Crew within a specific node or step of your Flow. That node (which would be a method) has access to the state and can then pass the relevant data to the crew via crew.kickoff(inputs={}).
No, that’s not how it works. Your YAML file is meant for substituting placeholders with external strings. So, if your YAML has a line like Here's your question: {user_question}, you would pass the value from your state when you call the crew, for instance: crew.kickoff(inputs={"user_question": self.state.query}).
If you need more specific advice on your use case, I suggest you put together a minimal, reproducible example. This will help isolate the exact issue you’re facing, allowing others to run your code and provide helpful suggestions.
I realized that almost as soon as I posted this query. However I let it be to make sure that I wasn’t missing anything.
YAML approach is a very good simplification and I assume CrewAI reads it on demand (please confirm if you can) so in case of a very long running flow (in case we develop it) we may be able to modify it without restarting the flow?
A different question: Can we hibernate a flow? Is there a way to hibernate a session so that it could be waiting for something to happen (like an email reception) which may come in some days.
It seems that crewAI (even flow) is designed for top down. There is no loop concept (even with router and kick_off with array) Nothing like come back to this point or wake up, check, go to sleep. Even if we do these from outside how can we pick up a particular execution to continue?
Of course there are many ways to implement this. Two naive approaches are:
You could simply halt the process at one of the nodes (methods). As long as a specific condition isn’t met, that node would keep the entire flow paused. Obviously, this approach isn’t practical for processes that might be delayed for a long time.
Another possibility is to use a flag in the shared state. Remember, you can and should leverage the shared state as a central repository for information. Also, keep in mind that you don’t have to execute a node unconditionally. Before running its core logic, a node can first check if a specific flag has been set in the shared state. If it has, the node can simply return without executing. This causes all subsequent nodes to effectively skip their turn, allowing the flow to terminate cleanly and intelligently. Then, when the resume event occurs, you would simply trigger the flow again (after clearing the termination flag). Each node would then check if its task has already been completed, passing its turn if so. The end result is a system where the nodes behave as if they have a memory of where the process left off.