Skip to content

Commit a23af3a

Browse files
aayush3011Aayush Kataria
andauthored
Consolidate to CosmosMemoryClient, Add Tests, Samples & CI (#3)
* Adding Samples, e2e tests and removing some redundant code * Fixing builds * Adding codeowners file --------- Co-authored-by: Aayush Kataria <aayushkataria@Aayushs-MacBook-Pro-2.local>
1 parent 4dea57d commit a23af3a

40 files changed

Lines changed: 10455 additions & 3087 deletions

.github/CODEOWNERS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# These owners are required reviewers for all changes
2+
@akataria @jcodella @TheovanKraay

README.md

Lines changed: 30 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,22 @@
88
[![YouTube](https://img.shields.io/badge/YouTube-Azure%20Cosmos%20DB-FF0000?logo=youtube&logoColor=white)](https://www.youtube.com/@AzureCosmosDB)
99

1010

11-
Agent Memory Toolkit is a Python library and Azure-backed reference implementation for storing, retrieving, and transforming agent memories over time. It combines a simple SDK for local and Cosmos DB operations with Durable Functions pipelines that generate thread summaries, extract facts, and build cross-thread user profiles. The toolkit is designed for agent applications that need both raw conversation history and higher-value derived memory that can be searched semantically later. It provides matching sync (`AgentMemory`) and async (`AsyncAgentMemory`) APIs so the same memory model can be used in scripts, services, notebooks, and larger agent systems.
11+
Agent Memory Toolkit is a Python library and Azure-backed reference implementation for storing, retrieving, and transforming agent memories over time. It combines a simple SDK for local and Cosmos DB operations with Durable Functions pipelines that generate thread summaries, extract facts, and build cross-thread user profiles. The toolkit is designed for agent applications that need both raw conversation history and higher-value derived memory that can be searched semantically later. It provides matching sync (`CosmosMemoryClient`) and async (`AsyncCosmosMemoryClient`) APIs so the same memory model can be used in scripts, services, notebooks, and larger agent systems.
1212

1313
```
14-
┌────────────────────────────────────────────────────────────────────────────┐
15-
│ YOUR AGENTIC APP │
16-
│ Uses AgentMemory / AsyncAgentMemory
17-
└───────────────────────────────────────────────────────────────────────────┘
18-
19-
20-
┌────────────────────────────────────────────────────────────────────────────┐
21-
│ AGENT MEMORY TOOLKIT (Python SDK) │
22-
│ │
23-
│ • Local in-memory CRUD │
24-
│ • Cosmos DB storage and retrieval │
25-
│ • Calls into Azure Durable Functions for memory processing │
26-
└──────────────────────────────────────────────────────────────────────────┘
14+
┌──────────────────────────────────────────────────────────────────────────────────────
15+
YOUR AGENTIC APP
16+
Uses CosmosMemoryClient / AsyncCosmosMemoryClient
17+
└─────────────────────────────────────────┬────────────────────────────────────────────┘
18+
19+
20+
┌──────────────────────────────────────────────────────────────────────────────────────
21+
AGENT MEMORY TOOLKIT (Python SDK)
22+
23+
│ • Local in-memory CRUD
24+
│ • Cosmos DB storage and retrieval
25+
│ • Calls into Azure Durable Functions for memory processing
26+
└────────────────────────────────────────────────────────────────────────┬────────────┘
2727
│ │
2828
│ read / write │ Invoke processing pipeline
2929
▼ ▼
@@ -72,23 +72,22 @@ Agent Memory Toolkit is a Python library and Azure-backed reference implementati
7272

7373
```
7474
agent_memory_toolkit/ Python library — sync API
75-
memory.py AgentMemory orchestrator
76-
cosmos_memory_client.py CosmosMemoryStore — Cosmos DB CRUD + vector search
77-
embeddings.py EmbeddingsClient — Azure OpenAI embeddings
78-
processing.py ProcessingClient — Durable Functions polling
75+
cosmos_memory_client.py CosmosMemoryClient — local CRUD, Cosmos DB, embeddings, processing
76+
embeddings.py EmbeddingsClient — Azure OpenAI embeddings (internal)
77+
processing.py ProcessingClient — Durable Functions polling (internal)
7978
models.py Pydantic data models (MemoryRecord, enums)
8079
exceptions.py Custom exception hierarchy
8180
_query_builder.py Shared query builder (private)
81+
_utils.py Shared helpers (private)
8282
aio/ Async API (mirrors azure.cosmos.aio convention)
83-
memory.py AsyncAgentMemory
84-
cosmos_memory_client.py AsyncCosmosMemoryStore
85-
embeddings.py AsyncEmbeddingsClient
86-
processing.py AsyncProcessingClient
83+
cosmos_memory_client.py AsyncCosmosMemoryClient
84+
embeddings.py AsyncEmbeddingsClient (internal)
85+
processing.py AsyncProcessingClient (internal)
8786
azure_functions/ Durable Functions — orchestrator, activities, HTTP trigger
8887
prompts/ LLM system prompts — summarize, facts, user_summary + update variants
89-
Samples/ Demo notebooks — sync (Demo.ipynb) + async (Demo_async.ipynb)
88+
Samples/ Demo notebooks + sample scripts
9089
Docs/ Documentation — concepts, local testing, Azure deployment
91-
tests/ Unit tests (pytest) — 184 tests, 87% coverage
90+
tests/ Unit + integration tests (pytest)
9291
```
9392

9493
---
@@ -108,9 +107,9 @@ pip install ".[dev]"
108107

109108
```python
110109
import uuid
111-
from agent_memory_toolkit import AgentMemory
110+
from agent_memory_toolkit import CosmosMemoryClient
112111

113-
memory = AgentMemory(use_default_credential=False)
112+
memory = CosmosMemoryClient(use_default_credential=False)
114113
thread_id = str(uuid.uuid4())
115114
memory.add_local(user_id="user-001", role="user", thread_id=thread_id, content="Hello world")
116115
print(memory.get_local())
@@ -126,11 +125,11 @@ cp .env.template .env # fill in endpoint values
126125
import os, uuid
127126
from dotenv import load_dotenv
128127
from azure.identity import DefaultAzureCredential
129-
from agent_memory_toolkit import AgentMemory
128+
from agent_memory_toolkit import CosmosMemoryClient
130129

131130
load_dotenv()
132131

133-
memory = AgentMemory(
132+
memory = CosmosMemoryClient(
134133
cosmos_endpoint=os.getenv("COSMOS_DB_ENDPOINT"),
135134
cosmos_database=os.getenv("COSMOS_DB_DATABASE"),
136135
cosmos_container=os.getenv("COSMOS_DB_CONTAINER"),
@@ -141,8 +140,7 @@ memory = AgentMemory(
141140
use_default_credential=True,
142141
cosmos_credential=DefaultAzureCredential(),
143142
)
144-
memory.create_memory_store()
145-
memory.connect_cosmos()
143+
# Constructor auto-creates the database and container if they don't exist.
146144

147145
# Add directly to Cosmos
148146
thread_id = str(uuid.uuid4())
@@ -172,10 +170,10 @@ result = memory.generate_user_summary(user_id="user-001")
172170
summary = memory.get_user_summary(user_id="user-001")
173171
```
174172

175-
> The async API (`AsyncAgentMemory`) is identical — just `await` each call. Import from the `aio` subpackage:
173+
> The async API (`AsyncCosmosMemoryClient`) is identical — just `await` each call. Import from the `aio` subpackage:
176174
>
177175
> ```python
178-
> from agent_memory_toolkit.aio import AsyncAgentMemory
176+
> from agent_memory_toolkit.aio import AsyncCosmosMemoryClient
179177
> ```
180178
181179
---

0 commit comments

Comments
 (0)