# What is Memory? (/memory/overview)



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.

Install dependencies and set your key before running the examples:

```bash
pip install agno openai sqlalchemy
export OPENAI_API_KEY="your-api-key"
```

```python title="memory_agent.py"
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 [#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 [#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. Automatic extraction exposes add, update, and delete operations; it does not expose clearing all memories. In agentic mode, the default memory manager permits creating and updating memories. Configure `MemoryManager(delete_memories=True, clear_memories=True)` to allow agentic deletion and clearing. These manager flags do not restrict the automatic extraction path.

<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 [#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 [#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
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 [#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>
