Getting OSError: [WinError 123] when using memory=true

Hey there,

I wanted to start using the memory feature, but couldn’t get it to work. I am on a windows pc and as soon as I am setting memory=true for my crew, I get the following error:

OSError: [WinError 123] The syntax for the file name, directory name, or volume label is incorrect: 'C:\\Users\\{user_name}\\AppData\\Local\\CrewAI\\data_enrichment_crew/short_term/{a 840 char long name with all my agents...}'

I guess it’s because I have quite a complex use case with a couple of agents involved. If I am right, the folder name for the short term memory is generated by joining the agent names (crewAI/src/crewai/memory/storage/rag_storage.py at 02718e291b6cf2b4cedb2f2d923ce7ffc5aa9963 · crewAIInc/crewAI · GitHub). That leads to a folder name that is 840 chars long - windows has a 240 char max.

[class RAGStorage(Storage)](https://github.com/crewAIInc/crewAI/blob/02718e291b6cf2b4cedb2f2d923ce7ffc5aa9963/src/crewai/memory/storage/rag_storage.py#L27):
    """
    Extends Storage to handle embeddings for memory entries, improving
    search efficiency.
    """

    def __init__(self, type, allow_reset=True, embedder_config=None, crew=None):
        super().__init__()
        if (
            not os.getenv("OPENAI_API_KEY")
            and not os.getenv("OPENAI_BASE_URL") == "https://api.openai.com/v1"
        ):
            os.environ["OPENAI_API_KEY"] = "fake"

        agents = crew.agents if crew else []
        agents = [self._sanitize_role(agent.role) for agent in agents]
        **agents = "_".join(agents)**

        config = {
            "app": {
                "config": {"name": type, "collect_metrics": False, "log_level": "ERROR"}
            },
            "chunker": {
                "chunk_size": 5000,
                "chunk_overlap": 100,
                "length_function": "len",
                "min_chunk_size": 150,
            },
            "vectordb": {
                "provider": "chroma",
                "config": {
                    "collection_name": type,
                    **"dir": f"{db_storage_path()}/{type}/{agents}",**
                    "allow_reset": allow_reset,
                },
            },
        }

        if embedder_config:
            config["embedder"] = embedder_config
        self.type = type
        self.config = config
        self.allow_reset = allow_reset

Are there any workarounds? I tried setting a CustomRAG as provided in the documentation, but couldn’t get it to work either…

1 Like

what version are you on?? This was fixed a few versions back

1 Like

Was not on the very latest version. I did an upgrade just now and I am now on Version 0.70.1. But the error is still there.

In a clean environment?

Hi, same problem here.

I am using version 0.80.0 with a clean environment, and the issue is still happening.

This was the same error I had. Windows file paths have a set limit for 256 charicters when creating file folders for memory. This issue does not seem to have been addressed. I keep on getting invalid path when trying to execute my crew on windows. Any help would be appreciated. I'm using Version: 0.35.8 · Issue #944 · crewAIInc/crewAI · GitHub

there was a workaroud posted in this old discord thread. Discord

but try reducing the agent and role names to like 1,2,3. etc