Memory enables AI agents to remember past interactions, maintain context, and provide more coherent responses over time. Without memory, agents would treat each interaction as if it was their first.
In the PraisonAI framework, memory is handled automatically for basic cases and can be customized for more advanced needs:
Copy
from praisonaiagents import Agent# Basic agent with default memory handlingagent = Agent( instructions="You are a helpful assistant that remembers our conversations")# The conversation history is maintained automaticallyagent.start("My name is Alex")agent.continue("What's my name?")# Note: TODO: This Feature yet to be developed # Agent will remember "Alex"
For more advanced applications, you can implement custom memory systems:
Copy
# Note: TODO: This Feature yet to be testedfrom praisonaiagents import Agent, Memory# Create a simple memory storememory = Memory()# Add information to memorymemory.add("user_name", "Alex")memory.add("favorite_color", "blue")# Create agent with this memoryagent = Agent( instructions="You are a personal assistant", memory=memory)# The agent can now access these memoriesagent.start("What's my favorite color?") # Agent should respond "blue"