FoundationAgents/MetaGPT · error · ValueError

IndexRepo {Path(self.persist_path).name} not exists.

Error message

IndexRepo {Path(self.persist_path).name} not exists.

What it means

ValueError from IndexRepo._search_with_index: a filename filter was supplied but the FAISS index directory at self.persist_path does not exist, so there is no persisted index to load via SimpleEngine.from_index. The repository is search-only here; indexes must be created beforehand (e.g. via Editor's write operations that feed IndexRepo).

Source

Thrown at metagpt/tools/libs/index_repo.py:325

                    pathnames.append(j)

        logger.debug(f"{pathnames}, excludes:{excludes})")
        return pathnames, excludes

    async def _search(self, query: str, filters: Set[str]) -> List[NodeWithScore]:
        """Perform a search for the given query using the index.

        Args:
            query (str): The search query.
            filters (Set[str]): A set of filenames to filter the search results.

        Returns:
            List[NodeWithScore]: A list of nodes with scores matching the query.
        """
        if not filters:
            return []
        if not Path(self.persist_path).exists():
            raise ValueError(f"IndexRepo {Path(self.persist_path).name} not exists.")
        Context()
        engine = SimpleEngine.from_index(
            index_config=FAISSIndexConfig(persist_path=self.persist_path),
            retriever_configs=[FAISSRetrieverConfig()],
        )
        rsp = await engine.aretrieve(query)
        return [i for i in rsp if i.metadata.get("file_path") in filters]

    def _is_fingerprint_changed(self, filename: Union[str, Path], content: str) -> bool:
        """Check if the fingerprint of the given document content has changed.

        Args:
            filename (Union[str, Path]): The filename of the document.
            content (str): The content of the document.

        Returns:
            bool: True if the fingerprint has changed, False otherwise.
        """

View on GitHub (pinned to 11cdf466d0)

Solutions

  1. Run the indexing step for the repo root first so the FAISS index is persisted
  2. Verify Path(persist_path).exists() before searching
  3. If the index was deleted unintentionally, re-index and then retry the search

Example fix

# before
repo = IndexRepo(persist_path=".index/repo_a", root_path="repo_a")
await repo.search(query, filenames=[f])  # raises: index dir absent
# after: index first (e.g. via Editor write flow that feeds IndexRepo), then
from pathlib import Path
assert Path(".index/repo_a").exists()
await repo.search(query, filenames=[f])
Defensive patterns

Strategy: validation

Validate before calling

from pathlib import Path
if not Path(repo.persist_path).exists():
    raise SystemExit(f"no index at {repo.persist_path}; run indexing first")

Try / catch

try:
    res = await repo.search(query, filenames=files)
except ValueError as e:
    if "not exists" in str(e):
        # trigger an indexing pass over repo.root_path, then retry
        raise

Prevention

When it happens

Trigger: Constructing IndexRepo(persist_path=..., root_path=...) for a directory that was never indexed, then awaiting search(query, filenames=[...]) with a non-empty filter.

Common situations: Searching a fresh workspace before any indexing run; the index directory was cleaned/deleted; persist_path typo points at a non-existent location; first use after cloning a repo that doesn't ship indexes.

Related errors


AI-assisted analysis of FoundationAgents/MetaGPT@11cdf466d0 (2026-08-14). Data as JSON: /api/errors/3a4d328fd4308f2f. Report an issue: GitHub.