> ## Documentation Index
> Fetch the complete documentation index at: https://agno-v2.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# What is Memory?

> Store facts about each user and recall them in later conversations.

Customer-facing agents and personal assistants often serve the same user across many conversations. Memory keeps facts such as preferences, responsibilities, and recurring goals available across those conversations.

```python memory_agent.py theme={null}
from agno.agent import Agent
from agno.db.sqlite import SqliteDb
from agno.models.openai import OpenAIResponses

agent = Agent(
    model=OpenAIResponses(id="gpt-5.4-mini"),
    db=SqliteDb(db_file="tmp/memory.db"),
    update_memory_on_run=True,
)

agent.print_response(
    "I prefer email updates and morning meetings.",
    user_id="sarah",
    session_id="onboarding",
)

agent.print_response(
    "How should you schedule and send my project updates?",
    user_id="sarah",
    session_id="project-planning",
)
```

The first run stores useful facts for `sarah`. The second run uses the same `user_id`, so the agent can recall those facts in a different session.

## How Memory Works

1. `user_id` identifies whose memories should be loaded.
2. The configured database stores each user's memory records.
3. Stored memories for that user are added to the model context for later runs.
4. The selected memory mode controls when records are created, updated, or deleted.

Use a stable application user ID for every run that should share the same memories.

## Choose a Memory Mode

| Mode | Configuration | Use it when |
| - | - | - |
| Automatic | `update_memory_on_run=True` | Each user input should be processed into memories automatically |
| Agentic | `enable_agentic_memory=True` | The model should decide when to create or update memories during a run |

Automatic memory applies one consistent extraction step during each run. Agentic memory adds an `update_user_memory` tool and lets the model choose when to call it. Existing memories are loaded into the model context. The default memory manager permits creating and updating memories. Configure `MemoryManager(delete_memories=True, clear_memories=True)` when the agent should also delete individual memories or clear them.

> [!NOTE]
>
> When both settings are enabled, agentic memory takes precedence and the automatic extraction step is skipped. Choose one mode for each agent.

## Memory, History, and State

| Feature | Stores | Scope | Use it for |
| - | - | - | - |
| Memory | Extracted facts about a user | `user_id` across sessions | Preferences, profile details, recurring goals |
| [Chat history](https://agno-v2.mintlify.site/history/overview.md) | Messages and tool calls from previous runs | `session_id` | Conversational continuity within one thread |
| [Session state](https://agno-v2.mintlify.site/state/overview.md) | Application data managed by code or tools | `session_id` | Carts, task lists, workflow progress, counters |

These features can work together. A support agent can use memory for the customer's communication preference, history for the current ticket, and state for the ticket status.

## Store and Inspect Memories

Memories use the database configured on the agent. The default table or collection name is `agno_memories`.

| Database backend | Custom-name parameter |
| - | - |
| SQL and other table-backed databases | `memory_table` |
| MongoDB and Firestore | `memory_collection` |

```python theme={null}
memories = agent.get_user_memories(user_id="sarah")

for memory in memories or []:
    print(memory.memory_id, memory.memory)
```

Manual retrieval is useful for customer profile screens, debugging, review, and deletion workflows. You can also [manage memories in the AgentOS UI](https://os.agno.com/memory).

## Next Steps

> **[Agent Memory](https://agno-v2.mintlify.site/memory/agent/overview.md)**
>
> Configure memory for a single agent.

> **[Team Memory](https://agno-v2.mintlify.site/memory/team/overview.md)**
>
> Share user memories with a team and its members.

> **[Working with Memories](https://agno-v2.mintlify.site/memory/working-with-memories/overview.md)**
>
> Customize memory creation, retrieval, and storage.

> **[Production Best Practices](https://agno-v2.mintlify.site/memory/best-practices.md)**
>
> Plan user isolation, retention, and memory quality checks.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.