I’m developing a flow to kick off crews for web research on a long list of companies. This flow works well with just one company as input:
inputs = {
"company": "[the company]",
(...other inputs)
}
def run():
_input = inputs
try:
MyCrew().crew().kickoff_for(inputs=_input)
except Exception as e:
raise Exception(f"An error occurred while running the crew: {e}")
However, when I run a similar flow with a list of multiple inputs using kickoff_for_each
instead of kickoff
, as in:
inputs = [
{
"company": company,
(...other inputs)
} for company in companies
]
def run():
_input = inputs
try:
MyCrew().crew().kickoff_for_each(inputs=_input)
except Exception as e:
raise Exception(f"An error occurred while running the crew: {e}")
I get a litany of errors from pydantic about the memory tools I’m using:
pydantic_core._pydantic_core.ValidationError: 3 validation errors for Crew
short_term_memory
Input should be an instance of ShortTermMemory [type=is_instance_of, input_value={'embedder_config': None,... object at 0x144d6d300>}, input_type=dict]
For further information visit https://errors.pydantic.dev/2.10/v/is_instance_of
long_term_memory
Input should be an instance of LongTermMemory [type=is_instance_of, input_value={'embedder_config': None,... object at 0x144d6d1e0>}, input_type=dict]
For further information visit https://errors.pydantic.dev/2.10/v/is_instance_of
entity_memory
Input should be an instance of EntityMemory [type=is_instance_of, input_value={'embedder_config': None,... object at 0x144d6d2d0>}, input_type=dict]
For further information visit https://errors.pydantic.dev/2.10/v/is_instance_of
I’ve confirmed that the individual elements of the list comprehension are of the same structure as the version that works successfully with kickoff
; if I create the list comprehension and run kickoff(inputs=_input[0])
, everything works as expected, so I don’t think it’s a data structure issue.
For reference, this is my memory implementation (which works in single kickoff
but not kickoff_for_each
):
@crew
def crew(self) -> Crew:
return Crew(
agents=self.agents,
tasks=self.tasks,
process=Process.hierarchical,
memory = True,
long_term_memory = LongTermMemory(
storage=LTMSQLiteStorage(
db_path="memory/long_term_memory_storage.db"
)
),
short_term_memory = ShortTermMemory(
storage = RAGStorage(
embedder_config={
"provider": "openai",
"config": {
"model": 'text-embedding-3-small'
}
},
type="short_term",
path="memory/"
)
),
entity_memory = EntityMemory(
storage=RAGStorage(
embedder_config={
"provider": "openai",
"config": {
"model": 'text-embedding-3-small'
}
},
type="short_term",
path="memory/"
)
),
verbose=True,
manager_llm=llm #defined using LLM()
)
I’ve tried downgrading pydantic as far as I can, but 2.4.2 seems to be the earliest version that is still compatible with crewAI, and it still generates these errors. I’ll also note that if I disable / comment out all three memory tools for the crew, the script then works with kickoff_for_each
, but does not produce satisfactory results; therefore, I’d like to figure out how to enable memory with kickoff_for_each
. Anyone encountered similar issues?