crewAIInc/crewAI · error · ValueError
Mind name is not set.
Error message
Mind name is not set.
What it means
AIMindTool._run() sends the query to the Minds API using self.mind_name as the model name. The constructor normally sets self.mind_name from the created mind (mind.name), so hitting this ValueError means the attribute is None at run time — typically because construction was bypassed, the attribute was overwritten, or object state was mutated/restored (e.g. pickling) without it.
Source
Thrown at lib/crewai-tools/src/crewai_tools/tools/ai_mind_tool/ai_mind_tool.py:91
)
datasources.append(config)
name = f"{AIMindToolConstants.MIND_NAME_PREFIX}_{secrets.token_hex(5)}"
mind = minds_client.minds.create(
name=name, datasources=datasources, replace=True
)
self.mind_name = mind.name
def _run(self, query: str) -> str | None:
# The Minds API is OpenAI compatible and therefore, the OpenAI client can be used.
openai_client = OpenAI(
base_url=AIMindToolConstants.MINDS_API_BASE_URL, api_key=self.api_key
)
if self.mind_name is None:
raise ValueError("Mind name is not set.")
completion = openai_client.chat.completions.create(
model=self.mind_name,
messages=[{"role": "user", "content": query}],
stream=False,
)
if not isinstance(completion, ChatCompletion):
raise ValueError("Invalid response from AI-Mind")
return completion.choices[0].message.content
View on GitHub (pinned to 754d7323be)
Solutions
- Ensure the tool is created normally via AIMindTool(api_key=..., datasources=...) so __init__ completes mind creation and sets mind_name.
- If state was mutated, re-set it: tool.mind_name = <name from Minds dashboard> before running.
- Avoid serializing the tool instance; recreate it per run instead.
- Check for swallowed exceptions during construction that leave the object half-initialized.
Example fix
# before openai_client = OpenAI(...) result = tool._run(query) # mind_name is None # after assert tool.mind_name, "AIMindTool not fully initialized; recreate the tool" result = tool._run(query)
Defensive patterns
Strategy: type-guard
Validate before calling
def aimind_ready(tool) -> bool:
return getattr(tool, "mind_name", None) is not None Type guard
def is_initialized_aimind(tool: object) -> bool:
return bool(getattr(tool, "mind_name", None)) and bool(getattr(tool, "api_key", None)) Try / catch
try:
result = tool._run(query)
except ValueError as e:
if "Mind name is not set" in str(e):
tool = AIMindTool(api_key=..., datasources=[...]) # re-create properly
result = tool._run(query)
else:
raise Prevention
- Always construct AIMindTool through its __init__ so mind creation completes.
- Don't deep-copy, pickle, or cache tool instances; rebuild them per session.
- Add a preflight assert on tool.mind_name before first use.
When it happens
Trigger: Calling tool._run(query) on an instance whose __init__ did not complete the mind-creation step (e.g. an exception swallowed after client creation); serializing/deserializing the tool without the attribute; manually setting tool.mind_name = None; subclass overrides skipping super().__init__.
Common situations: Deep-copying or caching tool instances; crew flows that rebuild tools from config and skip the constructor; tests constructing the object via __new__ or mocks.
Related errors
- Client is not initialized
- Failed to initialize MCP Adapter: {e}
- MCP server not started, run `mcp_server.start()` first befor
- max_bytes must be positive, got {max_bytes}.
- Invalid response from AI-Mind
AI-assisted analysis of crewAIInc/crewAI@754d7323be (2026-08-15).
Data as JSON: /api/errors/f61ae31617922fe8.
Report an issue: GitHub.