Is there any way in crewai for getting the intermediate steps stored in the result,
like we do in langchain by setting return_intermediate_steps=True param in agent_executor
@Yash Yes, using CrewAI Flows, which has implemented state.
See the example from the official CrewAI docs (Note: It’s an example of structured state management.).
from crewai.flow.flow import Flow, listen, start
from pydantic import BaseModel
class ExampleState(BaseModel):
counter: int = 0
message: str = ""
class StructuredExampleFlow(Flow[ExampleState]):
@start()
def first_method(self):
self.state.message = "Hello from structured flow"
@listen(first_method)
def second_method(self):
self.state.counter += 1
self.state.message += " - updated"
@listen(second_method)
def third_method(self):
self.state.counter += 1
self.state.message += " - updated again"
print(f"State after third_method: {self.state}")
flow = StructuredExampleFlow()
flow.kickoff()
@rokbenko i only have one crew and task which i guess do not require the flow,
let me explain my usecase to you :
I have single agent comparising of multiple tools i want to get the output exact what is returned by the tool but sometimes my final answer is an explaination.
so what i am thinking is too get the intermediate steps in that case