This example demonstrates how to use in-memory session management with teams to maintain conversation context and history without requiring a persistent database.
from agno.agent import Agentfrom agno.models.openai import OpenAIChatfrom agno.team import Teamfrom rich.pretty import pprintagent = Agent( model=OpenAIChat(id="gpt-5-mini"),)team = Team( model=OpenAIChat(id="gpt-5-mini"), members=[agent],)# -*- Create a runteam.print_response("Share a 2 sentence horror story", stream=True)# -*- Print the messages in the memorypprint( [ m.model_dump(include={"role", "content"}) for m in agent.get_messages_for_session() ])# -*- Ask a follow up question that continues the conversationteam.print_response("What was my first message?", stream=True)# -*- Print the messages in the memorypprint( [ m.model_dump(include={"role", "content"}) for m in agent.get_messages_for_session() ])