Hi everyone,
I’m using CrewAI with an unstructured state in my flow, and according to the documentation, an "id"
field should be automatically created and accessible in self.state
when the flow starts.
However, in my code snippet below:
class CustomerSupportFlow(Flow):
def __init__(self):
super().__init__()
load_dotenv()
self.llm_model = os.getenv("MODEL")
@start()
def receive_ticket(self):
# Inizializza il ticket
print(f"Ricezione del ticket... state_id: {self.state["id"]}")
self.state["ticket"] = Ticket(1, "Mario Rossi", "Problema con l'ordine")
print(f"Ticket ricevuto: {self.state["ticket"].get_attr()}")
I get a KeyError: 'id'
on the line where I try to print self.state["id"]
. It seems that "id"
is not initialized automatically in the unstructured state, contrary to what the docs say.
Has anyone encountered this? Is there a workaround or a step I might be missing?
Thanks in advance!
Edit:
Same problem with structured state when trying to access state id with self.state.id