Skip to content

Commit 57947d2

Browse files
committed
small changes, new troubleshooting doc, and overview infographic
1 parent 2533cd7 commit 57947d2

5 files changed

Lines changed: 574 additions & 2553 deletions

File tree

Docs/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,12 @@ This folder contains the main project documentation for Agent Memory Toolkit.
1010
| [local_testing.md](local_testing.md) | Covers local setup, environment configuration, RBAC, Cosmos provisioning, running the toolkit and Azure Functions locally, and testing change feed auto-processing with serverless or autoscale container provisioning. |
1111
| [azure_testing.md](azure_testing.md) | Covers Azure deployment, cloud configuration, required services, change feed settings, throughput mode configuration, and validation steps for running the toolkit in Azure. |
1212
| [design_patterns.md](design_patterns.md) | Shows when and how to call CRUD operations, summarization, fact extraction, and memory retrieval in chat and multi-agent applications, including automatic processing via the change feed. |
13+
| [troubleshooting.md](troubleshooting.md) | Helps diagnose common setup, authentication, Cosmos DB, embeddings, Durable Functions, vector search, and change feed issues. |
1314

1415
## Recommended Reading Order
1516

1617
1. Start with [concepts.md](concepts.md) to understand the data model and memory lifecycle.
1718
2. Use [local_testing.md](local_testing.md) to get the toolkit running and validated on your machine.
1819
3. Use [azure_testing.md](azure_testing.md) when you are ready to deploy or validate the full stack in Azure.
19-
4. See [design_patterns.md](design_patterns.md) for integration patterns in real applications.
20+
4. See [design_patterns.md](design_patterns.md) for integration patterns in real applications.
21+
5. Use [troubleshooting.md](troubleshooting.md) when setup, processing, search, or automatic change feed behavior does not work as expected.

