Skip to content

memory agents #969

@MervinPraison

Description

@MervinPraison

@claude

memory agents

💡 Proposed PraisonAI Implementation

from praisonaiagents import Agent, Memory

Enable session summaries

memory = Memory(
provider="rag",
session_summary_config={
"enabled": True,
"update_after_n_turns": 5, # Summarize every 5 turns
"model": "gpt-4o-mini", # Model for summarization
"include_in_context": True # Add to agent context
}
)

agent = Agent(
name="Assistant",
memory=memory
)

Manual summary access

async def get_session_summary():
summary = await memory.get_session_summary()
print(f"Summary: {summary.text}")
print(f"Topics: {summary.topics}")

Automatic summary in responses

response = agent.run("Tell me about our conversation")

Response automatically includes session context

2. Agentic Memory

💡 Proposed PraisonAI Implementation

from praisonaiagents import Agent, Memory
from praisonaiagents.memory.tools import MemoryTools

Enable agentic memory management

memory = Memory(
provider="rag",
agentic_config={
"enabled": True,
"auto_classify": True, # Auto-detect important info
"confidence_threshold": 0.7,
"management_model": "gpt-4o"
}
)

Agent with memory management tools

agent = Agent(
name="MemoryAgent",
memory=memory,
tools=[MemoryTools()] # Provides memory CRUD operations
)

Memory tools available to agent:

- remember(fact): Store important information

- update_memory(id, new_fact): Update existing memory

- forget(id): Remove outdated information

- search_memories(query): Find relevant memories

Automatic memory management

response = agent.run("My favorite color is blue")

Agent autonomously decides to store this as a user preference

3. Memory References

💡 Proposed PraisonAI Implementation

from praisonaiagents import Agent, Memory

Enable memory references in responses

memory = Memory(
provider="rag",
reference_config={
"include_references": True,
"reference_format": "inline", # or "footnote", "metadata"
"max_references": 5,
"show_confidence": True
}
)

agent = Agent(
name="Assistant",
memory=memory
)

Automatic reference inclusion

response = agent.run("What did we discuss about my project?")

Response includes references

print(response.content)

"We discussed your ML project focusing on NLP [1],

specifically sentiment analysis [2]..."

print(response.references)

[

{"id": 1, "text": "User's ML project uses transformers", "confidence": 0.92},

{"id": 2, "text": "Project goal: sentiment analysis on reviews", "confidence": 0.88}

]

Custom reference handler

def format_with_references(response):
content = response.content
for ref in response.references:
content += f"\n[{ref.id}] {ref.text} (confidence: {ref.confidence})"
return content

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions