> ## Documentation Index
> Fetch the complete documentation index at: https://agno-v2-docs-scavio-google-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 support agents, product copilots, 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 inspect, create, update, or delete memories during a run |

Automatic memory applies one consistent extraction step during each run. Agentic memory adds memory tools to the agent's toolset and lets the model choose when to call them.

<Note>
  When both settings are enabled, agentic memory takes precedence and the automatic extraction step is skipped. Choose one mode for each agent.
</Note>

## 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](/history/overview) | Messages and tool calls from previous runs | `session_id`              | Conversational continuity within one thread    |
| [Session state](/state/overview)  | 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`. Set `memory_table` on the database when your application needs a custom name.

```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

<CardGroup cols={3}>
  <Card title="Agent Memory" icon="robot" iconType="duotone" href="/memory/agent/overview">
    Configure memory for a single agent.
  </Card>

  <Card title="Team Memory" icon="users" iconType="duotone" href="/memory/team/overview">
    Share user memories with a team and its members.
  </Card>

  <Card title="Working with Memories" icon="file-lines" iconType="duotone" href="/memory/working-with-memories/overview">
    Customize memory creation, retrieval, and storage.
  </Card>

  <Card title="Production Best Practices" icon="shield-check" iconType="duotone" href="/memory/best-practices">
    Plan user isolation, retention, and memory quality checks.
  </Card>
</CardGroup>
