crewAIInc/crewAI · error · ValueError
Agent ID is required to query the Contextual AI agent
Error message
Agent ID is required to query the Contextual AI agent
What it means
Error "Agent ID is required to query the Contextual AI agent" thrown in crewAIInc/crewAI.
Source
Thrown at lib/crewai-tools/src/crewai_tools/tools/contextualai_query_tool/contextual_query_tool.py:71
return not any(
doc.get("status") in ("processing", "pending") for doc in documents
)
return True
async def _wait_for_documents_async(
self, datastore_id: str, max_attempts: int = 20, interval: float = 30.0
) -> bool:
"""Asynchronously poll until documents are ready, exiting early if possible."""
for _attempt in range(max_attempts):
ready = await asyncio.to_thread(self._check_documents_ready, datastore_id)
if ready:
return True
await asyncio.sleep(interval)
return True # give up but don't fail hard
def _run(self, query: str, agent_id: str, datastore_id: str | None = None) -> str:
if not agent_id:
raise ValueError("Agent ID is required to query the Contextual AI agent")
if datastore_id:
ready = self._check_documents_ready(datastore_id)
if not ready:
try:
# If no running event loop, use asyncio.run
loop = asyncio.get_running_loop()
except RuntimeError:
loop = None
if loop and loop.is_running():
# Already inside an event loop
try:
import nest_asyncio # type: ignore[import-untyped]
nest_asyncio.apply(loop)
loop.run_until_complete(
self._wait_for_documents_async(datastore_id)View on GitHub (pinned to 754d7323be)
Solutions
- Pass a valid agent_id obtained from the Contextual AI console.
When it happens
Trigger: Thrown at lib/crewai-tools/src/crewai_tools/tools/contextualai_query_tool/contextual_query_tool.py:71 when the library encounters an invalid state.
Common situations: Occurs when the Contextual AI query tool is called without an agent ID. Provide the agent ID of the agent to query.
AI-assisted analysis of crewAIInc/crewAI@754d7323be (2026-08-15).
Data as JSON: /api/errors/3b99882b84787c0d.
Report an issue: GitHub.