Quick Start
1
Simple Usage
A gateway callsite stamps inbound channel input as
UNTRUSTED; recall gates on TRUSTED so it is fenced out.2
Wiring the origin
Add a free-form
origin label so the write is auditable by channel and session.How It Works
Untrusted channel input is stamped at the gateway, then dropped at recall time before it can reach the model as trusted context. The trust field is structured metadata, not prose. A hostile group-chat message can put whatever text it wants intotext, but it cannot forge metadata["trust"] = "trusted" — that value comes from the caller, not the message content.
Trust Levels
Three levels order asuntrusted < trusted < system.
Values are plain strings (
str, Enum), so "trusted" / "untrusted" / "system" are accepted anywhere a MemoryTrust is.
The gate fails closed in every ambiguous case:
- Legacy records are trusted. A record with no
metadata["trust"]field ranks asTRUSTED. - Unknown persisted trust labels fail closed (rank as
UNTRUSTED). - A misspelled
min_truston the search call raisesValueError— the gate must fail loudly, never silently weaken. metadata=Noneon a returned record does not crash recall — such records are treated as trusted.
API Reference
New keyword arguments on the coreMemory methods. Existing callers are unaffected — when no keyword is passed, nothing changes.
Defaults are unchanged: a
store_* call without trust/origin is treated as trusted; a search_* call without min_trust returns everything, same as before.
Choosing What to Stamp
Pick a trust level by where the content came from.Common Patterns
Gateway-bot store — stamp every inbound channel message untrusted with an origin.TRUSTED.
Best Practices
Default to UNTRUSTED at every gateway callsite
Default to UNTRUSTED at every gateway callsite
Any content originating from a third-party channel (group chat, DM, webhook) should be stamped
trust=MemoryTrust.UNTRUSTED at the point it enters memory. Treat trusted as the exception, not the default, for channel-derived writes.Always pass min_trust=TRUSTED on recall paths that feed model context
Always pass min_trust=TRUSTED on recall paths that feed model context
Recall paths that inject memory into a later, unrelated turn should call
search_* with min_trust=MemoryTrust.TRUSTED. This is what fences out poisoned memory before it can resurface as trusted context.Use origin for auditing, not for policy
Use origin for auditing, not for policy
origin is a free-form route/channel/session label (e.g. "telegram:group:123"). Use it to audit where a record came from — do not branch trust decisions on it. Trust decisions belong on the trust field.Never silently downgrade a misspelled threshold
Never silently downgrade a misspelled threshold
A misspelled
min_trust raises ValueError. Let it surface — do not wrap it in a fallback that silently weakens the gate. Failing loudly is the point.Related
Untrusted Request Fencing
Fence webhook and hook payloads as data, not instructions.
Prompt Injection Protection
Detect and neutralise injection attempts in inbound content.
Memory
Short-term, long-term, and entity memory overview.

