Skip to main content
Choose the state you need before enabling memory features. Session history retains a conversation; user facts can inform another session; notes and vector-backed learnings have separate storage and retrieval contracts. For a complete two-turn application, follow the memory tutorial. For @agentium/harness history and leases, use harness conversations.

Continue a chat

Use the Agent conversation pattern with a stable, owner-scoped session ID and configured storage. Verify a follow-up can reference the earlier order number. InMemoryStorage is process-local; select a persistent storage adapter when restart persistence is required.

Remember an explicit preference across sessions

Host function: pass a configured model. This example deliberately records a known preference for one fictional user, then asks about it in a new session. It owns the Agent and in-memory store. Live model calls still need provider credentials.
Verify the returned facts include the preference and the response uses it. This checks an explicit write, not automatic extraction quality. In an application, only store facts the authenticated user or an authorized workflow is permitted to assert. Automatic fact/profile extraction is model-backed background work. When a test must inspect its result, await agent.memory.awaitExtractions() after verifying memory exists, then inspect the store. Do not promise that every user statement becomes a correct durable fact.

Choose a memory feature

fileMemory: true does not by itself establish disk persistence. Vector-backed memory also requires an embedding provider and store; an in-memory index can still invoke a paid embedding API.

Preserve the ownership boundary

Your host verifies identity, binds sessions to owners, scopes backing stores, and decides which learnings may be shared. User IDs supplied by a request body are not trusted identity. A shared storage client does not automatically partition every record by tenant. For Teams, configure memory on each member Agent. TeamConfig.memory does not initialize member memory in v4. Member histories are distinct from an automatically shared Team transcript; see Team patterns.

More patterns

Use memory isolation for scope contracts, storage examples for persistence setup, correction patterns for reviewed learning, and recovery design for interrupted execution. Conversation persistence and task recovery solve different failures.