← Back to PRs

#22518: feat(extensions): add chromadb-memory plugin with multi-agent collection routing

by ta3pks open 2026-02-21 07:59 View on GitHub →
size: L
## Summary Adds a new `chromadb-memory` extension — a fully self-hosted long-term memory plugin backed by ChromaDB and local Ollama embeddings. No cloud APIs required. ## Features - **Auto-recall**: Before every agent turn, the user's message is embedded via Ollama and queried against ChromaDB. Relevant results (above `minScore`) are injected into context automatically. - **`chromadb_search` tool**: Manual semantic search over ChromaDB for when the agent needs to dig deeper. - **Hybrid search**: Combines vector similarity with keyword boosting (capitalized proper nouns, quoted phrases) for better recall on named entities. - **Multi-agent collection routing** (new): Set `collectionMap` to route different agents to different ChromaDB collections — keeps agent memories isolated without running separate plugin instances. - **Backward compatible**: `collectionMap` is optional. If omitted, all agents use `collectionName` as before. - **Per-collection ID cache**: Fixes a cross-agent cache collision bug where multiple agents sharing one plugin instance would incorrectly reuse each other's resolved collection IDs. ## Multi-agent config example ```json { "plugins": { "entries": { "chromadb-memory": { "enabled": true, "config": { "chromaUrl": "http://localhost:8000", "collectionName": "longterm_memory", "collectionMap": { "main": "longterm_memory", "regina": "regina_memory" }, "ollamaUrl": "http://localhost:11434", "embeddingModel": "nomic-embed-text", "autoRecall": true } } } } } ``` ## Schema change - Added `collectionMap` property to `openclaw.plugin.json` config schema - Changed `additionalProperties: false` → `true` to prevent validation failures as the plugin evolves ## Prerequisites - ChromaDB running locally (Docker or native) - Ollama with `nomic-embed-text` pulled ## Testing Tested on a live OpenClaw setup with two agents (`main` + `regina`) sharing one gateway, each with their own ChromaDB collection. Hot-reload confirmed working — no gateway restart required when adding `collectionMap` to an existing config. <!-- greptile_comment --> <h3>Greptile Summary</h3> Added a new `chromadb-memory` extension that provides self-hosted long-term memory backed by ChromaDB with local Ollama embeddings. The plugin features auto-recall (automatic context injection before agent turns), a manual `chromadb_search` tool, and hybrid search combining vector similarity with keyword boosting. The key enhancement is multi-agent collection routing via `collectionMap`, which allows different agents to use separate ChromaDB collections without running multiple plugin instances. This fixes a cross-agent cache collision bug where agents would incorrectly share resolved collection IDs. **Key changes:** - Per-collection ID cache to prevent cross-agent cache collisions - Backward-compatible `collectionMap` configuration (optional, falls back to `collectionName`) - Hybrid search with keyword extraction for proper nouns and quoted phrases - Error handling with cache invalidation and retry logic - Schema change: `additionalProperties: false` → `true` in config schema for forward compatibility **Issues found:** - The `before_agent_start` hook signature is incorrect - it should receive `(event, ctx)` with `agentId` in the second parameter `ctx`, not in `event` <h3>Confidence Score: 3/5</h3> - This PR contains a critical syntax error in the event handler that will cause the multi-agent routing feature to malfunction - The implementation is well-structured and solves a real cross-agent cache collision bug, but has a critical bug in the `before_agent_start` hook signature that will prevent the multi-agent collection routing from working correctly. The `agentId` is being read from the wrong parameter (`event.agentId` instead of `ctx.agentId`), which means all agents will likely fall back to the default collection. - Pay close attention to `extensions/chromadb-memory/index.ts` - the event handler signature needs correction before merging <sub>Last reviewed commit: 2fefca8</sub> <!-- greptile_other_comments_section --> <sub>(2/5) Greptile learns from your feedback when you react with thumbs up/down!</sub> <!-- /greptile_comment -->

Most Similar PRs