> ## Documentation Index
> Fetch the complete documentation index at: https://developers.telnyx.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Memory Model

An instance has three kinds of memory, and only one of them is real.

| Memory | Scope | Lifetime | Examples |
| - | - | - | - |
| Storage | The instance | Until the agent is deleted | The message log, the state, the scheduled tasks, the SQL database |
| Instance fields | The instance, while activated | Until eviction, restart or relocation | `this.cache`, anything on `this` that is not storage |
| The container | Every instance placed in it | Until the container is replaced | The filesystem, `/tmp`, module-level variables |

**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](/docs/agents/model/isolation) lists what is shared.

Long-term memory across conversations is not any of these. It is [Agent Memory](/docs/agents/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.
