You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: agents/memory.mdx
+10-8Lines changed: 10 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,18 +2,22 @@
2
2
title: Memory
3
3
---
4
4
5
-
Memory is an Agent's ability to recall relavant information to provide the best, most personalized response. If the user tells the Agent they like to ski, then future responses can reference this information to provide a more personalized experience.
5
+
Memory gives an Agent the ability to recall relavant information. Memory is a part of the Agent's context that helps it provide the best, most personalized response.
6
+
7
+
<Check>
8
+
If the user tells the Agent they like to ski, then future responses can reference this information to provide a more personalized experience.
9
+
</Check>
6
10
7
11
In Agno, Memory covers chat history, user preferences and any supplemental information about the task at hand. **Agno supports 3 types of memory out of the box:**
8
12
9
-
1.**Session Storage:** Session storage saves an Agent's sessions in a database and enables Agents to have multi-turn conversations. Session storage also holds the session state, which is persisted across runs because it is saved to the database after each run. Session storage is a form of short-term memory **called "Storage" in Agno**.
13
+
1.**Session Storage (chat history and session state):** Session storage saves an Agent's sessions in a database and enables Agents to have multi-turn conversations. Session storage also holds the session state, which is persisted across runs because it is saved to the database after each run. Session storage is a form of short-term memory **called "Storage" in Agno**.
10
14
11
-
2.**User Memories:** The Agent can store insights and facts about the user that it learns through conversation. This helps the agents personalize its response to the user it is interacting with. Think of this as adding "ChatGPT like memory" to your agent. **This is called "Memory" in Agno**.
15
+
2.**User Memories (user preferences):** The Agent can store insights and facts about the user that it learns through conversation. This helps the agents personalize its response to the user it is interacting with. Think of this as adding "ChatGPT like memory" to your agent. **This is called "Memory" in Agno**.
12
16
13
-
3.**Session Summaries:** The Agent can store a condensed representations of the session, useful when chat histories gets too long. **This is called "Summary" in Agno**.
17
+
3.**Session Summaries (chat summary):** The Agent can store a condensed representations of the session, useful when chat histories gets too long. **This is called "Summary" in Agno**.
14
18
15
19
<Note>
16
-
It is also relatively easy to use your own memory implementation using `Agent.context`.
20
+
It is relatively easy to use your own memory implementation using `Agent.context`.
17
21
</Note>
18
22
19
23
To become an expert in Agentic Memory, you need ot learn about:
@@ -22,9 +26,7 @@ To become an expert in Agentic Memory, you need ot learn about:
Copy file name to clipboardExpand all lines: memory/introduction.mdx
+8-340Lines changed: 8 additions & 340 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,350 +4,18 @@ title: Introduction
4
4
5
5
# Memory for Agents
6
6
7
-
Memory is an Agent's ability to recall relavant information to provide the best, most personalized response. If the user tells the Agent they like to ski, then future responses can reference this information to provide a more personalized experience.
7
+
Memory gives an Agent the ability to recall relavant information. Memory is a part of the Agent's context that helps it provide the best, most personalized response.
8
8
9
-
In Agno, Memory covers chat history, user preferences and any supplemental information about the task at hand. **Agno supports 3 types of memory out of the box:**
9
+
<Check>
10
+
If the user tells the Agent they like to ski, then future responses can reference this information to provide a more personalized experience.
11
+
</Check>
10
12
11
-
1.**Session Storage:** Session storage saves an Agent's sessions in a database and enables Agents to have multi-turn conversations. Session storage also holds the session state, which is persisted across runs because it is saved to the database after each run. Session storage is a form of short-term memory **called "Storage" in Agno**.
13
+
1.**Session Storage (chat history and session state):** Session storage saves an Agent's sessions in a database and enables Agents to have multi-turn conversations. Session storage also holds the session state, which is persisted across runs because it is saved to the database after each run. Session storage is a form of short-term memory **called "Storage" in Agno**.
12
14
13
-
2.**User Memories:** The Agent can store insights and facts about the user that it learns through conversation. This helps the agents personalize its response to the user it is interacting with. Think of this as adding "ChatGPT like memory" to your agent. **This is called "Memory" in Agno**.
15
+
2.**User Memories (user preferences):** The Agent can store insights and facts about the user that it learns through conversation. This helps the agents personalize its response to the user it is interacting with. Think of this as adding "ChatGPT like memory" to your agent. **This is called "Memory" in Agno**.
14
16
15
-
3.**Session Summaries:** The Agent can store a condensed representations of the session, useful when chat histories gets too long. **This is called "Summary" in Agno**.
17
+
3.**Session Summaries (chat summary):** The Agent can store a condensed representations of the session, useful when chat histories gets too long. **This is called "Summary" in Agno**.
16
18
17
19
<Note>
18
-
If you haven't, we recommend reading the Memory section of the [Agents](/agents/memory) to get familiar with the basics.
20
+
If you haven't, we also recommend reading the Memory section of the [Agents](/agents/memory) to get familiar with the basics.
19
21
</Note>
20
-
21
-
## Managing User Memory
22
-
23
-
When we speak about Memory, the commonly agreed upon understanding of Memory is the ability to store insights and facts about the user the Agent is interacting with. In short, build a persona of the user, learn about their preferences and use that to personalize the Agent's response.
24
-
25
-
### Agentic Memory
26
-
27
-
Agno Agents natively support Agentic Memory Management and recommends it as the starting point for your memory journey.
28
-
29
-
With Agentic Memory, The Agent itself creates, updates and deletes memories from user conversations.
30
-
31
-
Set `enable_agentic_memory=True` to give the Agent a tool to manage memories of the user, this tool passes the task to the `MemoryManager` class.
32
-
33
-
> You may also set `enable_user_memories=True` which always runs the `MemoryManager` after each user message. [See below for an example.](#create-memories-after-each-run)
34
-
35
-
```python agentic_memory.py
36
-
from agno.agent import Agent
37
-
from agno.memory.v2.db.sqlite import SqliteMemoryDb
-`add_history_to_messages=True` adds the chat history to the messages sent to the Model, the `num_history_runs` determines how many runs to add.
83
-
-`read_chat_history=True` adds a tool to the Agent that allows it to read chat history, as it may be larger than what's included in the `num_history_runs`.
84
-
85
-
### Create Memories after each run
86
-
87
-
While `enable_agentic_memory=True` gives the Agent a tool to manage memories of the user, we can also always "trigger" the `MemoryManagement` after each user message.
88
-
89
-
Set `enable_user_memories=True` which always process memories after each user message.
90
-
91
-
```python create_memories_after_each_run.py
92
-
from agno.agent.agent import Agent
93
-
from agno.memory.v2.db.sqlite import SqliteMemoryDb
Agentic search allows you to find memories based on meaning rather than exact keyword matches. This is particularly useful for retrieving contextually relevant information:
315
-
316
-
```python
317
-
from agno.memory.v2.memory import Memory, UserMemory
318
-
from agno.models.google.gemini import Gemini
319
-
320
-
# Initialize memory with a model for agentic search
memory=UserMemory(memory="The user enjoys hiking in the mountains on weekends"),
327
-
user_id=john_doe_id,
328
-
)
329
-
memory.add_user_memory(
330
-
memory=UserMemory(
331
-
memory="The user enjoys reading science fiction novels before bed"
332
-
),
333
-
user_id=john_doe_id,
334
-
)
335
-
336
-
# Search for memories related to the query
337
-
memories = memory.search_user_memories(
338
-
user_id=john_doe_id,
339
-
query="What does the user like to do on weekends?",
340
-
retrieval_method="agentic",
341
-
)
342
-
print("John Doe's found memories:")
343
-
for i, m inenumerate(memories):
344
-
print(f"{i}: {m.memory}")
345
-
```
346
-
347
-
With agentic search, the model understands the intent behind your query and returns the most relevant memories, even if they don't contain the exact keywords from your search.
348
-
349
-
350
-
## Developer Resources
351
-
352
-
- Find full examples in the [Cookbook](https://github.com/agno-agi/agno/tree/main/cookbook/agent_concepts/memory)
353
-
- View the class reference for the `Memory` class [here](/reference/memory/memory)
0 commit comments