Skip to main content
An instance has three kinds of memory, and only one of them is real. Storage is the truth. The message log (this.messages), the state (setState and getState, which merge-patch), the schedule (queue, schedule, every) and the instance’s SQL database are written before a call returns and reloaded when the instance next activates, on whatever host that is. Each instance has its own; no instance can read another’s. Instance fields are a cache. They are the fastest memory and the least reliable: an instance can be evicted between any two calls. The pattern is to load from storage on activation and never assume the cache is still there. The container is neither. Its filesystem and its module-level variables are shared by whichever instances happen to be placed in it, and are gone when an instance moves. Nothing an instance relies on belongs there, and nothing one conversation should hide from another belongs there either; Isolation lists what is shared. Long-term memory across conversations is not any of these. It is Agent Memory, outside the runtime, keyed by the profile (the caller’s number on calls and texts, the sender’s address on email, the conversation’s name otherwise), read when the instance activates and written after each turn that replied, or at hang-up on a call on the direct engine.