Examples
- Examples
- Getting Started
- Agents
- Teams
- Workflows
- Applications
- Streamlit Apps
- Evals
Agent Concepts
- Reasoning
- Multimodal
- RAG
- User Control Flows
- Knowledge
- Memory
- Built-in Memory
- Standalone Memory Operations
- Persistent Memory with SQLite
- Custom Memory Creation
- Memory Search
- Agent With Memory
- Agentic Memory
- Agent with Session Summaries
- Multiple Agents Sharing Memory
- Custom Memory
- Multi-User Multi-Session Chat
- Multi-User Multi-Session Chat Concurrent
- Memory References
- Session Summary References
- Mem0 Memory
- DB
- Async
- Hybrid Search
- Storage
- Tools
- Vector Databases
- Context
- Embedders
- Agent State
- Observability
- Miscellaneous
Models
- Anthropic
- AWS Bedrock
- AWS Bedrock Claude
- Azure AI Foundry
- Azure OpenAI
- Cerebras
- Cerebras OpenAI
- Cohere
- DeepInfra
- DeepSeek
- Fireworks
- Gemini
- Groq
- Hugging Face
- IBM
- LM Studio
- LiteLLM
- LiteLLM OpenAI
- Meta
- Mistral
- NVIDIA
- Ollama
- OpenAI
- Perplexity
- Together
- XAI
- Vercel
Memory
Built-in Memory
Code
cookbook/agent_concepts/memory/00_builtin_memory.py
from agno.agent import Agent
from agno.models.openai import OpenAIChat
from rich.pretty import pprint
agent = Agent(
model=OpenAIChat(id="gpt-4o"),
# Set add_history_to_messages=true to add the previous chat history to the messages sent to the Model.
add_history_to_messages=True,
# Number of historical responses to add to the messages.
num_history_responses=3,
description="You are a helpful assistant that always responds in a polite, upbeat and positive manner.",
)
# -*- Create a run
agent.print_response("Share a 2 sentence horror story", stream=True)
# -*- Print the messages in the memory
pprint(
[
m.model_dump(include={"role", "content"})
for m in agent.get_messages_for_session()
]
)
# -*- Ask a follow up question that continues the conversation
agent.print_response("What was my first message?", stream=True)
# -*- Print the messages in the memory
pprint(
[
m.model_dump(include={"role", "content"})
for m in agent.get_messages_for_session()
]
)
Usage
1
Create a virtual environment
Open the Terminal
and create a python virtual environment.
python3 -m venv .venv
source .venv/bin/activate
2
Install libraries
pip install -U agno
3
Run Example
python cookbook/agent_concepts/memory/00_builtin_memory.py
Was this page helpful?
Assistant
Responses are generated using AI and may contain mistakes.