AgentMemory Package
Description
AgentMemory is a Python package for managing agent memory structures in AI applications. It provides a flexible data model for long-term and short-term memory and supports storing and managing:
- Persona: Information and properties of an agent.
- Conversation: Conversations between agents and users.
- ConversationItems: Individual messages or actions within a conversation.
- Workflows: Workflows executed by agents.
- WorkflowSteps: Individual steps within a workflow.
Additionally, a cache system is provided for fast access and temporary storage.
Installation
Install the package using pip or uv:
pip install agentmemory-py
# or
uv add agentmemory-py
Quickstart
Create a Memory Object
from agentmemory import AgentMemory
from agentmemory.connection import AgentMemoryConnection
from agentmemory.connection.longterm import MongoDBConnection
from agentmemory.connection.shortterm import RedisConnection
con = AgentMemoryConnection(
longterm_con=MongoDBConnection(
mongo_uri="mongodb://localhost:27017",
database="support-agentmemory"
),
shortterm_con=RedisConnection(
host="localhost"
)
)
memory = AgentMemory("support-agentmemory", con=con)
Manage Conversations
Create a New Conversation
from agentmemory.schema.conversations import Conversation
conversation = Conversation(
title="New Conversation",
)
created_conversation = memory.conversations.create(conversation)
print(created_conversation)
List Conversations
# Get all conversations
conversations = memory.conversations.list()
# Get only 5 conversations
conversations = memory.conversations.list(limit=5)
# Filter by title
conversations = memory.conversations.list(query={"title": "title1"})
Retrieve and Update a Conversation
id = "<ID>"
conversation = memory.conversations.get(id)
conversation.title = "Updated Title"
memory.conversations.update(conversation)
Delete a Conversation
id = "<ID>"
memory.conversations.delete(id)
Manage ConversationItems
from agentmemory.schema.conversations import ConversationItem
item = ConversationItem(
conversation_id="<CONVERSATION_ID>",
role="system",
content="Hello, how can I help?",
data={
"custom": "data"
}
)
created_item = memory.conversation_items.create(item)
print(created_item)
# Get items of a conversation
items = memory.conversation_items.list_by_conversation_id("<CONVERSATION_ID>")
Manage Personas
from agentmemory.schema.personas import Persona
persona = Persona(
name="<NAME>",
role="<ROLE>",
goals="<GOALS>",
background="<BACKGROUND>",
data={
"custom": "data"
}
)
created_persona = memory.personas.create(persona)
print(created_persona)
# Retrieve persona by name
persona = memory.personas.get_by_name("<NAME>")
Manage Workflows and WorkflowSteps
from agentmemory.schema.workflows import Workflow, WorkflowStep, WorkflowStatus
workflow = Workflow(
conversation_item_id="<CONVERSATION_ITEM_ID>",
user_query="<USER_QUERY>",
status=WorkflowStatus.RUNNING,
data={
"custom": "data"
}
)
created_workflow = memory.workflows.create(workflow)
print(created_workflow)
step = WorkflowStep(
workflow_id=created_workflow.workflow_id,
name="<NAME>",
tool="<TOOL_NAME>",
arguments={
"arg1": "value1"
},
status=WorkflowStatus.SUCCESS,
result="<RESULT>",
logs=[],
data={
"custom": "data"
}
)
created_step = memory.workflow_steps.create(step)
print(created_step)
Custom Caching
The integrated cache system enables fast access to frequently used data.
memory.cache.keys("*") # List all keys
memory.cache.get("<KEY>") # Get value
memory.cache.set("<KEY>", {"key": "value"}) # Set value
memory.cache.clear("<PATTERN>") # Clear cache by pattern
Tests
To run the tests:
uv run pytest
License
MIT License. See LICENSE for details.
Release files for agentmemory-py 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| agentmemory_py-0.1.0.tar.gz | 45.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| agentmemory_py-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 68.7 kB
Release files / agentmemory_py-0.1.0.tar.gz
| Download URL | agentmemory_py-0.1.0.tar.gz |
|---|---|
| Size | 45.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bd97c610fdbafc50685c5cc1f74f78d45320a7e0d751de4ab2a5b9ba06db86ee
|
|
BLAKE2b-256 checksum How to use checksums |
389e743bdd9b1bfd866a45e3b2b1746c94811809494fdf4936a5f10093e05f77
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 22, 2025.
Transparency logRelease files / agentmemory_py-0.1.0-py3-none-any.whl
| Download URL | agentmemory_py-0.1.0-py3-none-any.whl |
|---|---|
| Size | 23.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9f196bd47ea3ed538a810a538f50181538727d81f04d7991e2ea2ed1a6506315
|
|
BLAKE2b-256 checksum How to use checksums |
aa9735c3ebe490a2205c6f9f335876e7836b367994a58bc0df4be7cf1d33aa39
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 22, 2025.
Transparency log