Memory & Working Knowledge
Every Turn process has a built-in, durable key-value memory store. You write to it with remember, read from it with recall, and it persists automatically across suspend boundaries and VM restarts. No external database is required.
The Problem with Ad-Hoc Memory
In most agent systems, "memory" means either:
- A messages list Unbounded, context-polluting, with no retrieval strategy.
- A vector database An entirely separate service to maintain, query, and synchronize.
Turn makes memory a first-class component of the process state, stored alongside the agent's environment, context window, and mailbox. It is durable and automatic.
remember : Writing to Memory
remember("key", value);Stores a value in the agent's persistent memory under the given key. Memory persists across turns, suspend boundaries, and process restarts.
// Store any Turn value: strings, numbers, maps, lists
remember("user_name", "Alice");
remember("preferred_style", "concise, bullet-point format");
remember("session_count", 7);
remember("last_context", current_summary);NOTE
Memory is isolated per process. Each spawned actor has its own memory namespace. A child process cannot read or write the parent's memory.
recall : Reading from Memory
let value = recall("key");Retrieves the value stored under the given key. Returns null if the key does not exist.
let name = recall("user_name");
if name == null {
remember("user_name", "Guest");
} else {
call("echo", "Welcome back, " + name);
}
let style = recall("preferred_style");
let result = infer Summary {
"Summarize this report in " + style + ": " + report_text;
};Memory Across Sessions
Memory survives process restarts. This is the primary mechanism for building agents that accumulate knowledge over time:
// Read state from previous sessions
let run_count = recall("run_count");
let last_result = recall("last_result");
if run_count == null {
remember("run_count", 1);
call("echo", "First run. No prior state.");
} else {
let new_count = run_count + 1;
remember("run_count", new_count);
call("echo", "Run #" + new_count + ". Last result was: " + last_result);
}
let result = infer Report { "Analyze current market conditions."; };
remember("last_result", result["summary"]);Memory vs. Context
These are two distinct primitives with different lifetimes and purposes:
memory = the agent's DURABLE KNOWLEDGE
persisted to .turn_store/ automatically
survives restarts, suspend boundaries
exact key-value lookup via recall()
context = the agent's WORKING SCRATCHPAD for this turn
token-bounded, per-process
what the LLM sees when infer is called
written with context.append()| Memory | Context | |
|---|---|---|
| Lifetime | Permanent (persists across restarts) | Per-turn (cleared on completion) |
| Capacity | Unlimited | Token-budgeted |
| Access | Exact key lookup (recall("key")) | Automatic (injected into every infer) |
| Written with | remember("key", val) | context.append(val) |
| Read with | recall("key") | Automatic |
Use memory for facts that should persist across conversations, sessions, and process restarts. Use context for the working scratchpad of the current inference call.