microsoft/autogen · error · RuntimeError

Reset not allowed. Set allow_reset=True in config to enable.

Error message

Reset not allowed. Set allow_reset=True in config to enable.

What it means

reset() is a destructive operation (wipes the whole ChromaDB client, all collections), so it is gated by the allow_reset flag in ChromaDBMemoryConfig (default False). Calling reset() without allow_reset=True raises RuntimeError to prevent accidental data loss.

Source

Thrown at python/packages/autogen-ext/src/autogen_ext/memory/chromadb/_chromadb.py:440

            raise RuntimeError("Failed to initialize ChromaDB")

        try:
            results = self._collection.get()
            if results and results["ids"]:
                self._collection.delete(ids=results["ids"])
        except Exception as e:
            logger.error(f"Failed to clear ChromaDB collection: {e}")
            raise

    async def close(self) -> None:
        """Clean up ChromaDB client and resources."""
        self._collection = None
        self._client = None

    async def reset(self) -> None:
        self._ensure_initialized()
        if not self._config.allow_reset:
            raise RuntimeError("Reset not allowed. Set allow_reset=True in config to enable.")

        if self._client is not None:
            try:
                self._client.reset()
            except Exception as e:
                logger.error(f"Error during ChromaDB reset: {e}")
            finally:
                self._collection = None

    def _to_config(self) -> ChromaDBVectorMemoryConfig:
        """Serialize the memory configuration."""

        return self._config

    @classmethod
    def _from_config(cls, config: ChromaDBVectorMemoryConfig) -> Self:
        """Deserialize the memory configuration."""

View on GitHub (pinned to 027ecf0a37)

Solutions

  1. If a full wipe is intended, construct the config with ChromaDBVectorMemoryConfig(..., allow_reset=True) — ideally only in tests.
  2. If you only want to empty one collection, use clear() instead of reset(); it does not require the flag.
  3. Keep allow_reset=True scoped to test/dev configs and never enable it for persistent production stores.

Example fix

# before
config = ChromaDBVectorMemoryConfig(collection_name='memos')
memory = ChromaDBVectorMemory(config=config)
await memory.reset()  # RuntimeError

# after (tests only)
config = ChromaDBVectorMemoryConfig(collection_name='memos', allow_reset=True)
memory = ChromaDBVectorMemory(config=config)
await memory.reset()
Defensive patterns

Strategy: validation

Validate before calling

def can_reset(memory) -> bool:
    return bool(memory._config.allow_reset) and getattr(memory, '_client', None) is not None

Try / catch

try:
    await memory.reset()
except RuntimeError as e:
    if 'Reset not allowed' in str(e):
        await memory.clear()  # non-destructive fallback for one collection
    else:
        raise

Prevention

When it happens

Trigger: await memory.reset() on a ChromaDBVectorMemory whose config was built with default allow_reset=False; explicitly constructing ChromaDBVectorMemoryConfig(allow_reset=False) and then resetting; calling reset() in test teardown on a production-configured memory.

Common situations: Test helpers that reset state between cases while reusing a production config; copying example config into tests without noticing the safety flag; assuming reset() only clears one collection (it resets the entire client).

Related errors


AI-assisted analysis of microsoft/autogen@027ecf0a37 (2026-08-15). Data as JSON: /api/errors/ccc96663fe6fa77c. Report an issue: GitHub.