Memory
Agentic Memory Creation
Examples
- Introduction
- Getting Started
- Agents
- Teams
- Workflows
- Applications
Agent Concepts
- Multimodal
- RAG
- Knowledge
- Memory
- Basic Memory Operations
- Persistent Memory with SQLite
- Agentic Memory Creation
- Basic Memory Search
- Agentic Memory Search
- Agent Memory Creation
- Agent Memory Management
- Agent with Session Summaries
- Multiple Agents Sharing Memory
- Multi-User Multi-Session Chat
- MongoDB Memory Storage
- PostgreSQL Memory Storage
- Redis Memory Storage
- Mem0 Memory
- Async
- Hybrid Search
- Storage
- Tools
- Vector Databases
- Embedders
Models
- Anthropic
- AWS Bedrock
- AWS Bedrock Claude
- Azure AI Foundry
- Azure OpenAI
- Cohere
- DeepInfra
- DeepSeek
- Fireworks
- Gemini
- Groq
- Hugging Face
- Mistral
- NVIDIA
- Ollama
- OpenAI
- Perplexity
- Together
- xAI
- IBM
- LM Studio
- LiteLLM
- LiteLLM OpenAI
Memory
Agentic Memory Creation
Code
cookbook/agent_concepts/memory/03_agentic_memory.py
from agno.memory.v2 import Memory
from agno.memory.v2.db.sqlite import SqliteMemoryDb
from agno.models.google import Gemini
from agno.models.message import Message
memory_db = SqliteMemoryDb(table_name="memory", db_file="tmp/memory.db")
# Reset for this example
memory_db.clear()
memory = Memory(model=Gemini(id="gemini-2.0-flash-exp"), db=memory_db)
john_doe_id = "john_doe@example.com"
memory.create_user_memories(
message="""
I enjoy hiking in the mountains on weekends,
reading science fiction novels before bed,
cooking new recipes from different cultures,
playing chess with friends,
and attending live music concerts whenever possible.
Photography has become a recent passion of mine, especially capturing landscapes and street scenes.
I also like to meditate in the mornings and practice yoga to stay centered.
""",
user_id=john_doe_id,
)
memories = memory.get_user_memories(user_id=john_doe_id)
print("John Doe's memories:")
for i, m in enumerate(memories):
print(f"{i}: {m.memory} - {m.topics}")
jane_doe_id = "jane_doe@example.com"
# Send a history of messages and add memories
memory.create_user_memories(
messages=[
Message(role="user", content="My name is Jane Doe"),
Message(role="assistant", content="That is great!"),
Message(role="user", content="I like to play chess"),
Message(role="assistant", content="That is great!"),
],
user_id=jane_doe_id,
)
memories = memory.get_user_memories(user_id=jane_doe_id)
print("Jane Doe's memories:")
for i, m in enumerate(memories):
print(f"{i}: {m.memory} - {m.topics}")
Usage
1
Create a virtual environment
Open the Terminal
and create a python virtual environment.
python3 -m venv .venv
source .venv/bin/activate
2
Set your API key
export GOOGLE_API_KEY=xxx
3
Install libraries
pip install -U agno google-generativeai
4
Run Example
python cookbook/agent_concepts/memory/03_agentic_memory.py