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.
pip install 'llmslim[mongodb]'2. Architecture & execution flow
3. Production code pattern
from llmslim.integrations.mongodb import MongoDBContextStore
store = MongoDBContextStore.from_env()
await store.save(user_approved_memory, namespace="tenant-42")
items = await store.search("renewal preference", limit=5, namespace="tenant-42")
# Pass items to plan_context(); persistence is never automatic.4. Deployment best practices
5. Key optimization tips
Frequently asked questions
Troubleshooting
The database is unavailable
Context-source collection fails closed by default, and hosted paid inference fails closed before calling Sarvam.