crewAIInc/crewAI · error · TimeoutError

{index_name=} did not complete in {wait_until_complete}!

Error message

{index_name=} did not complete in {wait_until_complete}!

What it means

A polling helper in the MongoDB vector search tool utils: it loops calling predicate() every `interval` seconds until it returns True or `timeout` (default TIMEOUT) elapses, at which point it raises TimeoutError(err). In this tool it is used to wait for a MongoDB Search Index (e.g. an Atlas vector index) to finish building, so the error means the named index ({index_name}) was still not ready when the wait budget expired.

Source

Thrown at lib/crewai-tools/src/crewai_tools/tools/mongodb_vector_search_tool/utils.py:121

def _wait_for_predicate(
    predicate: Callable[[], bool], err: str, timeout: float = 120, interval: float = 0.5
) -> None:
    """Generic to block until the predicate returns true.

    Args:
        predicate (Callable[, bool]): A function that returns a boolean value
        err (str): Error message to raise if nothing occurs
        timeout (float, optional): Wait time for predicate. Defaults to TIMEOUT.
        interval (float, optional): Interval to check predicate. Defaults to DELAY.

    Raises:
        TimeoutError: _description_
    """
    start = monotonic()
    while not predicate():
        if monotonic() - start > timeout:
            raise TimeoutError(err)
        sleep(interval)

View on GitHub (pinned to 754d7323be)

Solutions

  1. Retry after waiting — Atlas index builds often just need more time; check the Atlas UI for index status/size
  2. Increase wait_until_complete / the timeout argument passed to the wait helper
  3. Verify in Atlas UI > Search that the index is BUILDING vs FAILED; fix the definition if FAILED
  4. Warm up separately: create the index and let it finish before running the tool (decouple index creation from ingestion)

Example fix

# before
tool.upsert(["text"], ids=["1"], metadatas=[{}])  # TimeoutError on fresh index

# after
# create/verify index in Atlas first, then allow a larger budget
tool = MongoDBVectorSearchTool(
    collection_name="docs",
    index_name="vector_index",
    wait_until_complete=600,  # give large collections room
)
Defensive patterns

Strategy: retry

Validate before calling

def index_ready(client, coll, index_name: str) -> bool:
    indexes = list(coll.list_search_indexes())
    return any(
        i.get("name") == index_name and i.get("status", "").upper() in ("READY", "ACTIVE")
        for i in indexes
    )

Try / catch

import time

for attempt in range(5):
    try:
        tool.upsert(texts, ids=ids)
        break
    except TimeoutError:
        if attempt == 4:
            raise
        time.sleep(60)  # index build may just need more time

Prevention

When it happens

Trigger: Calling upsert/index-creation flows right after creating a new Atlas vector search index — large collections take minutes to build; using a free/shared Atlas tier with slow index builds; an index that failed to build (bad definition) so the predicate never becomes true; a too-small wait_until_complete value.

Common situations: First run on a fresh collection where the vector index was just created; big collections with many embeddings; typo'd index definition leaving it in a failed state; CI time budgets shorter than build time.

Related errors


AI-assisted analysis of crewAIInc/crewAI@754d7323be (2026-08-15). Data as JSON: /api/errors/ae900f40cf97c8b2. Report an issue: GitHub.