Use this file to discover all available pages before exploring further.
Memory allows agents to maintain conversation context across multiple messages within a session. This enables natural, contextual conversations where the agent remembers previous interactions.
For standalone memory operations (add, search, get, update, delete), see the Cognis documentation.
from lyzr import Studiostudio = Studio(api_key="your-api-key")# Create agent with memoryagent = studio.create_agent( name="Conversational Bot", provider="gpt-4o", role="Helpful assistant", goal="Have natural conversations", instructions="Remember context from previous messages", memory=30 # Remember last 30 messages)# Start a conversationsession_id = "user_123_session"agent.run("My name is Alice", session_id=session_id)agent.run("I'm interested in Python programming", session_id=session_id)response = agent.run("What's my name and what am I interested in?", session_id=session_id)# Agent remembers: "Your name is Alice and you're interested in Python programming"
Memory is scoped to sessions. Use session_id to maintain separate conversations:
# User 1's conversationagent.run("Hello", session_id="user_1_session")agent.run("My name is Bob", session_id="user_1_session")# User 2's conversation (separate context)agent.run("Hello", session_id="user_2_session")agent.run("My name is Carol", session_id="user_2_session")# Each session has its own memory
agent = studio.create_agent( name="Research Assistant", provider="gpt-4o", role="Research assistant", memory=50)session = "research_session"agent.run("Let's research climate change", session_id=session)agent.run("Focus on renewable energy solutions", session_id=session)agent.run("What are the key findings?", session_id=session)
agent = studio.create_agent( name="Math Tutor", provider="gpt-4o", role="Math tutor", memory=30)session = "lesson_1"agent.run("I'm learning algebra", session_id=session)agent.run("I struggle with quadratic equations", session_id=session)agent.run("Can you give me a practice problem?", session_id=session)# Tutor remembers: algebra, struggles with quadratics