Exception Hierarchy
Remem exposes five exception classes, each mapping to a specific HTTP status code and failure scenario:Importing Exception Classes
Import all exception classes at the top of your module:Handling Each Exception
AuthenticationError — 401
Raised when your API key is invalid, missing, or revoked. This is not a transient error — retrying with the same key will always fail.PlanLimitError — 402
Raised when your account has reached its memory limit for the current plan. You can still read and search memories — only new writes are blocked.Your agent can still read and search memories when the limit is hit — only new writes are blocked. Your agent will not go blind; it just stops learning new things until you upgrade.
MemoryNotFoundError — 404
Raised when you try to update or delete a memory ID that does not exist — either because it was already deleted or the ID is wrong.DuplicateMemoryError — 409
Raised when you try to store content that is already present at 95% similarity or above. This is Remem protecting your memory store from redundant data — treat it as a no-op.DuplicateMemoryError is not a real error in most cases — it means Remem protected your database from storing the same fact twice. Ignore it silently in production.RememError — Catch-All
RememError is the base class for all Remem exceptions. Use it as a fallback to catch unexpected errors — server errors, rate limits, or anything else not matched by a specific subclass.
Production-Ready Pattern
This is the pattern to use in any production agent. Both helper functions are guaranteed never to raise — your agent continues regardless of what Remem returns.Retry Logic
For transient server errors (5xx), use exponential backoff before giving up. Don’t retry on client errors (4xx) — those require a code or configuration fix.Error Reference
Production Checklist
Run through this checklist before shipping any agent that uses Remem in production.
Wrap every
remember() call — DuplicateMemoryError is common and safe to ignoreHandle
PlanLimitError gracefully — agent should continue without storing, not crashLog
AuthenticationError immediately — it means your key needs fixingReturn an empty list from
recall() on error — agent degrades gracefully with no contextAdd retry logic for 5xx errors — transient server issues should not kill your agent