Docs/troubleshooting.md

Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
# Troubleshooting Agent Memory Toolkit
2+
3+
Use this guide when local memory works but Cosmos DB, embeddings, Durable Functions, or automatic change feed processing does not.
4+
5+
---
6+
7+
## Quick Triage
8+
9+
| Symptom | First checks |
10+
|---------|--------------|
11+
| Import errors | Install with `pip install -e ".[dev]"` and import `CosmosMemoryClient` or `AsyncCosmosMemoryClient`. |
12+
| Missing configuration | Verify `.env`, `azure_functions/local.settings.json`, and Azure Function App settings use the same endpoint, database, and container values. |
13+
| Cosmos 401 or 403 | Run `az login` and confirm Cosmos DB data-plane RBAC is assigned. |
14+
| Cosmos operations fail before connecting | Call `create_memory_store()` or `connect_cosmos()` before cloud operations. |
15+
| Search returns no vector results | Confirm embeddings are generated and `EMBEDDING_DIMENSIONS` matches the container vector policy. |
16+
| Durable Function calls fail | Start the Functions host and check `ADF_ENDPOINT`, `ADF_KEY`, and the orchestrator route. |
17+
| Change feed does not create summaries or facts | Confirm change feed settings, thresholds, lease container, counter container, and that inserted documents have `type: "turn"`. |
18+
19+
---
20+
21+
## 1. Environment And Imports
22+
23+
Install the package from the repository root:
24+
25+
```bash
26+
pip install -e ".[dev]"
27+
pip install -r azure_functions/requirements.txt
28+
```
29+
30+
The public clients are:
31+
32+
```python
33+
from agent_memory_toolkit import CosmosMemoryClient
34+
from agent_memory_toolkit.aio import AsyncCosmosMemoryClient
35+
```
36+
37+
If notebooks cannot import the package, run them from the `Samples` folder or add the repository root to `sys.path`.
38+
39+
---
40+
41+
## 2. Configuration And Authentication
42+
43+
For local runs, keep `.env` and `azure_functions/local.settings.json` aligned:
44+
45+
```env
46+
COSMOS_DB_ENDPOINT=https://<account>.documents.azure.com:443/
47+
COSMOS_DB_DATABASE=ai_memory
48+
COSMOS_DB_CONTAINER=memories
49+
COSMOS_DB_COUNTERS_CONTAINER=counter
50+
COSMOS_DB_LEASE_CONTAINER=leases
51+
AI_FOUNDRY_ENDPOINT=https://<project>.services.ai.azure.com/
52+
EMBEDDING_MODEL=text-embedding-3-large
53+
EMBEDDING_DIMENSIONS=1536
54+
ADF_ENDPOINT=http://localhost:7071/api
55+
ADF_KEY=
56+
```
57+
58+
Run `az login` before using `DefaultAzureCredential`.
59+
60+
Required roles:
61+
62+
| Service | Role |
63+
|---------|------|
64+
| Cosmos DB | Cosmos DB Built-in Data Contributor |
65+
| Azure OpenAI / AI Services | Cognitive Services OpenAI User |
66+
67+
RBAC changes can take several minutes to propagate.
68+
69+
---
70+
71+
## 3. Cosmos DB Store Creation
72+
73+
Run `create_memory_store()` before relying on cloud operations. It creates the database plus the `memories`, `counter`, and `leases` containers.
74+
75+
The memories container is created with:
76+
77+
- hierarchical partition key on `user_id` and `thread_id`
78+
- vector index on `/embedding`
79+
- full-text index on `/content`
80+
81+
If vector or full-text search fails after changing dimensions or indexing settings, create a fresh container with the desired configuration. Cosmos container vector policies are creation-time infrastructure choices.
82+
83+
Use `COSMOS_DB_THROUGHPUT_MODE=serverless` for the default setup. Use `autoscale` with `COSMOS_DB_AUTOSCALE_MAX_RU` when you need provisioned autoscale throughput.
84+
85+
---
86+
87+
## 4. Embeddings And Search
88+
89+
Embedding failures usually mean one of these is wrong:
90+
91+
- `AI_FOUNDRY_ENDPOINT`
92+
- `EMBEDDING_MODEL`
93+
- `EMBEDDING_DIMENSIONS`
94+
- Azure OpenAI / AI Services RBAC
95+
96+
For hybrid search, `search_terms` is required when `hybrid_search=True`.
97+
98+
If search returns documents but scores look poor, check that records have an `embedding` field and that the query uses similar language to the stored memory content.
99+
100+
---
101+
102+
## 5. Durable Functions Processing
103+
104+
Thread summaries, fact extraction, and user summaries require the Functions host.
105+
106+
Start local dependencies:
107+
108+
```bash
109+
azurite --silent --location /tmp/azurite --debug /tmp/azurite/debug.log
110+
cd azure_functions
111+
func start
112+
```
113+
114+
The SDK posts to:
115+
116+
```text
117+
<ADF_ENDPOINT>/orchestrators/memory_orchestrator
118+
```
119+
120+
For local testing, `ADF_ENDPOINT` is usually `http://localhost:7071/api` and `ADF_KEY` is blank. For Azure, use the deployed Function App URL and set `ADF_KEY` if function-key auth is enabled.
121+
122+
If orchestration polling times out, check the Functions logs first. The orchestration may still be running, or an activity may be waiting on Cosmos DB or the LLM endpoint.
123+
124+
---
125+
126+
## 6. Change Feed Processing
127+
128+
Automatic processing requires these settings in the Functions app or `local.settings.json`:
129+
130+
```json
131+
"COSMOS_DB__accountEndpoint": "https://<account>.documents.azure.com:443/",
132+
"COSMOS_DB_COUNTERS_CONTAINER": "counter",
133+
"COSMOS_DB_LEASE_CONTAINER": "leases",
134+
"THREAD_SUMMARY_EVERY_N": "5",
135+
"FACT_EXTRACTION_EVERY_N": "3",
136+
"USER_SUMMARY_EVERY_N": "10"
137+
```
138+
139+
Set a threshold to `"0"` to disable that processing type.
140+
141+
Only documents with `type: "turn"` increment counters. Derived memories such as `summary`, `fact`, and `user_summary` do not trigger threshold counts.
142+
143+
If nothing fires:
144+
145+
- verify the Functions host shows the Cosmos DB trigger
146+
- confirm the `leases` container exists
147+
- confirm the `counter` container is writable
148+
- insert enough new turn documents to cross the configured threshold
149+
- check for generated documents with `memory_type="summary"`, `memory_type="fact"`, or `get_user_summary(user_id=...)`
150+
151+
---
152+
153+
## 7. Async Client Notes
154+
155+
Use async Azure credentials with the async client:
156+
157+
```python
158+
from azure.identity.aio import DefaultAzureCredential
159+
from agent_memory_toolkit.aio import AsyncCosmosMemoryClient
160+
```
161+
162+
Always `await` cloud operations and close the client when done:
163+
164+
```python
165+
await memory.close()
166+
```
167+
168+
In notebooks, top-level `await` is supported, so do not wrap cells with `asyncio.run()`.

Overview.png

1.74 MB
Loading

0 commit comments

Comments
 (0)