Skip to main content
Back to integrations
Backend ServicesMemory & retrieval

LLMSlim + MongoDB

Explicit persistent context, Atlas retrieval, and hosted quota accounting.

MongoDBContextStore provides opt-in context persistence and bounded text/vector retrieval. MongoDBHostedQuotaStore uses a separate operational collection for atomic hosted-demo rate, token, spend, concurrency, and aggregate telemetry records.

1. Package installation

Install LLMSlim and the official MongoDB SDK using your package manager.

terminal

2. Architecture & execution flow

1

Initialize a store explicitly with a server-side URI.

2

Persist only caller-approved context or traces.

3

Retrieve bounded records as untrusted memory/RAG items.

4

Keep hosted quota metadata in a separate operational collection.

3. Production code pattern

mongodb_memory.py

4. Deployment best practices

Keep MONGODB_URI server-side, use Stable API and TLS, isolate tenant namespaces, set short timeouts, and separate the hosted quota collection from user content and memory collections.

5. Key optimization tips

  • Persist only with explicit user/application intent.
  • Supply embedding providers explicitly for Atlas Vector Search.
  • Treat every retrieved record as untrusted unless the caller establishes stronger provenance outside the database.

Frequently asked questions

Troubleshooting