diff --git a/Docs/README.md b/Docs/README.md index 4332550..a748741 100644 --- a/Docs/README.md +++ b/Docs/README.md @@ -10,10 +10,12 @@ This folder contains the main project documentation for Agent Memory Toolkit. | [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. | | [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. | | [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. | +| [troubleshooting.md](troubleshooting.md) | Helps diagnose common setup, authentication, Cosmos DB, embeddings, Durable Functions, vector search, and change feed issues. | ## Recommended Reading Order 1. Start with [concepts.md](concepts.md) to understand the data model and memory lifecycle. 2. Use [local_testing.md](local_testing.md) to get the toolkit running and validated on your machine. 3. Use [azure_testing.md](azure_testing.md) when you are ready to deploy or validate the full stack in Azure. -4. See [design_patterns.md](design_patterns.md) for integration patterns in real applications. \ No newline at end of file +4. See [design_patterns.md](design_patterns.md) for integration patterns in real applications. +5. Use [troubleshooting.md](troubleshooting.md) when setup, processing, search, or automatic change feed behavior does not work as expected. \ No newline at end of file diff --git a/Docs/troubleshooting.md b/Docs/troubleshooting.md new file mode 100644 index 0000000..4baa1dc --- /dev/null +++ b/Docs/troubleshooting.md @@ -0,0 +1,168 @@ +# Troubleshooting Agent Memory Toolkit + +Use this guide when local memory works but Cosmos DB, embeddings, Durable Functions, or automatic change feed processing does not. + +--- + +## Quick Triage + +| Symptom | First checks | +|---------|--------------| +| Import errors | Install with `pip install -e ".[dev]"` and import `CosmosMemoryClient` or `AsyncCosmosMemoryClient`. | +| Missing configuration | Verify `.env`, `azure_functions/local.settings.json`, and Azure Function App settings use the same endpoint, database, and container values. | +| Cosmos 401 or 403 | Run `az login` and confirm Cosmos DB data-plane RBAC is assigned. | +| Cosmos operations fail before connecting | Call `create_memory_store()` or `connect_cosmos()` before cloud operations. | +| Search returns no vector results | Confirm embeddings are generated and `EMBEDDING_DIMENSIONS` matches the container vector policy. | +| Durable Function calls fail | Start the Functions host and check `ADF_ENDPOINT`, `ADF_KEY`, and the orchestrator route. | +| Change feed does not create summaries or facts | Confirm change feed settings, thresholds, lease container, counter container, and that inserted documents have `type: "turn"`. | + +--- + +## 1. Environment And Imports + +Install the package from the repository root: + +```bash +pip install -e ".[dev]" +pip install -r azure_functions/requirements.txt +``` + +The public clients are: + +```python +from agent_memory_toolkit import CosmosMemoryClient +from agent_memory_toolkit.aio import AsyncCosmosMemoryClient +``` + +If notebooks cannot import the package, run them from the `Samples` folder or add the repository root to `sys.path`. + +--- + +## 2. Configuration And Authentication + +For local runs, keep `.env` and `azure_functions/local.settings.json` aligned: + +```env +COSMOS_DB_ENDPOINT=https://.documents.azure.com:443/ +COSMOS_DB_DATABASE=ai_memory +COSMOS_DB_CONTAINER=memories +COSMOS_DB_COUNTERS_CONTAINER=counter +COSMOS_DB_LEASE_CONTAINER=leases +AI_FOUNDRY_ENDPOINT=https://.services.ai.azure.com/ +EMBEDDING_MODEL=text-embedding-3-large +EMBEDDING_DIMENSIONS=1536 +ADF_ENDPOINT=http://localhost:7071/api +ADF_KEY= +``` + +Run `az login` before using `DefaultAzureCredential`. + +Required roles: + +| Service | Role | +|---------|------| +| Cosmos DB | Cosmos DB Built-in Data Contributor | +| Azure OpenAI / AI Services | Cognitive Services OpenAI User | + +RBAC changes can take several minutes to propagate. + +--- + +## 3. Cosmos DB Store Creation + +Run `create_memory_store()` before relying on cloud operations. It creates the database plus the `memories`, `counter`, and `leases` containers. + +The memories container is created with: + +- hierarchical partition key on `user_id` and `thread_id` +- vector index on `/embedding` +- full-text index on `/content` + +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. + +Use `COSMOS_DB_THROUGHPUT_MODE=serverless` for the default setup. Use `autoscale` with `COSMOS_DB_AUTOSCALE_MAX_RU` when you need provisioned autoscale throughput. + +--- + +## 4. Embeddings And Search + +Embedding failures usually mean one of these is wrong: + +- `AI_FOUNDRY_ENDPOINT` +- `EMBEDDING_MODEL` +- `EMBEDDING_DIMENSIONS` +- Azure OpenAI / AI Services RBAC + +For hybrid search, `search_terms` is required when `hybrid_search=True`. + +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. + +--- + +## 5. Durable Functions Processing + +Thread summaries, fact extraction, and user summaries require the Functions host. + +Start local dependencies: + +```bash +azurite --silent --location /tmp/azurite --debug /tmp/azurite/debug.log +cd azure_functions +func start +``` + +The SDK posts to: + +```text +/orchestrators/memory_orchestrator +``` + +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. + +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. + +--- + +## 6. Change Feed Processing + +Automatic processing requires these settings in the Functions app or `local.settings.json`: + +```json +"COSMOS_DB__accountEndpoint": "https://.documents.azure.com:443/", +"COSMOS_DB_COUNTERS_CONTAINER": "counter", +"COSMOS_DB_LEASE_CONTAINER": "leases", +"THREAD_SUMMARY_EVERY_N": "5", +"FACT_EXTRACTION_EVERY_N": "3", +"USER_SUMMARY_EVERY_N": "10" +``` + +Set a threshold to `"0"` to disable that processing type. + +Only documents with `type: "turn"` increment counters. Derived memories such as `summary`, `fact`, and `user_summary` do not trigger threshold counts. + +If nothing fires: + +- verify the Functions host shows the Cosmos DB trigger +- confirm the `leases` container exists +- confirm the `counter` container is writable +- insert enough new turn documents to cross the configured threshold +- check for generated documents with `memory_type="summary"`, `memory_type="fact"`, or `get_user_summary(user_id=...)` + +--- + +## 7. Async Client Notes + +Use async Azure credentials with the async client: + +```python +from azure.identity.aio import DefaultAzureCredential +from agent_memory_toolkit.aio import AsyncCosmosMemoryClient +``` + +Always `await` cloud operations and close the client when done: + +```python +await memory.close() +``` + +In notebooks, top-level `await` is supported, so do not wrap cells with `asyncio.run()`. \ No newline at end of file diff --git a/Overview.png b/Overview.png new file mode 100644 index 0000000..621e23c Binary files /dev/null and b/Overview.png differ diff --git a/README.md b/README.md index f182885..48ad3c0 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Azure Cosmos DB Agent Memory Toolkit - Public Preview +# Azure Cosmos DB Agent Memory Toolkit [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/licenses/MIT) [![Python 3.11+](https://img.shields.io/badge/python-3.11+-blue.svg)](https://www.python.org/downloads/) @@ -8,48 +8,25 @@ [![YouTube](https://img.shields.io/badge/YouTube-Azure%20Cosmos%20DB-FF0000?logo=youtube&logoColor=white)](https://www.youtube.com/@AzureCosmosDB) -Agent Memory Toolkit is a Python SDK for storing, retrieving, and transforming agent memories on Azure Cosmos DB. It gives your agent both raw conversation history and higher-value derived memory — thread summaries, extracted facts, and cross-thread user profiles — all searchable semantically. The processing pipeline can run **in-process** (zero infra) or in a sibling **Azure Durable Function app** that watches the Cosmos DB change feed. Sync (`CosmosMemoryClient`) and async (`AsyncCosmosMemoryClient`) APIs are mirror-images of each other. +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 also supports automatic processing via a Cosmos DB change feed trigger that fires these pipelines in the background when configurable message count thresholds are crossed. 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. -``` -┌──────────────────────────────────────────────────────────────────────────────────────┐ -│ YOUR AGENTIC APP │ -│ Uses CosmosMemoryClient / AsyncCosmosMemoryClient │ -└─────────────────────────────────────────┬────────────────────────────────────────────┘ - │ - ▼ -┌──────────────────────────────────────────────────────────────────────────────────────┐ -│ AGENT MEMORY TOOLKIT (Python SDK) │ -│ │ -│ • Local in-memory CRUD │ -│ • Cosmos DB storage and retrieval │ -│ • Pluggable processor: in-process or remote Durable Function app │ -└──────────────────────────────────────────┬──────────────────────────────┬────────────┘ - │ │ - │ read / write │ Invoke processing pipeline - ▼ ▼ -┌───────────────────────────────────┐ ┌──────────────────────────────────┐ -│ AZURE COSMOS DB (NoSQL) │ │ AZURE DURABLE FUNCTIONS │ -│ │ │ │ -│ Stores: │ │ Orchestrates memory processing: │ -│ • turns │ │ • thread summaries │ -│ • summaries │◄─── memory management ───►│ • fact extraction │ -│ • facts │ │ • user summaries │ -│ • user summaries │ │ │ -│ │ │ On-demand (SDK) or automatic │ -│ Supports query, vector, text │ change feed trigger │ (Cosmos DB change feed trigger). │ -│ search over stored memories. │───────────────────────────►│ │ -└───────────────────────┬───────────┘ └──────────────────┬───────────────┘ - │ embeddings and LLM-based processing │ - └──────────────────────┬───────────────────────────────────┘ - ▼ - ┌──────────────────────────────────┐ - │ MICROSOFT FOUNDRY │ - │ │ - │ • Embeddings for search │ - │ • Chat/LLM generation │ - │ │ - └──────────────────────────────────┘ -``` +![Agent Memory Toolkit overview](Overview.png) + +--- + +## Features + +| Feature | Description | +|---------|-------------| +| **Local memory store** | In-memory CRUD — no Azure needed for development | +| **Cosmos DB integration** | CRUD, `push_to_cosmos()` bulk upload, semantic search, hierarchical partition key, vector + full-text indexes | +| **Thread summaries** | `generate_thread_summary()` — LLM-generated, incrementally updated, embedded and stored | +| **Fact extraction** | `extract_facts()` — discrete, independently searchable assertions from a thread | +| **User summaries** | `generate_user_summary()` — cross-thread user profile, incrementally updated | +| **Incremental updates** | Thread and user summaries use point-read + time-filtering to merge new data with existing summaries | +| **Automatic processing** | Cosmos DB change feed trigger fires thread summaries, fact extraction, and user summaries when configurable message count thresholds are crossed | +| **Externalized prompts** | LLM prompts live in editable Markdown files (`azure_functions/prompts/`) | +| **Entra ID auth** | `DefaultAzureCredential` everywhere — `az login`, managed identities | --- @@ -163,6 +140,20 @@ See [`Samples/`](Samples/) for end-to-end scenarios (chat memory, RAG, multi-age --- +## Azure Resources + +| Resource | Purpose | +|----------|---------| +| **Cosmos DB for NoSQL** | Memory store with hierarchical partition key, vector index, full-text index | +| **Azure OpenAI / AI Foundry** | Embedding model + chat model for summarization / fact extraction | +| **Azure Functions** | Durable Functions orchestrator and activity functions | + +Automatic change feed processing stores lightweight counter documents in a dedicated `counter` container and also uses a `leases` container that is provisioned by `create_memory_store()`. Throughput defaults to `serverless`; set `COSMOS_DB_THROUGHPUT_MODE=autoscale` to apply the shared `COSMOS_DB_AUTOSCALE_MAX_RU` cap to the memories, counter, and lease containers. See [concepts.md](Docs/concepts.md#automatic-processing-change-feed) for details. + +All services use **Entra ID** auth via `DefaultAzureCredential`. + +--- + ## Concepts in 60 seconds | Concept | What it is | API | @@ -290,16 +281,6 @@ Async equivalents (`AsyncInProcessProcessor`, `AsyncDurableFunctionProcessor`) l --- -## Documentation - -- **[Docs/concepts.md](Docs/concepts.md)** — Memory types, threads, roles, embeddings, processing pipeline -- **[Docs/design_patterns.md](Docs/design_patterns.md)** — Integration patterns for chat apps and multi-agent systems -- **[Docs/local_testing.md](Docs/local_testing.md)** — Prerequisites, environment setup, running locally, debugging -- **[Docs/azure_testing.md](Docs/azure_testing.md)** — Azure deployment, RBAC, cloud validation -- **[infra/README.md](infra/README.md)** — `azd` deployment, Bicep modules, BYOR settings, counter-trigger tuning - ---- - ## Project structure ``` @@ -315,11 +296,15 @@ tests/ Unit + integration tests (pytest) --- -## Migration notes +## Documentation -- **`agent_memory_toolkit.processing.ProcessingClient` is removed.** Drop the import and call `client.process_now()` (or `client.process_now_and_wait()`) instead. Same for the async `AsyncProcessingClient`. -- **New `processor=` kwarg.** Defaults to `InProcessProcessor()` — existing code keeps its current behavior with no edits. -- **`adf_endpoint` / `adf_key` constructor kwargs are gone.** The SDK no longer makes HTTP calls to the Function app at runtime; the Function app reads from the Cosmos change feed. +- **[concepts.md](Docs/concepts.md)** — Memory types, threads, roles, embeddings, processing pipeline +- **[design_patterns.md](Docs/design_patterns.md)** — Integration patterns for chat apps and multi-agent systems +- **[local_testing.md](Docs/local_testing.md)** — Prerequisites, environment setup, running locally, debugging +- **[azure_testing.md](Docs/azure_testing.md)** — Azure deployment, RBAC, cloud validation +- **[troubleshooting.md](Docs/troubleshooting.md)** — Common setup, auth, Cosmos DB, Durable Functions, search, and change feed failure modes + +--- ## Trademark notice Trademarks This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft trademarks or logos is subject to and must follow Microsoft’s Trademark & Brand Guidelines. Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship. Any use of third-party trademarks or logos are subject to those third-party’s policies. diff --git a/Samples/advanced_memory_lifecycle.py b/Samples/Advanced/advanced_memory_lifecycle.py similarity index 100% rename from Samples/advanced_memory_lifecycle.py rename to Samples/Advanced/advanced_memory_lifecycle.py diff --git a/Samples/advanced_search_patterns.py b/Samples/Advanced/advanced_search_patterns.py similarity index 100% rename from Samples/advanced_search_patterns.py rename to Samples/Advanced/advanced_search_patterns.py diff --git a/Samples/Demo_async.ipynb b/Samples/Demo_async.ipynb deleted file mode 100644 index a3c1d21..0000000 --- a/Samples/Demo_async.ipynb +++ /dev/null @@ -1,2900 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "id": "04a283f1", - "metadata": {}, - "source": [ - "## 1. Setup\n", - "\n", - "Install/import dependencies and load environment variables from `.env`." - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "id": "15434fb9", - "metadata": { - "ExecuteTime": { - "end_time": "2026-04-07T22:06:39.082693Z", - "start_time": "2026-04-07T22:06:38.712684Z" - }, - "execution": { - "iopub.execute_input": "2026-05-04T20:25:45.211452Z", - "iopub.status.busy": "2026-05-04T20:25:45.211356Z", - "iopub.status.idle": "2026-05-04T20:25:45.346501Z", - "shell.execute_reply": "2026-05-04T20:25:45.346098Z" - } - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "COSMOS_DB_ENDPOINT: https://akataria-agent-memory-testing.documents.azure.com:443/\n", - "COSMOS_DB_DATABASE: ai_memory\n", - "COSMOS_DB_CONTAINER: memories\n", - "COSMOS_DB_COUNTERS_CONTAINER: counter\n", - "COSMOS_DB_LEASE_CONTAINER: leases\n", - "COSMOS_DB_THROUGHPUT_MODE: serverless\n", - "COSMOS_DB_AUTOSCALE_MAX_RU: 1000\n" - ] - } - ], - "source": [ - "import os, json, sys\n", - "\n", - "from pathlib import Path\n", - "\n", - "sys.path.insert(0, os.path.abspath(\"..\"))\n", - "\n", - "\n", - "\n", - "from dotenv import load_dotenv\n", - "\n", - "from agent_memory_toolkit.aio import AsyncCosmosMemoryClient\n", - "\n", - "\n", - "\n", - "# Load environment variables from .env in the repo root\n", - "\n", - "load_dotenv(os.path.join(\"..\", \".env\"))\n", - "\n", - "\n", - "\n", - "print(\"COSMOS_DB_ENDPOINT:\", os.getenv(\"COSMOS_DB_ENDPOINT\"))\n", - "\n", - "print(\"COSMOS_DB_DATABASE:\", os.getenv(\"COSMOS_DB_DATABASE\"))\n", - "\n", - "print(\"COSMOS_DB_CONTAINER:\", os.getenv(\"COSMOS_DB_CONTAINER\"))\n", - "\n", - "print(\"COSMOS_DB_COUNTERS_CONTAINER:\", os.getenv(\"COSMOS_DB_COUNTERS_CONTAINER\", \"counter\"))\n", - "\n", - "print(\"COSMOS_DB_LEASE_CONTAINER:\", os.getenv(\"COSMOS_DB_LEASE_CONTAINER\", \"leases\"))\n", - "\n", - "print(\"COSMOS_DB_THROUGHPUT_MODE:\", os.getenv(\"COSMOS_DB_THROUGHPUT_MODE\", \"serverless\"))\n", - "\n", - "print(\"COSMOS_DB_AUTOSCALE_MAX_RU:\", os.getenv(\"COSMOS_DB_AUTOSCALE_MAX_RU\", \"1000\"))" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "id": "75bf151787e8aaa2", - "metadata": { - "ExecuteTime": { - "end_time": "2026-04-07T22:06:41.229355Z", - "start_time": "2026-04-07T22:06:41.014359Z" - }, - "execution": { - "iopub.execute_input": "2026-05-04T20:25:45.347628Z", - "iopub.status.busy": "2026-05-04T20:25:45.347566Z", - "iopub.status.idle": "2026-05-04T20:25:45.652841Z", - "shell.execute_reply": "2026-05-04T20:25:45.652467Z" - } - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "AsyncCosmosMemoryClient instance created\n", - "Throughput mode: serverless\n", - "Local memory store: []\n" - ] - } - ], - "source": [ - "from azure.identity.aio import DefaultAzureCredential as AsyncDefaultAzureCredential\n", - "\n", - "# Credential priority: explicit cosmos_credential > explicit cosmos_key > DefaultAzureCredential.\n", - "# Set COSMOS_DB_KEY in your .env if you don't yet have control-plane RBAC (currently in private preview).\n", - "memory = AsyncCosmosMemoryClient(\n", - " cosmos_endpoint=os.getenv(\"COSMOS_DB_ENDPOINT\"),\n", - " cosmos_database=os.getenv(\"COSMOS_DB_DATABASE\"),\n", - " cosmos_container=os.getenv(\"COSMOS_DB_CONTAINER\"),\n", - " cosmos_counter_container=os.getenv(\"COSMOS_DB_COUNTERS_CONTAINER\", \"counter\"),\n", - " cosmos_lease_container=os.getenv(\"COSMOS_DB_LEASE_CONTAINER\", \"leases\"),\n", - " cosmos_throughput_mode=os.getenv(\"COSMOS_DB_THROUGHPUT_MODE\", \"serverless\"),\n", - " cosmos_autoscale_max_ru=int(os.getenv(\"COSMOS_DB_AUTOSCALE_MAX_RU\", \"1000\")),\n", - " cosmos_key=os.getenv(\"COSMOS_DB_KEY\"),\n", - " ai_foundry_endpoint=os.getenv(\"AI_FOUNDRY_ENDPOINT\"),\n", - " ai_foundry_api_key=os.getenv(\"AI_FOUNDRY_API_KEY\"),\n", - " embedding_deployment_name=os.getenv(\"AI_FOUNDRY_EMBEDDING_DEPLOYMENT_NAME\", \"text-embedding-3-large\"),\n", - " chat_deployment_name=os.getenv(\"AI_FOUNDRY_CHAT_DEPLOYMENT_NAME\", \"gpt-4o-mini\"),\n", - " use_default_credential=True,\n", - ")\n", - "\n", - "print(\"AsyncCosmosMemoryClient instance created\")\n", - "print(\"Throughput mode:\", os.getenv(\"COSMOS_DB_THROUGHPUT_MODE\", \"serverless\"))\n", - "print(\"Local memory store:\", memory.local_memory)\n" - ] - }, - { - "cell_type": "markdown", - "id": "3ed9ad79", - "metadata": {}, - "source": [ - "## 2. Local Memory Operations\n", - "\n", - "`AsyncCosmosMemoryClient` mirrors the sync API. Local operations (`add_local`, `get_local`, `update_local`, `delete_local`) are synchronous under the hood (in-memory list), but the class is designed for use in async code paths.\n", - "\n", - "> **Note:** In Jupyter you can `await` directly in cells without wrapping in `asyncio.run()`." - ] - }, - { - "cell_type": "markdown", - "id": "56eadc55", - "metadata": {}, - "source": [ - "### 2a. Add memories with `add_local`" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "id": "5619b2ed", - "metadata": { - "ExecuteTime": { - "end_time": "2026-04-07T22:06:45.409758Z", - "start_time": "2026-04-07T22:06:45.149684Z" - }, - "execution": { - "iopub.execute_input": "2026-05-04T20:25:45.653810Z", - "iopub.status.busy": "2026-05-04T20:25:45.653720Z", - "iopub.status.idle": "2026-05-04T20:25:45.655764Z", - "shell.execute_reply": "2026-05-04T20:25:45.655372Z" - } - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "User ID: user-ea5eba7a\n", - "Thread ID: 807c3bc6-c021-4f66-b996-07bc5ef781ab\n", - "\n" - ] - } - ], - "source": [ - "import uuid\n", - "THREAD_ID = str(uuid.uuid4())\n", - "# Use a unique user_id per demo run so we get a clean extraction without\n", - "# inheriting facts from prior runs that would dedup new content away.\n", - "USER_ID = f\"user-{uuid.uuid4().hex[:8]}\"\n", - "print(f\"User ID: {USER_ID}\")\n", - "print(f\"Thread ID: {THREAD_ID}\\n\")\n" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "id": "5ce1b88c", - "metadata": { - "ExecuteTime": { - "end_time": "2026-04-07T22:06:47.709471Z", - "start_time": "2026-04-07T22:06:47.682021Z" - }, - "execution": { - "iopub.execute_input": "2026-05-04T20:25:45.656663Z", - "iopub.status.busy": "2026-05-04T20:25:45.656610Z", - "iopub.status.idle": "2026-05-04T20:25:45.660512Z", - "shell.execute_reply": "2026-05-04T20:25:45.660236Z" - } - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Added 12 memories\n", - "[\n", - " {\n", - " \"id\": \"558654f4-87cd-49c9-ad8c-efb35081a7ff\",\n", - " \"user_id\": \"user-ea5eba7a\",\n", - " \"thread_id\": \"807c3bc6-c021-4f66-b996-07bc5ef781ab\",\n", - " \"role\": \"user\",\n", - " \"type\": \"turn\",\n", - " \"content\": \"What's the weather like in Seattle this weekend?\",\n", - " \"metadata\": {},\n", - " \"created_at\": \"2026-05-04T20:25:45.658915+00:00\",\n", - " \"tags\": [],\n", - " \"ttl\": 2592000\n", - " },\n", - " {\n", - " \"id\": \"c6b6827e-4768-475c-87a5-adad9cb2b2d0\",\n", - " \"user_id\": \"user-ea5eba7a\",\n", - " \"thread_id\": \"807c3bc6-c021-4f66-b996-07bc5ef781ab\",\n", - " \"role\": \"agent\",\n", - " \"type\": \"turn\",\n", - " \"content\": \"This weekend Seattle will be around 55\\u00b0F with partly cloudy skies on Saturday and light rain expected Sunday.\",\n", - " \"metadata\": {},\n", - " \"created_at\": \"2026-05-04T20:25:45.658939+00:00\",\n", - " \"tags\": [],\n", - " \"ttl\": 2592000\n", - " },\n", - " {\n", - " \"id\": \"afa8d19a-293c-4104-9262-fa4f63f9bc6a\",\n", - " \"user_id\": \"user-ea5eba7a\",\n", - " \"thread_id\": \"807c3bc6-c021-4f66-b996-07bc5ef781ab\",\n", - " \"role\": \"user\",\n", - " \"type\": \"turn\",\n", - " \"content\": \"That sounds nice enough. Can you help me book a trip to Seattle for this weekend?\",\n", - " \"metadata\": {},\n", - " \"created_at\": \"2026-05-04T20:25:45.658953+00:00\",\n", - " \"tags\": [],\n", - " \"ttl\": 2592000\n", - " },\n", - " {\n", - " \"id\": \"101560c2-fd8f-4ad0-b323-510503bd472a\",\n", - " \"user_id\": \"user-ea5eba7a\",\n", - " \"thread_id\": \"807c3bc6-c021-4f66-b996-07bc5ef781ab\",\n", - " \"role\": \"agent\",\n", - " \"type\": \"turn\",\n", - " \"content\": \"Sure! I found round-trip flights departing Friday evening and returning Sunday night. There are also several hotels in downtown Seattle with availability. Would you like me to look at specific airlines or neighborhoods?\",\n", - " \"metadata\": {},\n", - " \"created_at\": \"2026-05-04T20:25:45.658966+00:00\",\n", - " \"tags\": [],\n", - " \"ttl\": 2592000\n", - " },\n", - " {\n", - " \"id\": \"afe25494-52f6-4370-a5a2-c8d09fea8fd3\",\n", - " \"user_id\": \"user-ea5eba7a\",\n", - " \"thread_id\": \"807c3bc6-c021-4f66-b996-07bc5ef781ab\",\n", - " \"role\": \"user\",\n", - " \"type\": \"turn\",\n", - " \"content\": \"Something near Pike Place Market would be great. And keep the flights under $300 round trip if possible.\",\n", - " \"metadata\": {},\n", - " \"created_at\": \"2026-05-04T20:25:45.658978+00:00\",\n", - " \"tags\": [],\n", - " \"ttl\": 2592000\n", - " },\n", - " {\n", - " \"id\": \"67cee94e-1b2f-4456-882f-40ae84925e30\",\n", - " \"user_id\": \"user-ea5eba7a\",\n", - " \"thread_id\": \"807c3bc6-c021-4f66-b996-07bc5ef781ab\",\n", - " \"role\": \"agent\",\n", - " \"type\": \"turn\",\n", - " \"content\": \"I found a round-trip on Alaska Airlines for $275 and two hotel options within a 5-minute walk of Pike Place Market: the Inn at the Market ($189/night) and a Hilton Garden Inn ($145/night). Want me to reserve one of these?\",\n", - " \"metadata\": {},\n", - " \"created_at\": \"2026-05-04T20:25:45.658991+00:00\",\n", - " \"tags\": [],\n", - " \"ttl\": 2592000\n", - " },\n", - " {\n", - " \"id\": \"bb55ae9b-d50c-4d82-b03a-458c599c5d5c\",\n", - " \"user_id\": \"user-ea5eba7a\",\n", - " \"thread_id\": \"807c3bc6-c021-4f66-b996-07bc5ef781ab\",\n", - " \"role\": \"user\",\n", - " \"type\": \"turn\",\n", - " \"content\": \"Whenever you book a flight for me, always book an aisle seat \\u2014 never a window or middle.\",\n", - " \"metadata\": {},\n", - " \"created_at\": \"2026-05-04T20:25:45.659003+00:00\",\n", - " \"tags\": [],\n", - " \"ttl\": 2592000\n", - " },\n", - " {\n", - " \"id\": \"3ee542c4-6717-4e85-a2b3-6170f8600e11\",\n", - " \"user_id\": \"user-ea5eba7a\",\n", - " \"thread_id\": \"807c3bc6-c021-4f66-b996-07bc5ef781ab\",\n", - " \"role\": \"agent\",\n", - " \"type\": \"turn\",\n", - " \"content\": \"Got it. I'll always select an aisle seat for your bookings.\",\n", - " \"metadata\": {},\n", - " \"created_at\": \"2026-05-04T20:25:45.659015+00:00\",\n", - " \"tags\": [],\n", - " \"ttl\": 2592000\n", - " },\n", - " {\n", - " \"id\": \"5544d374-0b6f-437c-a6a7-b6522e9f8604\",\n", - " \"user_id\": \"user-ea5eba7a\",\n", - " \"thread_id\": \"807c3bc6-c021-4f66-b996-07bc5ef781ab\",\n", - " \"role\": \"user\",\n", - " \"type\": \"turn\",\n", - " \"content\": \"For trip planning, my workflow is: first check the weather for the destination, then check flights, then book the hotel last after everything else is confirmed.\",\n", - " \"metadata\": {},\n", - " \"created_at\": \"2026-05-04T20:25:45.659028+00:00\",\n", - " \"tags\": [],\n", - " \"ttl\": 2592000\n", - " },\n", - " {\n", - " \"id\": \"3a42a459-1e0a-4923-a63b-b899230f5003\",\n", - " \"user_id\": \"user-ea5eba7a\",\n", - " \"thread_id\": \"807c3bc6-c021-4f66-b996-07bc5ef781ab\",\n", - " \"role\": \"agent\",\n", - " \"type\": \"turn\",\n", - " \"content\": \"Noted \\u2014 I'll follow that order: weather, then flights, then hotel.\",\n", - " \"metadata\": {},\n", - " \"created_at\": \"2026-05-04T20:25:45.659039+00:00\",\n", - " \"tags\": [],\n", - " \"ttl\": 2592000\n", - " },\n", - " {\n", - " \"id\": \"056e8fcb-514a-495f-8e30-affcf9e2b56e\",\n", - " \"user_id\": \"user-ea5eba7a\",\n", - " \"thread_id\": \"807c3bc6-c021-4f66-b996-07bc5ef781ab\",\n", - " \"role\": \"user\",\n", - " \"type\": \"turn\",\n", - " \"content\": \"And never book me into anything that departs or arrives between midnight and 6am unless I explicitly approve it.\",\n", - " \"metadata\": {},\n", - " \"created_at\": \"2026-05-04T20:25:45.659051+00:00\",\n", - " \"tags\": [],\n", - " \"ttl\": 2592000\n", - " },\n", - " {\n", - " \"id\": \"97401d13-7f8c-46bb-8dc5-1d0ea3d9d299\",\n", - " \"user_id\": \"user-ea5eba7a\",\n", - " \"thread_id\": \"807c3bc6-c021-4f66-b996-07bc5ef781ab\",\n", - " \"role\": \"agent\",\n", - " \"type\": \"turn\",\n", - " \"content\": \"Will do \\u2014 no overnight bookings without your explicit approval.\",\n", - " \"metadata\": {},\n", - " \"created_at\": \"2026-05-04T20:25:45.659062+00:00\",\n", - " \"tags\": [],\n", - " \"ttl\": 2592000\n", - " }\n", - "]\n", - "Rules thread ID: c1138077-4c41-49a1-8758-5d7cdcef4347 (8 turns)\n" - ] - } - ], - "source": [ - "# Add sample conversation: weather in Seattle → booking a trip (6 turns)\n", - "memory.add_local(\n", - " user_id=USER_ID, role=\"user\", thread_id=THREAD_ID,\n", - " content=\"What's the weather like in Seattle this weekend?\",\n", - ")\n", - "memory.add_local(\n", - " user_id=USER_ID, role=\"agent\", thread_id=THREAD_ID,\n", - " content=\"This weekend Seattle will be around 55°F with partly cloudy skies on Saturday and light rain expected Sunday.\",\n", - ")\n", - "memory.add_local(\n", - " user_id=USER_ID, role=\"user\", thread_id=THREAD_ID,\n", - " content=\"That sounds nice enough. Can you help me book a trip to Seattle for this weekend?\",\n", - ")\n", - "memory.add_local(\n", - " user_id=USER_ID, role=\"agent\", thread_id=THREAD_ID,\n", - " content=\"Sure! I found round-trip flights departing Friday evening and returning Sunday night. There are also several hotels in downtown Seattle with availability. Would you like me to look at specific airlines or neighborhoods?\",\n", - ")\n", - "memory.add_local(\n", - " user_id=USER_ID, role=\"user\", thread_id=THREAD_ID,\n", - " content=\"Something near Pike Place Market would be great. And keep the flights under $300 round trip if possible.\",\n", - ")\n", - "memory.add_local(\n", - " user_id=USER_ID, role=\"agent\", thread_id=THREAD_ID,\n", - " content=\"I found a round-trip on Alaska Airlines for $275 and two hotel options within a 5-minute walk of Pike Place Market: the Inn at the Market ($189/night) and a Hilton Garden Inn ($145/night). Want me to reserve one of these?\",\n", - ")\n", - "\n", - "memory.add_local(\n", - " user_id=USER_ID, role=\"user\", thread_id=THREAD_ID,\n", - " content=\"Whenever you book a flight for me, always book an aisle seat — never a window or middle.\",\n", - ")\n", - "memory.add_local(\n", - " user_id=USER_ID, role=\"agent\", thread_id=THREAD_ID,\n", - " content=\"Got it. I'll always select an aisle seat for your bookings.\",\n", - ")\n", - "memory.add_local(\n", - " user_id=USER_ID, role=\"user\", thread_id=THREAD_ID,\n", - " content=\"For trip planning, my workflow is: first check the weather for the destination, then check flights, then book the hotel last after everything else is confirmed.\",\n", - ")\n", - "memory.add_local(\n", - " user_id=USER_ID, role=\"agent\", thread_id=THREAD_ID,\n", - " content=\"Noted — I'll follow that order: weather, then flights, then hotel.\",\n", - ")\n", - "memory.add_local(\n", - " user_id=USER_ID, role=\"user\", thread_id=THREAD_ID,\n", - " content=\"And never book me into anything that departs or arrives between midnight and 6am unless I explicitly approve it.\",\n", - ")\n", - "memory.add_local(\n", - " user_id=USER_ID, role=\"agent\", thread_id=THREAD_ID,\n", - " content=\"Will do — no overnight bookings without your explicit approval.\",\n", - ")\n", - "\n", - "print(f\"Added {len(memory.local_memory)} memories\")\n", - "print(json.dumps(memory.get_local(), indent=2))\n", - "\n", - "# A second short thread of pure procedural-style instructions. Demonstrates\n", - "# that the extractor produces clean procedural items when the conversation is\n", - "# focused on rules/workflows rather than mixed with factual booking specifics.\n", - "RULES_THREAD_ID = str(uuid.uuid4())\n", - "for role, content in [\n", - " (\"user\", \"Whenever you book a flight for me, always book an aisle seat — never a window or middle.\"),\n", - " (\"agent\", \"Got it. I'll always select an aisle seat for your bookings.\"),\n", - " (\"user\", \"For trip planning, my workflow is: first check the weather, then check flights, and book the hotel last after everything else is confirmed.\"),\n", - " (\"agent\", \"Noted — I'll follow that order: weather, then flights, then hotel.\"),\n", - " (\"user\", \"Never book me into anything that departs or arrives between midnight and 6am unless I explicitly approve it.\"),\n", - " (\"agent\", \"Will do — no overnight bookings without your explicit approval.\"),\n", - " (\"user\", \"When picking a hotel, only recommend ones that include complimentary breakfast.\"),\n", - " (\"agent\", \"Understood — only hotels with complimentary breakfast.\"),\n", - "]:\n", - " memory.add_local(user_id=USER_ID, role=role, thread_id=RULES_THREAD_ID, content=content)\n", - "\n", - "print(f\"Rules thread ID: {RULES_THREAD_ID} ({sum(1 for m in memory.local_memory if m['thread_id']==RULES_THREAD_ID)} turns)\")\n" - ] - }, - { - "cell_type": "markdown", - "id": "9a0aac22", - "metadata": {}, - "source": [ - "### 2b. Query memories with `get_local`" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "id": "942e3714", - "metadata": { - "ExecuteTime": { - "end_time": "2026-04-07T22:06:50.682868Z", - "start_time": "2026-04-07T22:06:50.661470Z" - }, - "execution": { - "iopub.execute_input": "2026-05-04T20:25:45.661416Z", - "iopub.status.busy": "2026-05-04T20:25:45.661371Z", - "iopub.status.idle": "2026-05-04T20:25:45.663639Z", - "shell.execute_reply": "2026-05-04T20:25:45.663296Z" - } - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Total memories: 20\n", - "\n", - "Memories for user-001: 20\n", - "Tool memories: 10\n", - " [c6b6827e...] This weekend Seattle will be around 55°F with partly cloudy \n", - " [101560c2...] Sure! I found round-trip flights departing Friday evening an\n", - " [67cee94e...] I found a round-trip on Alaska Airlines for $275 and two hot\n", - " [3ee542c4...] Got it. I'll always select an aisle seat for your bookings.\n", - " [3a42a459...] Noted — I'll follow that order: weather, then flights, then \n", - " [97401d13...] Will do — no overnight bookings without your explicit approv\n", - " [40665284...] Got it. I'll always select an aisle seat for your bookings.\n", - " [2b7e104d...] Noted — I'll follow that order: weather, then flights, then \n", - " [30da082b...] Will do — no overnight bookings without your explicit approv\n", - " [4e5b3a7d...] Understood — only hotels with complimentary breakfast.\n", - "\n", - "Fact memories: 0\n", - "\n", - "Agent memories for user-001: 10\n" - ] - } - ], - "source": [ - "# Get all memories\n", - "all_memories = memory.get_local()\n", - "print(f\"Total memories: {len(all_memories)}\\n\")\n", - "\n", - "# Filter by user_id\n", - "user1_memories = memory.get_local(user_id=USER_ID)\n", - "print(f\"Memories for user-001: {len(user1_memories)}\")\n", - "\n", - "# Filter by role\n", - "tool_memories = memory.get_local(role=\"agent\")\n", - "print(f\"Tool memories: {len(tool_memories)}\")\n", - "for m in tool_memories:\n", - " print(f\" [{m['id'][:8]}...] {m['content'][:60]}\")\n", - "\n", - "# Filter by type\n", - "facts = memory.get_local(memory_types=[\"fact\"])\n", - "print(f\"\\nFact memories: {len(facts)}\")\n", - "for m in facts:\n", - " print(f\" [{m['id'][:8]}...] {m['content']}\")\n", - "\n", - "# Combine filters: user-001 + agent role\n", - "user1_agent = memory.get_local(user_id=USER_ID, role=\"agent\")\n", - "print(f\"\\nAgent memories for user-001: {len(user1_agent)}\")" - ] - }, - { - "cell_type": "markdown", - "id": "ba973a1c", - "metadata": {}, - "source": [ - "### 2c. Update & Delete with `update_local` / `delete_local`" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "id": "4ca36086", - "metadata": { - "ExecuteTime": { - "end_time": "2026-04-07T22:06:53.605394Z", - "start_time": "2026-04-07T22:06:53.576655Z" - }, - "execution": { - "iopub.execute_input": "2026-05-04T20:25:45.664504Z", - "iopub.status.busy": "2026-05-04T20:25:45.664457Z", - "iopub.status.idle": "2026-05-04T20:25:45.666846Z", - "shell.execute_reply": "2026-05-04T20:25:45.666497Z" - } - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Before update:\n", - "{\n", - " \"id\": \"afe25494-52f6-4370-a5a2-c8d09fea8fd3\",\n", - " \"user_id\": \"user-ea5eba7a\",\n", - " \"thread_id\": \"807c3bc6-c021-4f66-b996-07bc5ef781ab\",\n", - " \"role\": \"user\",\n", - " \"type\": \"turn\",\n", - " \"content\": \"Something near Pike Place Market would be great. And keep the flights under $300 round trip if possible.\",\n", - " \"metadata\": {},\n", - " \"created_at\": \"2026-05-04T20:25:45.658978+00:00\",\n", - " \"tags\": [],\n", - " \"ttl\": 2592000\n", - "}\n", - "\n", - "After update:\n", - "{\n", - " \"id\": \"afe25494-52f6-4370-a5a2-c8d09fea8fd3\",\n", - " \"user_id\": \"user-ea5eba7a\",\n", - " \"thread_id\": \"807c3bc6-c021-4f66-b996-07bc5ef781ab\",\n", - " \"role\": \"user\",\n", - " \"type\": \"turn\",\n", - " \"content\": \"Something near Pike Place Market would be great. Keep flights under $300 round trip and hotels under $200/night.\",\n", - " \"metadata\": {\n", - " \"edited\": true,\n", - " \"reason\": \"user clarified hotel budget\"\n", - " },\n", - " \"created_at\": \"2026-05-04T20:25:45.658978+00:00\",\n", - " \"tags\": [],\n", - " \"ttl\": 2592000,\n", - " \"updated_at\": \"2026-05-04T20:25:45.665382+00:00\"\n", - "}\n", - "\n", - "Deleting memory afa8d19a...\n", - "\n", - "Remaining memories: 19\n", - " [807c3bc6...] [558654f4...] role=user type=turn What's the weather like in Seattle this weekend?\n", - " [807c3bc6...] [c6b6827e...] role=agent type=turn This weekend Seattle will be around 55°F with part\n", - " [807c3bc6...] [101560c2...] role=agent type=turn Sure! I found round-trip flights departing Friday \n", - " [807c3bc6...] [afe25494...] role=user type=turn Something near Pike Place Market would be great. K\n", - " [807c3bc6...] [67cee94e...] role=agent type=turn I found a round-trip on Alaska Airlines for $275 a\n", - " [807c3bc6...] [bb55ae9b...] role=user type=turn Whenever you book a flight for me, always book an \n", - " [807c3bc6...] [3ee542c4...] role=agent type=turn Got it. I'll always select an aisle seat for your \n", - " [807c3bc6...] [5544d374...] role=user type=turn For trip planning, my workflow is: first check the\n", - " [807c3bc6...] [3a42a459...] role=agent type=turn Noted — I'll follow that order: weather, then flig\n", - " [807c3bc6...] [056e8fcb...] role=user type=turn And never book me into anything that departs or ar\n", - " [807c3bc6...] [97401d13...] role=agent type=turn Will do — no overnight bookings without your expli\n", - " [c1138077...] [47eef782...] role=user type=turn Whenever you book a flight for me, always book an \n", - " [c1138077...] [40665284...] role=agent type=turn Got it. I'll always select an aisle seat for your \n", - " [c1138077...] [15f9f705...] role=user type=turn For trip planning, my workflow is: first check the\n", - " [c1138077...] [2b7e104d...] role=agent type=turn Noted — I'll follow that order: weather, then flig\n", - " [c1138077...] [c5d66e1a...] role=user type=turn Never book me into anything that departs or arrive\n", - " [c1138077...] [30da082b...] role=agent type=turn Will do — no overnight bookings without your expli\n", - " [c1138077...] [705626cf...] role=user type=turn When picking a hotel, only recommend ones that inc\n", - " [c1138077...] [4e5b3a7d...] role=agent type=turn Understood — only hotels with complimentary breakf\n" - ] - } - ], - "source": [ - "# Update the user's budget constraint to be more specific\n", - "target_id = memory.local_memory[4][\"id\"] # \"Something near Pike Place Market...\"\n", - "print(f\"Before update:\\n{json.dumps(memory.get_local(memory_id=target_id)[0], indent=2)}\\n\")\n", - "\n", - "memory.update_local(\n", - " memory_id=target_id,\n", - " content=\"Something near Pike Place Market would be great. Keep flights under $300 round trip and hotels under $200/night.\",\n", - " metadata={\"edited\": True, \"reason\": \"user clarified hotel budget\"},\n", - ")\n", - "print(f\"After update:\\n{json.dumps(memory.get_local(memory_id=target_id)[0], indent=2)}\")\n", - "\n", - "# Delete the third memory (index 2 — the user's booking request)\n", - "del_target_id = memory.local_memory[2][\"id\"]\n", - "print(f\"\\nDeleting memory {del_target_id[:8]}...\")\n", - "memory.delete_local(del_target_id)\n", - "\n", - "# Verify it's gone\n", - "print(f\"\\nRemaining memories: {len(memory.get_local())}\")\n", - "for m in memory.get_local():\n", - " print(f\" [{m['thread_id'][:8]}...] [{m['id'][:8]}...] role={m['role']:<6} type={m['type']:<8} {m['content'][:50]}\")" - ] - }, - { - "cell_type": "markdown", - "id": "bad8c2b6", - "metadata": {}, - "source": [ - "## 3. Cosmos DB Operations\n", - "\n", - "### 3a. Connect and create the memory store\n", - "\n", - "The async client auto-connects on the first Cosmos DB operation. Call `create_memory_store()` to create the database and container if they do not already exist, including the hierarchical partition key, vector index, and full-text index.\n", - "\n", - "> **Note:** `create_memory_store()` is safe to run more than once." - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "id": "82b363d7", - "metadata": { - "ExecuteTime": { - "end_time": "2026-04-07T22:06:58.478498Z", - "start_time": "2026-04-07T22:06:57.474753Z" - }, - "execution": { - "iopub.execute_input": "2026-05-04T20:25:45.667704Z", - "iopub.status.busy": "2026-05-04T20:25:45.667661Z", - "iopub.status.idle": "2026-05-04T20:25:46.372667Z", - "shell.execute_reply": "2026-05-04T20:25:46.371834Z" - } - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Connected: True\n" - ] - } - ], - "source": [ - "# The async client auto-creates the database and container on the first Cosmos operation.\n", - "# You can also call create_memory_store() explicitly if needed.\n", - "await memory.create_memory_store()\n", - "print(f\"Connected: {memory._container_client is not None}\")" - ] - }, - { - "cell_type": "markdown", - "id": "5c18edf3", - "metadata": {}, - "source": [ - "### 3b. Add memories to Cosmos DB with `add_cosmos`" - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "id": "b7d0939d", - "metadata": { - "execution": { - "iopub.execute_input": "2026-05-04T20:25:46.375244Z", - "iopub.status.busy": "2026-05-04T20:25:46.375091Z", - "iopub.status.idle": "2026-05-04T20:25:46.627003Z", - "shell.execute_reply": "2026-05-04T20:25:46.626193Z" - } - }, - "outputs": [], - "source": [ - "await memory.connect_cosmos()" - ] - }, - { - "cell_type": "code", - "execution_count": 9, - "id": "e0b3b5fc", - "metadata": { - "ExecuteTime": { - "end_time": "2026-04-07T22:07:08.081103Z", - "start_time": "2026-04-07T22:07:07.860764Z" - }, - "execution": { - "iopub.execute_input": "2026-05-04T20:25:46.629264Z", - "iopub.status.busy": "2026-05-04T20:25:46.629134Z", - "iopub.status.idle": "2026-05-04T20:25:47.111769Z", - "shell.execute_reply": "2026-05-04T20:25:47.111092Z" - } - }, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "Unclosed client session\n", - "client_session: \n" - ] - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - "Unclosed connector\n", - "connections: ['deque([(, 1790853.065794291)])', 'deque([(, 1790853.212369458), (, 1790853.254742)])', 'deque([(, 1790853.517245166)])']\n", - "connector: \n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "New Thread ID: 6b59bbaf-a9ba-4122-a67b-f18ce950ec2d\n", - "\n", - "Local memory count (should be unchanged): 19\n", - "\n", - "Memories in Cosmos DB for new thread: 4\n", - " [6b59bbaf...] [cc399b5f...] role=user Can you recommend some good restaurants in New York City?\n", - " [6b59bbaf...] [17c87803...] role=tool {\"query\": \"top restaurants NYC\", \"results\": [\"Carbone\", \"Nob\n", - " [6b59bbaf...] [6a66be86...] role=agent Absolutely! NYC has incredible dining options. For Italian, \n", - " [6b59bbaf...] [287c7246...] role=user I love Italian food. Are there any options that are budget-f\n" - ] - } - ], - "source": [ - "await memory.push_to_cosmos()\n", - "\n", - "# Push a new thread directly to Cosmos DB without adding to local memory first\n", - "new_thread_id = str(uuid.uuid4())\n", - "print(f\"New Thread ID: {new_thread_id}\\n\")\n", - "\n", - "# Add memories directly to Cosmos DB using add_cosmos\n", - "await memory.add_cosmos(\n", - " user_id=\"user-002\", role=\"user\", thread_id=new_thread_id,\n", - " content=\"Can you recommend some good restaurants in New York City?\",\n", - ")\n", - "await memory.add_cosmos(\n", - " user_id=\"user-002\", role=\"tool\", thread_id=new_thread_id,\n", - " content='{\"query\": \"top restaurants NYC\", \"results\": [\"Carbone\", \"Nobu\", \"Katz\\'s Deli\", \"Le Bernardin\"]}',\n", - " metadata={\"tool_name\": \"restaurant_search\", \"tool_call_id\": \"call_abc123\"},\n", - ")\n", - "await memory.add_cosmos(\n", - " user_id=\"user-002\", role=\"agent\", thread_id=new_thread_id,\n", - " content=\"Absolutely! NYC has incredible dining options. For Italian, try Carbone in Greenwich Village. For sushi, Nobu in Tribeca is world-class. For a classic NYC experience, Katz's Delicatessen on the Lower East Side is a must.\",\n", - ")\n", - "await memory.add_cosmos(\n", - " user_id=\"user-002\", role=\"user\", thread_id=new_thread_id,\n", - " content=\"I love Italian food. Are there any options that are budget-friendly?\",\n", - ")\n", - "await memory.add_cosmos(\n", - " user_id=\"user-002\", role=\"agent\", thread_id=new_thread_id,\n", - " content=\"For budget-friendly Italian in NYC, check out L'industrie Pizzeria in Williamsburg or Artichoke Basille's Pizza. Both are highly rated and won't break the bank.\",\n", - ")\n", - "\n", - "# Verify the memories were added directly to Cosmos DB (not in local memory)\n", - "print(f\"Local memory count (should be unchanged): {len(memory.local_memory)}\\n\")\n", - "\n", - "cosmos_results = await memory.get_memories(user_id=\"user-002\", thread_id=new_thread_id)\n", - "print(f\"Memories in Cosmos DB for new thread: {len(cosmos_results)}\")\n", - "for r in cosmos_results:\n", - " print(f\" [{r['thread_id'][:8]}...] [{r['id'][:8]}...] role={r['role']:<6} {r['content'][:60]}\")" - ] - }, - { - "cell_type": "markdown", - "id": "b04679dd", - "metadata": {}, - "source": [ - "### 3c. Retrieve memories from Cosmos DB with `get_memories`\n", - "\n", - "Supports the same filters as `get_local`: `memory_id`, `user_id`, `role`, `memory_type`." - ] - }, - { - "cell_type": "code", - "execution_count": 10, - "id": "a13b2301", - "metadata": { - "ExecuteTime": { - "end_time": "2026-04-07T22:07:11.561128Z", - "start_time": "2026-04-07T22:07:11.474440Z" - }, - "execution": { - "iopub.execute_input": "2026-05-04T20:25:47.113447Z", - "iopub.status.busy": "2026-05-04T20:25:47.113322Z", - "iopub.status.idle": "2026-05-04T20:25:47.262048Z", - "shell.execute_reply": "2026-05-04T20:25:47.260997Z" - } - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Memories for user-001: 19\n", - "\n", - " [807c3bc6...] [c6b6827e...] role=agent type=turn This weekend Seattle will be around 55°F with part\n", - " [807c3bc6...] [101560c2...] role=agent type=turn Sure! I found round-trip flights departing Friday \n", - " [807c3bc6...] [558654f4...] role=user type=turn What's the weather like in Seattle this weekend?\n", - " [c1138077...] [47eef782...] role=user type=turn Whenever you book a flight for me, always book an \n", - " [c1138077...] [30da082b...] role=agent type=turn Will do — no overnight bookings without your expli\n", - " [c1138077...] [40665284...] role=agent type=turn Got it. I'll always select an aisle seat for your \n", - " [c1138077...] [c5d66e1a...] role=user type=turn Never book me into anything that departs or arrive\n", - " [807c3bc6...] [5544d374...] role=user type=turn For trip planning, my workflow is: first check the\n", - " [807c3bc6...] [3ee542c4...] role=agent type=turn Got it. I'll always select an aisle seat for your \n", - " [807c3bc6...] [67cee94e...] role=agent type=turn I found a round-trip on Alaska Airlines for $275 a\n", - " [807c3bc6...] [afe25494...] role=user type=turn Something near Pike Place Market would be great. K\n", - " [c1138077...] [2b7e104d...] role=agent type=turn Noted — I'll follow that order: weather, then flig\n", - " [807c3bc6...] [bb55ae9b...] role=user type=turn Whenever you book a flight for me, always book an \n", - " [c1138077...] [4e5b3a7d...] role=agent type=turn Understood — only hotels with complimentary breakf\n", - " [c1138077...] [15f9f705...] role=user type=turn For trip planning, my workflow is: first check the\n", - " [807c3bc6...] [97401d13...] role=agent type=turn Will do — no overnight bookings without your expli\n", - " [807c3bc6...] [3a42a459...] role=agent type=turn Noted — I'll follow that order: weather, then flig\n", - " [807c3bc6...] [056e8fcb...] role=user type=turn And never book me into anything that departs or ar\n", - " [c1138077...] [705626cf...] role=user type=turn When picking a hotel, only recommend ones that inc\n", - "\n", - "Agent memories: 319\n", - " [26f28370...] [3f04a33a...] role=agent type=turn The PNW has amazing trails like the Wonderland Tra\n", - " [26f28370...] [afebb21e...] role=agent type=turn Running is a great way to stay fit! Do you prefer \n", - " [26f28370...] [9b9a4a3b...] role=agent type=turn Python is very popular for AI/ML workloads. What f\n", - " [96f8868c...] [afbb20b5...] role=agent type=turn Got it! You're based in Seattle working at Microso\n", - " [96f8868c...] [c175440a...] role=agent type=turn 8 years of Python experience is impressive!\n", - " [96f8868c...] [ba7a7168...] role=agent type=turn That's a great area! LLMs combined with RAG can un\n", - " [5827e67c...] [d3497550...] role=agent type=turn Spring is a wonderful time to visit Japan! Cherry \n", - " [5827e67c...] [3edcb648...] role=agent type=turn 10–14 days lets you spend ~5 days in each city plu\n", - " [5827e67c...] [679afa68...] role=agent type=turn Japan has wonderful vegetarian options — try shoji\n", - " [5827e67c...] [44bc0998...] role=agent type=turn Shigetsu inside Tenryu-ji temple is famous for its\n", - " [bec477fa...] [3e65264f...] role=agent type=turn Try aglio e olio — pasta, garlic, olive oil, chill\n", - " [bec477fa...] [9c440b51...] role=agent type=turn Italian cuisine emphasises quality ingredients pre\n", - " [800e58b0...] [966440e7...] role=agent type=turn Great itinerary! Tuscany is amazing in autumn — wi\n", - " [800e58b0...] [3f8e2989...] role=agent type=turn Brunello di Montalcino producers offer wonderful c\n", - " [a3968726...] [900a8c86...] role=agent type=turn Azure Container Apps is a great fit for FastAPI.\n", - " [a3968726...] [91cc1977...] role=agent type=turn Azure has excellent AI services — AI Foundry, AI S\n", - " [09dc7d13...] [b8be927e...] role=agent type=turn That sounds exciting! Tokyo is wonderful in spring\n", - " [09dc7d13...] [f822061c...] role=agent type=turn Great choice! Try Ain Soph in Shinjuku for plant-b\n", - " [09dc7d13...] [4f82afee...] role=agent type=turn A Suica or Pasmo IC card is the easiest option. It\n", - " [6e44bfdf...] [554813b8...] role=agent type=turn Keep a consistent sleep schedule, avoid screens 1 \n", - " [6e44bfdf...] [de33c4e1...] role=agent type=turn Yes — caffeine has a half-life of about 5-6 hours,\n", - " [d78550ff...] [415b6b5a...] role=agent type=turn Of course! Last time we discussed Ain Soph in Shin\n", - " [ticket-d...] [7dff7796...] role=agent type=turn I'm sorry to hear that. Could you share when you b\n", - " [ticket-d...] [f518daf5...] role=agent type=turn Thanks. I'll check warranty status. Could you also\n", - " [ticket-d...] [32fd980e...] role=agent type=turn Verified — the device is under warranty. I've init\n", - " [ticket-7...] [505cdf04...] role=agent type=turn Welcome back, Alex! Yes, that confirms the diagnos\n", - " [ticket-7...] [c8fc1e0a...] role=agent type=turn The Surface Dock 2 or the Anker 778 are excellent \n", - " [ticket-d...] [cdf309ab...] role=agent type=turn Welcome back, Alex! Happy to help with your Micros\n", - " [a912fa55...] [fc43544b...] role=agent type=turn PLAN:\n", - " 1. Research manufacturing impact (battery \n", - " [a912fa55...] [c898a267...] role=agent type=turn FINDING 1 — Manufacturing: EV battery production e\n", - " [a912fa55...] [00f08077...] role=agent type=turn FINDING 2 — Energy source: EVs charged on renewabl\n", - " [a912fa55...] [c2242b74...] role=agent type=turn FINDING 3 — End-of-life: Li-ion battery recycling \n", - " [a912fa55...] [277aa203...] role=agent type=turn RECOMMENDATION: For urban fleets, battery-electric\n", - " [3283e3ce...] [3347c70d...] role=agent type=turn This weekend Seattle will be around 55°F with part\n", - " [3283e3ce...] [7325fcca...] role=agent type=turn Sure! I found round-trip flights departing Friday \n", - " [3283e3ce...] [d4c2d4b1...] role=agent type=turn I found a round-trip on Alaska Airlines for $275 a\n", - " [93f9f763...] [0eb2219f...] role=agent type=turn Absolutely! NYC has incredible dining options. For\n", - " [93f9f763...] [d7de15e4...] role=agent type=turn For budget-friendly Italian in NYC, check out L'in\n", - " [3e8c0348...] [1c85da9a...] role=agent type=turn Sure! I found round-trip flights departing Friday \n", - " [3e8c0348...] [95fd0352...] role=agent type=turn I found a round-trip on Alaska Airlines for $275 a\n", - " [3e8c0348...] [b63df7c7...] role=agent type=turn This weekend Seattle will be around 55°F with part\n", - " [cc7ba964...] [eab7a8dc...] role=agent type=turn Absolutely! NYC has incredible dining options. For\n", - " [cc7ba964...] [043b1f73...] role=agent type=turn For budget-friendly Italian in NYC, check out L'in\n", - " [bfaa7891...] [3ecd376a...] role=agent type=turn Sure! I found round-trip flights departing Friday \n", - " [bfaa7891...] [d78560d0...] role=agent type=turn This weekend Seattle will be around 55°F with part\n", - " [bfaa7891...] [168452e9...] role=agent type=turn I found a round-trip on Alaska Airlines for $275 a\n", - " [69b363f1...] [678aae82...] role=agent type=turn Absolutely! NYC has incredible dining options. For\n", - " [69b363f1...] [1b9459b6...] role=agent type=turn For budget-friendly Italian in NYC, check out L'in\n", - " [67df7d45...] [f48762ba...] role=agent type=turn I found a round-trip on Alaska Airlines for $275 a\n", - " [67df7d45...] [d922da49...] role=agent type=turn This weekend Seattle will be around 55°F with part\n", - " [67df7d45...] [ccdb6efc...] role=agent type=turn Sure! I found round-trip flights departing Friday \n", - " [49296007...] [eed6a8e5...] role=agent type=turn Absolutely! NYC has incredible dining options. For\n", - " [49296007...] [495f8e55...] role=agent type=turn For budget-friendly Italian in NYC, check out L'in\n", - " [0087a4c7...] [c8444bda...] role=agent type=turn Sure! I found round-trip flights departing Friday \n", - " [0087a4c7...] [83b493a7...] role=agent type=turn This weekend Seattle will be around 55°F with part\n", - " [0087a4c7...] [1ff00508...] role=agent type=turn I found a round-trip on Alaska Airlines for $275 a\n", - " [a62f6290...] [bb3e7800...] role=agent type=turn Absolutely! NYC has incredible dining options. For\n", - " [a62f6290...] [926a875e...] role=agent type=turn For budget-friendly Italian in NYC, check out L'in\n", - " [154bf409...] [799c324a...] role=agent type=turn I found a round-trip on Alaska Airlines for $275 a\n", - " [154bf409...] [3234f409...] role=agent type=turn This weekend Seattle will be around 55°F with part\n", - " [154bf409...] [e635815b...] role=agent type=turn Sure! I found round-trip flights departing Friday \n", - " [0fcdecee...] [c2f5d5a5...] role=agent type=turn Absolutely! NYC has incredible dining options. For\n", - " [0fcdecee...] [cba4eb09...] role=agent type=turn For budget-friendly Italian in NYC, check out L'in\n", - " [t1...] [2af2a94e...] role=agent type=turn Agent response\n", - " [78ada42c...] [26821e00...] role=agent type=turn That sounds exciting! Tokyo is wonderful in spring\n", - " [78ada42c...] [104974d7...] role=agent type=turn Great choice! Try Ain Soph in Shinjuku for plant-b\n", - " [78ada42c...] [caaa7d25...] role=agent type=turn A Suica or Pasmo IC card is the easiest option. It\n", - " [dd0ad3f9...] [81fe48ff...] role=agent type=turn Keep a consistent sleep schedule, avoid screens 1 \n", - " [dd0ad3f9...] [e5b990ab...] role=agent type=turn Yes — caffeine has a half-life of about 5-6 hours,\n", - " [a402c62b...] [426026b6...] role=agent type=turn Of course! Last time we discussed Ain Soph in Shin\n", - " [e2e2402e...] [d37cf5bf...] role=agent type=turn Spring is a wonderful time to visit Japan! Cherry \n", - " [e2e2402e...] [5eebb35c...] role=agent type=turn 10–14 days lets you spend ~5 days in each city plu\n", - " [e2e2402e...] [307dc427...] role=agent type=turn Japan has wonderful vegetarian options — try shoji\n", - " [e2e2402e...] [53e01cf6...] role=agent type=turn Shigetsu inside Tenryu-ji temple is famous for its\n", - " [thread-0...] [72aadb29...] role=agent type=turn Cosmos DB is fantastic for low-latency global apps\n", - " [thread-0...] [aa7d2515...] role=agent type=turn Yes — DiskANN indexes power semantic search native\n", - " [thread-0...] [77886873...] role=agent type=turn HPK lets you co-locate related items for efficient\n", - " [thread-4...] [3e7ac221...] role=agent type=turn Cosmos is great\n", - " [thread-4...] [5dc2cf5b...] role=agent type=turn yes DiskANN\n", - " [thread-4...] [99f7cf33...] role=agent type=turn colocates data\n", - " [thread-0...] [0349d4e5...] role=agent type=turn Cosmos DB is fantastic for low-latency global apps\n", - " [thread-0...] [efea8437...] role=agent type=turn Yes — DiskANN indexes power semantic search native\n", - " [thread-0...] [3bec5407...] role=agent type=turn HPK lets you co-locate related items for efficient\n", - " [thread-0...] [3cb84a20...] role=agent type=turn Cosmos DB is fantastic for low-latency global apps\n", - " [thread-0...] [57ea857b...] role=agent type=turn Yes — DiskANN indexes power semantic search native\n", - " [thread-0...] [0f628302...] role=agent type=turn HPK lets you co-locate related items for efficient\n", - " [thread-0...] [06666f17...] role=agent type=turn Cosmos DB is fantastic for low-latency global apps\n", - " [thread-0...] [548dd8a9...] role=agent type=turn Yes — DiskANN indexes power semantic search native\n", - " [thread-0...] [bd139b4f...] role=agent type=turn HPK lets you co-locate related items for efficient\n", - " [thread-2...] [02c7e958...] role=agent type=turn Great choice! Hoh Rainforest and Hurricane Ridge a\n", - " [thread-2...] [6def8d60...] role=agent type=turn You'll need a wilderness permit from recreation.go\n", - " [thread-0...] [b8db28d6...] role=agent type=turn Cosmos DB is fantastic for low-latency global apps\n", - " [thread-0...] [cbf0f0be...] role=agent type=turn Yes — DiskANN indexes power semantic search native\n", - " [thread-0...] [771971c9...] role=agent type=turn HPK lets you co-locate related items for efficient\n", - " [thread-0...] [80f6b374...] role=agent type=turn Cosmos DB is fantastic for low-latency global apps\n", - " [thread-0...] [c5c544d6...] role=agent type=turn Yes — DiskANN indexes power semantic search native\n", - " [thread-0...] [2c69aa14...] role=agent type=turn HPK lets you co-locate related items for efficient\n", - " [thread-0...] [b9161808...] role=agent type=turn Cosmos DB is fantastic for low-latency global apps\n", - " [thread-0...] [a27126d6...] role=agent type=turn Yes — DiskANN indexes power semantic search native\n", - " [thread-0...] [98e2d8de...] role=agent type=turn HPK lets you co-locate related items for efficient\n", - " [thread-0...] [805cf355...] role=agent type=turn Cosmos DB is fantastic for low-latency global apps\n", - " [thread-0...] [7c3af0fe...] role=agent type=turn Yes — DiskANN indexes power semantic search native\n", - " [thread-0...] [72cdd403...] role=agent type=turn HPK lets you co-locate related items for efficient\n", - " [thread-b...] [30296030...] role=agent type=turn Great choice! Hoh Rainforest and Hurricane Ridge a\n", - " [thread-b...] [a64b3ad1...] role=agent type=turn You'll need a wilderness permit from recreation.go\n", - " [t1...] [8422cbfd...] role=agent type=turn Agent response\n", - " [d0421430...] [47eae793...] role=agent type=turn Got it! You're based in Seattle working at Microso\n", - " [d0421430...] [13017c8c...] role=agent type=turn 8 years of Python experience is impressive!\n", - " [d0421430...] [22d94ba6...] role=agent type=turn That's a great area! LLMs combined with RAG can un\n", - " [dd381d0c...] [8f58418d...] role=agent type=turn Spring is a wonderful time to visit Japan! Cherry \n", - " [dd381d0c...] [d7e35289...] role=agent type=turn 10–14 days lets you spend ~5 days in each city plu\n", - " [dd381d0c...] [46fda2e6...] role=agent type=turn Japan has wonderful vegetarian options — try shoji\n", - " [dd381d0c...] [de105f27...] role=agent type=turn Shigetsu inside Tenryu-ji temple is famous for its\n", - " [1a5388ca...] [f64a1f54...] role=agent type=turn Try aglio e olio — pasta, garlic, olive oil, chill\n", - " [1a5388ca...] [efb3613c...] role=agent type=turn Italian cuisine emphasises quality ingredients pre\n", - " [462c0b89...] [4e8648c0...] role=agent type=turn Great itinerary! Tuscany is amazing in autumn — wi\n", - " [462c0b89...] [1fe994b2...] role=agent type=turn Brunello di Montalcino producers offer wonderful c\n", - " [82849ac6...] [24cf1624...] role=agent type=turn Azure Container Apps is a great fit for FastAPI.\n", - " [82849ac6...] [7ea3e0ac...] role=agent type=turn Azure has excellent AI services — AI Foundry, AI S\n", - " [e9d75005...] [831c50e2...] role=agent type=turn The PNW has amazing trails like the Wonderland Tra\n", - " [e9d75005...] [3e754348...] role=agent type=turn Running is a great way to stay fit! Do you prefer \n", - " [e9d75005...] [2d8ad427...] role=agent type=turn Python is very popular for AI/ML workloads. What f\n", - " [75d8811b...] [f792c4e7...] role=agent type=turn That sounds exciting! Tokyo is wonderful in spring\n", - " [75d8811b...] [8a41f22a...] role=agent type=turn Great choice! Try Ain Soph in Shinjuku for plant-b\n", - " [75d8811b...] [20f5c5de...] role=agent type=turn A Suica or Pasmo IC card is the easiest option. It\n", - " [e8f0a465...] [efcc37f1...] role=agent type=turn Keep a consistent sleep schedule, avoid screens 1 \n", - " [e8f0a465...] [d1569024...] role=agent type=turn Yes — caffeine has a half-life of about 5-6 hours,\n", - " [45853aeb...] [2094ee58...] role=agent type=turn Of course! Last time we discussed Ain Soph in Shin\n", - " [ticket-9...] [6743a768...] role=agent type=turn I'm sorry to hear that. Could you share when you b\n", - " [ticket-9...] [5cf00dc0...] role=agent type=turn Thanks. I'll check warranty status. Could you also\n", - " [ticket-9...] [3aec4d8c...] role=agent type=turn Verified — the device is under warranty. I've init\n", - " [ticket-f...] [5d5a3234...] role=agent type=turn Welcome back, Alex! Yes, that confirms the diagnos\n", - " [ticket-f...] [e2aff8e0...] role=agent type=turn The Surface Dock 2 or the Anker 778 are excellent \n", - " [ticket-b...] [c8451dd2...] role=agent type=turn Welcome back, Alex! Happy to help with your Micros\n", - " [84350066...] [cc6e41cf...] role=agent type=turn PLAN:\n", - " 1. Research manufacturing impact (battery \n", - " [84350066...] [c8a01395...] role=agent type=turn FINDING 1 — Manufacturing: EV battery production e\n", - " [84350066...] [9a5c4e1d...] role=agent type=turn FINDING 2 — Energy source: EVs charged on renewabl\n", - " [84350066...] [6b1206fd...] role=agent type=turn FINDING 3 — End-of-life: Li-ion battery recycling \n", - " [84350066...] [25903ff0...] role=agent type=turn RECOMMENDATION: For urban fleets, battery-electric\n", - " [4c99b9ba...] [d1d42c19...] role=agent type=turn This weekend Seattle will be around 55°F with part\n", - " [4c99b9ba...] [6587d05b...] role=agent type=turn Sure! I found round-trip flights departing Friday \n", - " [4c99b9ba...] [f133d14c...] role=agent type=turn I found a round-trip on Alaska Airlines for $275 a\n", - " [73810c6b...] [4a24bc5a...] role=agent type=turn Absolutely! NYC has incredible dining options. For\n", - " [73810c6b...] [6037ae5b...] role=agent type=turn For budget-friendly Italian in NYC, check out L'in\n", - " [34249f73...] [eb3f86b6...] role=agent type=turn I found a round-trip on Alaska Airlines for $275 a\n", - " [34249f73...] [81d468be...] role=agent type=turn This weekend Seattle will be around 55°F with part\n", - " [34249f73...] [71a3704f...] role=agent type=turn Sure! I found round-trip flights departing Friday \n", - " [eb1efd30...] [d943c1a2...] role=agent type=turn Absolutely! NYC has incredible dining options. For\n", - " [eb1efd30...] [fbf6a5a9...] role=agent type=turn For budget-friendly Italian in NYC, check out L'in\n", - " [ae1eb483...] [a2d755ba...] role=agent type=turn Absolutely! NYC has incredible dining options. For\n", - " [ae1eb483...] [1eabf113...] role=agent type=turn For budget-friendly Italian in NYC, check out L'in\n", - " [151e417e...] [00f1ec4f...] role=agent type=turn This weekend Seattle will be around 55°F with part\n", - " [151e417e...] [a49ad927...] role=agent type=turn Sure! I found round-trip flights departing Friday \n", - " [151e417e...] [374d57e5...] role=agent type=turn I found a round-trip on Alaska Airlines for $275 a\n", - " [75b607c1...] [18d7b346...] role=agent type=turn Absolutely! NYC has incredible dining options. For\n", - " [75b607c1...] [22c624a7...] role=agent type=turn For budget-friendly Italian in NYC, check out L'in\n", - " [18ec5623...] [20ddefe7...] role=agent type=turn This weekend Seattle will be around 55°F with part\n", - " [18ec5623...] [17a3e670...] role=agent type=turn I found a round-trip on Alaska Airlines for $275 a\n", - " [18ec5623...] [d53dad25...] role=agent type=turn Sure! I found round-trip flights departing Friday \n", - " [6514d03a...] [2fbee9d5...] role=agent type=turn Absolutely! NYC has incredible dining options. For\n", - " [6514d03a...] [08f3076a...] role=agent type=turn For budget-friendly Italian in NYC, check out L'in\n", - " [thread-0...] [1f6ffd63...] role=agent type=turn Cosmos DB is fantastic for low-latency global apps\n", - " [thread-0...] [3a203195...] role=agent type=turn Yes — DiskANN indexes power semantic search native\n", - " [thread-0...] [a92f4b54...] role=agent type=turn HPK lets you co-locate related items for efficient\n", - " [thread-0...] [6370552e...] role=agent type=turn Cosmos DB is fantastic for low-latency global apps\n", - " [thread-0...] [e38ecbee...] role=agent type=turn Yes — DiskANN indexes power semantic search native\n", - " [thread-0...] [72ddcc06...] role=agent type=turn HPK lets you co-locate related items for efficient\n", - " [thread-5...] [c3c713fa...] role=agent type=turn Great choice! Hoh Rainforest and Hurricane Ridge a\n", - " [thread-5...] [c7364e90...] role=agent type=turn You'll need a wilderness permit from recreation.go\n", - " [thread-3...] [c527bd97...] role=agent type=turn Great choice! Hoh Rainforest and Hurricane Ridge a\n", - " [thread-3...] [7371ee6c...] role=agent type=turn You'll need a wilderness permit from recreation.go\n", - " [thread-0...] [95d62050...] role=agent type=turn Cosmos DB is fantastic for low-latency global apps\n", - " [thread-0...] [be0085d4...] role=agent type=turn Yes — DiskANN indexes power semantic search native\n", - " [thread-0...] [c09230e7...] role=agent type=turn HPK lets you co-locate related items for efficient\n", - " [thread-c...] [3582eb74...] role=agent type=turn Great choice! Hoh Rainforest and Hurricane Ridge a\n", - " [thread-c...] [598dff39...] role=agent type=turn You'll need a wilderness permit from recreation.go\n", - " [2dec0199...] [d53348b1...] role=agent type=turn This weekend Seattle will be around 55°F with part\n", - " [2dec0199...] [048b347d...] role=agent type=turn Sure! I found round-trip flights departing Friday \n", - " [2dec0199...] [f3b2e998...] role=agent type=turn I found a round-trip on Alaska Airlines for $275 a\n", - " [97d1c7d2...] [45d6f3eb...] role=agent type=turn Absolutely! NYC has incredible dining options. For\n", - " [97d1c7d2...] [61ec5e9b...] role=agent type=turn For budget-friendly Italian in NYC, check out L'in\n", - " [437580e8...] [741b0b83...] role=agent type=turn Absolutely! NYC has incredible dining options. For\n", - " [437580e8...] [ebb06dba...] role=agent type=turn For budget-friendly Italian in NYC, check out L'in\n", - " [9ed6e905...] [f200bbc0...] role=agent type=turn This weekend Seattle will be around 55°F with part\n", - " [9ed6e905...] [59877c89...] role=agent type=turn Sure! I found round-trip flights departing Friday \n", - " [9ed6e905...] [9a2a651c...] role=agent type=turn I found a round-trip on Alaska Airlines for $275 a\n", - " [9ed6e905...] [bfb488e8...] role=agent type=turn Got it. I'll always select an aisle seat for your \n", - " [9ed6e905...] [0d216b3d...] role=agent type=turn Understood — I'll confirm with you before booking \n", - " [9ed6e905...] [c9b3d5ab...] role=agent type=turn Will do. I'll filter hotel suggestions to only tho\n", - " [ede78157...] [d89aa694...] role=agent type=turn Absolutely! NYC has incredible dining options. For\n", - " [ede78157...] [bda83ce2...] role=agent type=turn For budget-friendly Italian in NYC, check out L'in\n", - " [e2422aed...] [0cc39f4a...] role=agent type=turn This weekend Seattle will be around 55°F with part\n", - " [e2422aed...] [d2d28ce4...] role=agent type=turn I found a round-trip on Alaska Airlines for $275 a\n", - " [e2422aed...] [a0ebc75c...] role=agent type=turn Got it. I'll always select an aisle seat for your \n", - " [e2422aed...] [a07d551b...] role=agent type=turn Sure! I found round-trip flights departing Friday \n", - " [e2422aed...] [fac38202...] role=agent type=turn Will do. I'll filter hotel suggestions to only tho\n", - " [e2422aed...] [01b514c0...] role=agent type=turn Understood — I'll confirm with you before booking \n", - " [ba2753c5...] [f62c3be1...] role=agent type=turn Absolutely! NYC has incredible dining options. For\n", - " [ba2753c5...] [5f541c2a...] role=agent type=turn For budget-friendly Italian in NYC, check out L'in\n", - " [d3a73355...] [7fc1a400...] role=agent type=turn This weekend Seattle will be around 55°F with part\n", - " [d3a73355...] [a895d314...] role=agent type=turn Sure! I found round-trip flights departing Friday \n", - " [d3a73355...] [05901836...] role=agent type=turn I found a round-trip on Alaska Airlines for $275 a\n", - " [d3a73355...] [a762cd26...] role=agent type=turn Got it. I'll always select an aisle seat for your \n", - " [d3a73355...] [81ce6316...] role=agent type=turn Understood — I'll confirm with you before booking \n", - " [d3a73355...] [86a404c9...] role=agent type=turn Will do. I'll filter hotel suggestions to only tho\n", - " [e9ed3070...] [9cf12919...] role=agent type=turn Absolutely! NYC has incredible dining options. For\n", - " [e9ed3070...] [8712d011...] role=agent type=turn For budget-friendly Italian in NYC, check out L'in\n", - " [92fcfce7...] [9b497f45...] role=agent type=turn This weekend Seattle will be around 55°F with part\n", - " [92fcfce7...] [2ac1f955...] role=agent type=turn Sure! I found round-trip flights departing Friday \n", - " [92fcfce7...] [340d4e33...] role=agent type=turn I found a round-trip on Alaska Airlines for $275 a\n", - " [92fcfce7...] [3a3d1544...] role=agent type=turn Got it. I'll always select an aisle seat for your \n", - " [92fcfce7...] [ba8c8d52...] role=agent type=turn Noted — I'll follow that order: weather, then flig\n", - " [92fcfce7...] [2485f06d...] role=agent type=turn Will do — no overnight bookings without your expli\n", - " [26392a45...] [41f1ba4d...] role=agent type=turn Absolutely! NYC has incredible dining options. For\n", - " [26392a45...] [54cf4894...] role=agent type=turn For budget-friendly Italian in NYC, check out L'in\n", - " [f0fd9a78...] [7df1661f...] role=agent type=turn This weekend Seattle will be around 55°F with part\n", - " [f0fd9a78...] [1f84e8ac...] role=agent type=turn Sure! I found round-trip flights departing Friday \n", - " [f0fd9a78...] [034bd98c...] role=agent type=turn I found a round-trip on Alaska Airlines for $275 a\n", - " [f0fd9a78...] [9bc141ef...] role=agent type=turn Got it. I'll always select an aisle seat for your \n", - " [f0fd9a78...] [51227197...] role=agent type=turn Noted — I'll follow that order: weather, then flig\n", - " [f0fd9a78...] [f6cd2184...] role=agent type=turn Will do — no overnight bookings without your expli\n", - " [5c3287a4...] [5955e0e9...] role=agent type=turn Absolutely! NYC has incredible dining options. For\n", - " [5c3287a4...] [9866371e...] role=agent type=turn For budget-friendly Italian in NYC, check out L'in\n", - " [b48abfd4...] [04627b70...] role=agent type=turn This weekend Seattle will be around 55°F with part\n", - " [b48abfd4...] [8cd6cac1...] role=agent type=turn Sure! I found round-trip flights departing Friday \n", - " [b48abfd4...] [b022017e...] role=agent type=turn I found a round-trip on Alaska Airlines for $275 a\n", - " [b48abfd4...] [83a30869...] role=agent type=turn Got it. I'll always select an aisle seat for your \n", - " [b48abfd4...] [1d2f503d...] role=agent type=turn Noted — I'll follow that order: weather, then flig\n", - " [b48abfd4...] [a087dfa4...] role=agent type=turn Will do — no overnight bookings without your expli\n", - " [dbdc90d0...] [8aaead6f...] role=agent type=turn Absolutely! NYC has incredible dining options. For\n", - " [dbdc90d0...] [e2e684e6...] role=agent type=turn For budget-friendly Italian in NYC, check out L'in\n", - " [a1210ca7...] [8486acee...] role=agent type=turn This weekend Seattle will be around 55°F with part\n", - " [a1210ca7...] [1329afa7...] role=agent type=turn Sure! I found round-trip flights departing Friday \n", - " [a1210ca7...] [0712700a...] role=agent type=turn I found a round-trip on Alaska Airlines for $275 a\n", - " [a1210ca7...] [3a6887c4...] role=agent type=turn Got it. I'll always select an aisle seat for your \n", - " [a1210ca7...] [9c18002a...] role=agent type=turn Noted — I'll follow that order: weather, then flig\n", - " [a1210ca7...] [7835ebd2...] role=agent type=turn Will do — no overnight bookings without your expli\n", - " [e97abcfc...] [c40acde3...] role=agent type=turn Absolutely! NYC has incredible dining options. For\n", - " [e97abcfc...] [25890ac3...] role=agent type=turn For budget-friendly Italian in NYC, check out L'in\n", - " [8f82e8c2...] [86395b5c...] role=agent type=turn This weekend Seattle will be around 55°F with part\n", - " [8f82e8c2...] [f810ee90...] role=agent type=turn Sure! I found round-trip flights departing Friday \n", - " [8f82e8c2...] [2c53284f...] role=agent type=turn I found a round-trip on Alaska Airlines for $275 a\n", - " [8f82e8c2...] [03f4f090...] role=agent type=turn Got it. I'll always select an aisle seat for your \n", - " [8f82e8c2...] [e61823c0...] role=agent type=turn Noted — I'll follow that order: weather, then flig\n", - " [8f82e8c2...] [de44f072...] role=agent type=turn Will do — no overnight bookings without your expli\n", - " [925c1a31...] [1bc3a721...] role=agent type=turn Got it. I'll always select an aisle seat for your \n", - " [925c1a31...] [81c4308b...] role=agent type=turn Noted — I'll follow that order: weather, then flig\n", - " [925c1a31...] [bbbce8be...] role=agent type=turn Will do — no overnight bookings without your expli\n", - " [925c1a31...] [490aeb85...] role=agent type=turn Understood — only hotels with complimentary breakf\n", - " [1aba6dfb...] [67c9d6d2...] role=agent type=turn Absolutely! NYC has incredible dining options. For\n", - " [1aba6dfb...] [f973d01f...] role=agent type=turn For budget-friendly Italian in NYC, check out L'in\n", - " [df2c66e2...] [885e20a1...] role=agent type=turn Noted — I'll follow that order: weather, then flig\n", - " [df2c66e2...] [a14e680c...] role=agent type=turn This weekend Seattle will be around 55°F with part\n", - " [df2c66e2...] [291b33d2...] role=agent type=turn Got it. I'll always select an aisle seat for your \n", - " [df2c66e2...] [0085b70d...] role=agent type=turn Sure! I found round-trip flights departing Friday \n", - " [ae1bb147...] [49f590c9...] role=agent type=turn Understood — only hotels with complimentary breakf\n", - " [ae1bb147...] [36fc3840...] role=agent type=turn Got it. I'll always select an aisle seat for your \n", - " [df2c66e2...] [d2b63415...] role=agent type=turn Will do — no overnight bookings without your expli\n", - " [df2c66e2...] [293d9579...] role=agent type=turn I found a round-trip on Alaska Airlines for $275 a\n", - " [ae1bb147...] [6d68214d...] role=agent type=turn Will do — no overnight bookings without your expli\n", - " [ae1bb147...] [88479523...] role=agent type=turn Noted — I'll follow that order: weather, then flig\n", - " [85e74267...] [32b3911a...] role=agent type=turn Absolutely! NYC has incredible dining options. For\n", - " [85e74267...] [2594fb41...] role=agent type=turn For budget-friendly Italian in NYC, check out L'in\n", - " [1a2686a2...] [72643b0a...] role=agent type=turn Sure! I found round-trip flights departing Friday \n", - " [1a2686a2...] [0ce72055...] role=agent type=turn This weekend Seattle will be around 55°F with part\n", - " [1a2686a2...] [c91a8397...] role=agent type=turn Will do — no overnight bookings without your expli\n", - " [1a2686a2...] [b0f0f031...] role=agent type=turn I found a round-trip on Alaska Airlines for $275 a\n", - " [1a2686a2...] [de786284...] role=agent type=turn Got it. I'll always select an aisle seat for your \n", - " [1a2686a2...] [863a0e92...] role=agent type=turn Noted — I'll follow that order: weather, then flig\n", - " [6c5e0b18...] [9d94e048...] role=agent type=turn Noted — I'll follow that order: weather, then flig\n", - " [6c5e0b18...] [b3cac85c...] role=agent type=turn Got it. I'll always select an aisle seat for your \n", - " [6c5e0b18...] [bce69f91...] role=agent type=turn Will do — no overnight bookings without your expli\n", - " [6c5e0b18...] [096d24da...] role=agent type=turn Understood — only hotels with complimentary breakf\n", - " [ac8cf2db...] [e388f6c6...] role=agent type=turn Absolutely! NYC has incredible dining options. For\n", - " [ac8cf2db...] [ad4aa222...] role=agent type=turn For budget-friendly Italian in NYC, check out L'in\n", - " [0df5b6dc...] [26681a8e...] role=agent type=turn Around 55°F with partly cloudy skies on Saturday a\n", - " [0df5b6dc...] [864f087a...] role=agent type=turn I found a $275 Alaska Airlines round-trip and a $1\n", - " [0df5b6dc...] [0cdaa994...] role=agent type=turn Got it — aisle seats only.\n", - " [0df5b6dc...] [4f35ab5b...] role=agent type=turn Noted — weather → flights → hotel.\n", - " [0df5b6dc...] [ab9e45ba...] role=agent type=turn Understood — no overnight bookings without your ap\n", - " [bc4a98cb...] [1076e63c...] role=agent type=turn Around 55°F with partly cloudy skies on Saturday a\n", - " [bc4a98cb...] [6ba1d437...] role=agent type=turn I found a $275 Alaska Airlines round-trip and a $1\n", - " [bc4a98cb...] [fcf81c7c...] role=agent type=turn Got it — aisle seats only.\n", - " [bc4a98cb...] [45e487f4...] role=agent type=turn Noted — weather → flights → hotel.\n", - " [bc4a98cb...] [1c81ae44...] role=agent type=turn Understood — no overnight bookings without your ap\n", - " [bdd72079...] [9a99982d...] role=agent type=turn Around 55°F with partly cloudy skies on Saturday a\n", - " [bdd72079...] [f17db44a...] role=agent type=turn I found a $275 Alaska Airlines round-trip and a $1\n", - " [bdd72079...] [804c1f25...] role=agent type=turn Got it — aisle seats only.\n", - " [bdd72079...] [56d4e04b...] role=agent type=turn Noted — weather → flights → hotel.\n", - " [bdd72079...] [9857a10d...] role=agent type=turn Understood — no overnight bookings without your ap\n", - " [42b91b2c...] [aee54464...] role=agent type=turn Around 55°F with partly cloudy skies on Saturday a\n", - " [42b91b2c...] [2610f0f2...] role=agent type=turn I found a $275 Alaska Airlines round-trip and a $1\n", - " [42b91b2c...] [81e4ae3f...] role=agent type=turn Got it — aisle seats only.\n", - " [42b91b2c...] [88c29041...] role=agent type=turn Noted — weather → flights → hotel.\n", - " [42b91b2c...] [aec0a2ba...] role=agent type=turn Understood — no overnight bookings without your ap\n", - " [e50f775e...] [88a718fa...] role=agent type=turn This weekend Seattle will be around 55°F with part\n", - " [e50f775e...] [5d25077d...] role=agent type=turn Sure! I found round-trip flights departing Friday \n", - " [e50f775e...] [4f8721a6...] role=agent type=turn I found a round-trip on Alaska Airlines for $275 a\n", - " [e50f775e...] [3f00a18c...] role=agent type=turn Got it. I'll always select an aisle seat for your \n", - " [e50f775e...] [4d4926ec...] role=agent type=turn Noted — I'll follow that order: weather, then flig\n", - " [e50f775e...] [96aa9017...] role=agent type=turn Will do — no overnight bookings without your expli\n", - " [8f42e1b5...] [26ba3a10...] role=agent type=turn Got it. I'll always select an aisle seat for your \n", - " [8f42e1b5...] [2430022a...] role=agent type=turn Noted — I'll follow that order: weather, then flig\n", - " [8f42e1b5...] [300757b0...] role=agent type=turn Will do — no overnight bookings without your expli\n", - " [8f42e1b5...] [c997e440...] role=agent type=turn Understood — only hotels with complimentary breakf\n", - " [7b8fc78b...] [0e5d8a0a...] role=agent type=turn Absolutely! NYC has incredible dining options. For\n", - " [7b8fc78b...] [c0437ffe...] role=agent type=turn For budget-friendly Italian in NYC, check out L'in\n", - " [807c3bc6...] [c6b6827e...] role=agent type=turn This weekend Seattle will be around 55°F with part\n", - " [807c3bc6...] [101560c2...] role=agent type=turn Sure! I found round-trip flights departing Friday \n", - " [c1138077...] [30da082b...] role=agent type=turn Will do — no overnight bookings without your expli\n", - " [c1138077...] [40665284...] role=agent type=turn Got it. I'll always select an aisle seat for your \n", - " [807c3bc6...] [3ee542c4...] role=agent type=turn Got it. I'll always select an aisle seat for your \n", - " [807c3bc6...] [67cee94e...] role=agent type=turn I found a round-trip on Alaska Airlines for $275 a\n", - " [c1138077...] [2b7e104d...] role=agent type=turn Noted — I'll follow that order: weather, then flig\n", - " [c1138077...] [4e5b3a7d...] role=agent type=turn Understood — only hotels with complimentary breakf\n", - " [807c3bc6...] [97401d13...] role=agent type=turn Will do — no overnight bookings without your expli\n", - " [807c3bc6...] [3a42a459...] role=agent type=turn Noted — I'll follow that order: weather, then flig\n", - " [6b59bbaf...] [6a66be86...] role=agent type=turn Absolutely! NYC has incredible dining options. For\n", - " [6b59bbaf...] [546aff6a...] role=agent type=turn For budget-friendly Italian in NYC, check out L'in\n" - ] - } - ], - "source": [ - "# Get all memories for user-001\n", - "results = await memory.get_memories(user_id=USER_ID)\n", - "print(f\"Memories for user-001: {len(results)}\\n\")\n", - "for r in results:\n", - " print(f\" [{r['thread_id'][:8]}...] [{r['id'][:8]}...] role={r['role']:<6} type={r['type']:<8} {r['content'][:50]}\")\n", - "\n", - "# Get only agent memories\n", - "agent_results = await memory.get_memories(role=\"agent\")\n", - "print(f\"\\nAgent memories: {len(agent_results)}\")\n", - "for r in agent_results:\n", - " print(f\" [{r['thread_id'][:8]}...] [{r['id'][:8]}...] role={r['role']:<6} type={r['type']:<8} {r['content'][:50]}\")" - ] - }, - { - "cell_type": "markdown", - "id": "7e98a7c2", - "metadata": {}, - "source": [ - "### 3d. Update & Delete in Cosmos DB\n", - "\n", - "If the content changes, the embedding is automatically re-generated (awaited)." - ] - }, - { - "cell_type": "code", - "execution_count": 11, - "id": "b0b61df9", - "metadata": { - "ExecuteTime": { - "end_time": "2026-04-07T22:07:16.784062Z", - "start_time": "2026-04-07T22:07:16.651689Z" - }, - "execution": { - "iopub.execute_input": "2026-05-04T20:25:47.264618Z", - "iopub.status.busy": "2026-05-04T20:25:47.264449Z", - "iopub.status.idle": "2026-05-04T20:25:47.395572Z", - "shell.execute_reply": "2026-05-04T20:25:47.394909Z" - } - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Before: Something near Pike Place Market would be great. Keep flights under $300 round trip and hotels under $200/night.\n", - "\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "After: Something near Pike Place Market would be great. Keep flights under $300 round trip and hotels under $200/night.\n" - ] - } - ], - "source": [ - "# Update the user's budget message to add a hotel budget constraint\n", - "user_msgs = await memory.get_memories(user_id=USER_ID, role=\"user\")\n", - "target = [m for m in user_msgs if \"Pike Place\" in m[\"content\"]][0]\n", - "print(f\"Before: {target['content']}\\n\")\n", - "\n", - "await memory.update_cosmos(\n", - " memory_id=target[\"id\"],\n", - " content=\"Something near Pike Place Market would be great. Keep flights under $300 round trip and hotels under $200/night.\",\n", - " metadata={\"edited\": True, \"reason\": \"user clarified hotel budget\"},\n", - ")\n", - "\n", - "updated = (await memory.get_memories(memory_id=target[\"id\"]))[0]\n", - "print(f\"After: {updated['content']}\")" - ] - }, - { - "cell_type": "code", - "execution_count": 12, - "id": "74874763", - "metadata": { - "ExecuteTime": { - "end_time": "2026-04-07T22:07:36.933417Z", - "start_time": "2026-04-07T22:07:36.641107Z" - }, - "execution": { - "iopub.execute_input": "2026-05-04T20:25:47.397837Z", - "iopub.status.busy": "2026-05-04T20:25:47.397690Z", - "iopub.status.idle": "2026-05-04T20:25:50.012907Z", - "shell.execute_reply": "2026-05-04T20:25:50.012517Z" - } - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "{'id': '17c87803-34e3-4410-ba71-0f16d867141d', 'user_id': 'user-002', 'thread_id': '6b59bbaf-a9ba-4122-a67b-f18ce950ec2d', 'role': 'tool', 'type': 'turn', 'content': '{\"query\": \"top restaurants NYC\", \"results\": [\"Carbone\", \"Nobu\", \"Katz\\'s Deli\", \"Le Bernardin\"]}', 'metadata': {'tool_name': 'restaurant_search', 'tool_call_id': 'call_abc123'}, 'created_at': '2026-05-04T20:25:46.986153+00:00', 'tags': [], '_rid': 'EShyAMqZjm9EMjEBAAAAAA==', '_self': 'dbs/EShyAA==/colls/EShyAMqZjm8=/docs/EShyAMqZjm9EMjEBAAAAAA==/', '_etag': '\"00006c06-0000-0800-0000-69f900cb0000\"', '_attachments': 'attachments/', '_ts': 1777926347}\n", - "Deleted tool memory 17c87803...\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\n", - "Remaining memories in Cosmos DB: 1024\n", - " [9060aacb...] [fact_31f...] role=system type=fact The user is building a recommendation engine for a\n", - " [9060aacb...] [fact_24c...] role=system type=fact The user chose a hybrid recommendation approach co\n", - " [9060aacb...] [fact_801...] role=system type=fact The user plans to use embeddings generated from bo\n", - " [9060aacb...] [fact_9e2...] role=system type=fact The user prefers Python for development.\n", - " [9060aacb...] [fact_d31...] role=system type=fact The user wants to use FastAPI for the API layer of\n", - " [9060aacb...] [ep_63631...] role=system type=episodic Last quarter, the user implemented a similar recom\n", - " [9060aacb...] [summary_...] role=system type=summary The user discussed building a hybrid recommendatio\n", - " [26f28370...] [050930c1...] role=user type=turn I love hiking in the Pacific Northwest\n", - " [26f28370...] [3f04a33a...] role=agent type=turn The PNW has amazing trails like the Wonderland Tra\n", - " [26f28370...] [1286f137...] role=user type=turn I usually run 5 miles every morning before work\n", - " [26f28370...] [afebb21e...] role=agent type=turn Running is a great way to stay fit! Do you prefer \n", - " [26f28370...] [9b9a4a3b...] role=agent type=turn Python is very popular for AI/ML workloads. What f\n", - " [96f8868c...] [6f2b06d0...] role=user type=turn I live in Seattle and work at Microsoft as a softw\n", - " [96f8868c...] [afbb20b5...] role=agent type=turn Got it! You're based in Seattle working at Microso\n", - " [96f8868c...] [f3ed4abc...] role=user type=turn My favourite programming language is Python and I'\n", - " [96f8868c...] [c175440a...] role=agent type=turn 8 years of Python experience is impressive!\n", - " [96f8868c...] [b14f468d...] role=user type=turn I'm currently working on a project involving large\n", - " [96f8868c...] [ba7a7168...] role=agent type=turn That's a great area! LLMs combined with RAG can un\n", - " [96f8868c...] [b10d9418...] role=user type=turn Last spring I went hiking on Mount Rainier with my\n", - " [96f8868c...] [8adba5c7...] role=user type=turn When debugging an LLM, always check the prompt fir\n", - " [96f8868c...] [fact_486...] role=system type=fact The user lives in Seattle.\n", - " [96f8868c...] [fact_c52...] role=system type=fact The user works at Microsoft as a software engineer\n", - " [96f8868c...] [fact_af9...] role=system type=fact The user's favorite programming language is Python\n", - " [96f8868c...] [fact_08a...] role=system type=fact The user has 8 years of experience using Python.\n", - " [96f8868c...] [fact_117...] role=system type=fact The user is currently working on a project involvi\n", - " [96f8868c...] [fact_ee1...] role=system type=fact The user has a dog.\n", - " [__proced...] [proc_616...] role=system type=procedural When debugging a large language model, always chec\n", - " [96f8868c...] [ep_13a6b...] role=system type=episodic Last spring, the user went hiking on Mount Rainier\n", - " [5827e67c...] [3782ffef...] role=user type=turn I'm planning a trip to Japan next spring. Any sugg\n", - " [5827e67c...] [d3497550...] role=agent type=turn Spring is a wonderful time to visit Japan! Cherry \n", - " [5827e67c...] [8717fe0d...] role=user type=turn I'd love to see Kyoto and Tokyo. How long should I\n", - " [5827e67c...] [3edcb648...] role=agent type=turn 10–14 days lets you spend ~5 days in each city plu\n", - " [5827e67c...] [summary_...] role=system type=summary The user planned a spring trip to Japan focused on\n", - " [5827e67c...] [30f39fca...] role=user type=turn What about food? I'm a vegetarian.\n", - " [5827e67c...] [679afa68...] role=agent type=turn Japan has wonderful vegetarian options — try shoji\n", - " [5827e67c...] [20418cbb...] role=user type=turn Are there any vegetarian restaurants you'd recomme\n", - " [5827e67c...] [44bc0998...] role=agent type=turn Shigetsu inside Tenryu-ji temple is famous for its\n", - " [bec477fa...] [410dcaf7...] role=user type=turn What's a good pasta recipe for a weeknight dinner?\n", - " [bec477fa...] [3e65264f...] role=agent type=turn Try aglio e olio — pasta, garlic, olive oil, chill\n", - " [bec477fa...] [93d8e2c1...] role=user type=turn Sounds great. I love simple Italian food, especial\n", - " [bec477fa...] [9c440b51...] role=agent type=turn Italian cuisine emphasises quality ingredients pre\n", - " [bec477fa...] [fact_584...] role=system type=fact The user prefers simple Italian food, especially d\n", - " [bec477fa...] [summary_...] role=system type=summary The conversation focused on suggesting a simple pa\n", - " [800e58b0...] [bc01e3d3...] role=user type=turn I want to visit Italy next year — Rome, Florence, \n", - " [800e58b0...] [966440e7...] role=agent type=turn Great itinerary! Tuscany is amazing in autumn — wi\n", - " [800e58b0...] [b1134253...] role=user type=turn Perfect — I love wine, especially Chianti and Brun\n", - " [800e58b0...] [3f8e2989...] role=agent type=turn Brunello di Montalcino producers offer wonderful c\n", - " [800e58b0...] [fact_bfd...] role=system type=fact The user plans to visit Italy next year, including\n", - " [800e58b0...] [fact_070...] role=system type=fact The user loves wine, especially Chianti and Brunel\n", - " [800e58b0...] [summary_...] role=system type=summary The user discussed plans to visit Italy next year,\n", - " [a3968726...] [80c78945...] role=user type=turn What's the best way to deploy a Python FastAPI app\n", - " [a3968726...] [900a8c86...] role=agent type=turn Azure Container Apps is a great fit for FastAPI.\n", - " [a3968726...] [00c996bc...] role=user type=turn Cool. I'm a Python engineer building AI tooling.\n", - " [a3968726...] [91cc1977...] role=agent type=turn Azure has excellent AI services — AI Foundry, AI S\n", - " [a3968726...] [fact_423...] role=system type=fact The user is a Python engineer building AI tooling.\n", - " [a3968726...] [summary_...] role=system type=summary The conversation focused on the best way to deploy\n", - " [__user_s...] [user_sum...] role=system type=user_summary The user is a Python engineer building AI tooling.\n", - " [09dc7d13...] [a313f4fe...] role=user type=turn Hi! I'm planning a trip to Tokyo next month.\n", - " [09dc7d13...] [b8be927e...] role=agent type=turn That sounds exciting! Tokyo is wonderful in spring\n", - " [09dc7d13...] [a048b3cd...] role=user type=turn I'd love food recommendations. I'm vegetarian.\n", - " [09dc7d13...] [f822061c...] role=agent type=turn Great choice! Try Ain Soph in Shinjuku for plant-b\n", - " [09dc7d13...] [6c05d0fc...] role=user type=turn Also, what's the best way to get around the city?\n", - " [09dc7d13...] [4f82afee...] role=agent type=turn A Suica or Pasmo IC card is the easiest option. It\n", - " [6e44bfdf...] [5f70d499...] role=user type=turn I've been having trouble sleeping lately. Any tips\n", - " [6e44bfdf...] [554813b8...] role=agent type=turn Keep a consistent sleep schedule, avoid screens 1 \n", - " [6e44bfdf...] [ceb47ce6...] role=user type=turn Does caffeine really affect sleep that much?\n", - " [6e44bfdf...] [de33c4e1...] role=agent type=turn Yes — caffeine has a half-life of about 5-6 hours,\n", - " [d78550ff...] [d78c85d4...] role=user type=turn Can you remind me of the Tokyo restaurant suggesti\n", - " [d78550ff...] [415b6b5a...] role=agent type=turn Of course! Last time we discussed Ain Soph in Shin\n", - " [ticket-d...] [d6a1be75...] role=user type=turn Hi, I'm having issues with my Surface Pro 9. The b\n", - " [ticket-d...] [7dff7796...] role=agent type=turn I'm sorry to hear that. Could you share when you b\n", - " [ticket-d...] [318d37d4...] role=user type=turn I bought it in March 2024 from the Microsoft Store\n", - " [ticket-d...] [f518daf5...] role=agent type=turn Thanks. I'll check warranty status. Could you also\n", - " [ticket-d...] [902ed190...] role=user type=turn It's alex.chen@example.com. The order number was M\n", - " [ticket-d...] [32fd980e...] role=agent type=turn Verified — the device is under warranty. I've init\n", - " [ticket-d...] [630500b2...] role=user type=turn OK, will do. By the way, I work as a software engi\n", - " [ticket-d...] [fact_b48...] role=system type=fact The user owns a Surface Pro 9 with a battery that \n", - " [ticket-d...] [fact_55f...] role=system type=fact The user purchased the Surface Pro 9 in March 2024\n", - " [ticket-d...] [fact_812...] role=system type=fact The user's email address is alex.chen@example.com.\n", - " [ticket-d...] [fact_68e...] role=system type=fact The Surface Pro 9 order number is MS-78234.\n", - " [ticket-d...] [fact_fe9...] role=system type=fact The user's Surface Pro 9 is currently under warran\n", - " [ticket-d...] [fact_198...] role=system type=fact The user works as a software engineer and relies o\n", - " [ticket-d...] [fact_369...] role=system type=fact The user will run the Surface app battery diagnost\n", - " [ticket-d...] [summary_...] role=system type=summary The user reported that their Surface Pro 9 battery\n", - " [ticket-7...] [59d28891...] role=user type=turn Hello again — Alex from the previous battery ticke\n", - " [ticket-7...] [505cdf04...] role=agent type=turn Welcome back, Alex! Yes, that confirms the diagnos\n", - " [ticket-7...] [4c3d1d55...] role=user type=turn Great. While we're talking, can you recommend a US\n", - " [ticket-7...] [c8fc1e0a...] role=agent type=turn The Surface Dock 2 or the Anker 778 are excellent \n", - " [ticket-7...] [f5cf5370...] role=user type=turn Multi-monitor is exactly what I need — I run 3 dis\n", - " [ticket-7...] [fact_032...] role=system type=fact The user's name is Alex.\n", - " [ticket-7...] [fact_ba5...] role=system type=fact The Surface app diagnostic reports that the user's\n", - " [ticket-7...] [fact_64c...] role=system type=fact Alex requires a USB-C dock compatible with the Sur\n", - " [ticket-7...] [summary_...] role=system type=summary Alex contacted support regarding a degraded batter\n", - " [__user_s...] [user_sum...] role=system type=user_summary The user's name is Alex.; The user's email address\n", - " [ticket-d...] [f6741f54...] role=user type=turn Hi, I have a quick question about my Microsoft 365\n", - " [ticket-d...] [cdf309ab...] role=agent type=turn Welcome back, Alex! Happy to help with your Micros\n", - " [a912fa55...] [975d78b5...] role=user type=turn Compare the environmental impact of electric vehic\n", - " [a912fa55...] [fc43544b...] role=agent type=turn PLAN:\n", - " 1. Research manufacturing impact (battery \n", - " [a912fa55...] [c898a267...] role=agent type=turn FINDING 1 — Manufacturing: EV battery production e\n", - " [a912fa55...] [00f08077...] role=agent type=turn FINDING 2 — Energy source: EVs charged on renewabl\n", - " [a912fa55...] [c2242b74...] role=agent type=turn FINDING 3 — End-of-life: Li-ion battery recycling \n", - " [a912fa55...] [277aa203...] role=agent type=turn RECOMMENDATION: For urban fleets, battery-electric\n", - " [thread-0...] [f844e873...] role=system type=fact User prefers Python over Java for backend work\n", - " [thread-0...] [d54ab12f...] role=system type=fact User is allergic to peanuts\n", - " [thread-0...] [24cf3d6a...] role=system type=fact User lives in Seattle, WA\n", - " [thread-0...] [323d880f...] role=system type=episodic Last Friday the user shipped a Cosmos-backed searc\n", - " [thread-0...] [b6c5a9ab...] role=system type=episodic User attended PyCon 2024 in Pittsburgh\n", - " [thread-0...] [b18fc854...] role=system type=procedural When the user says 'deploy', run `azd up` and tail\n", - " [thread-0...] [ce09b345...] role=system type=procedural Always confirm before purging Cosmos containers\n", - " [thread-5...] [fe918ee7...] role=system type=episodic Last Friday the user shipped a Cosmos-backed searc\n", - " [thread-5...] [31426409...] role=system type=episodic User attended PyCon 2024 in Pittsburgh\n", - " [thread-5...] [52d4d63f...] role=system type=procedural When the user says 'deploy', run `azd up` and tail\n", - " [thread-5...] [9ec66aac...] role=system type=procedural Always confirm before purging Cosmos containers\n", - " [3283e3ce...] [44e2a84b...] role=user type=turn What's the weather like in Seattle this weekend?\n", - " [3283e3ce...] [3347c70d...] role=agent type=turn This weekend Seattle will be around 55°F with part\n", - " [3283e3ce...] [7325fcca...] role=agent type=turn Sure! I found round-trip flights departing Friday \n", - " [3283e3ce...] [1548d960...] role=user type=turn Something near Pike Place Market would be great. K\n", - " [3283e3ce...] [d4c2d4b1...] role=agent type=turn I found a round-trip on Alaska Airlines for $275 a\n", - " [93f9f763...] [b19855ba...] role=user type=turn Can you recommend some good restaurants in New Yor\n", - " [93f9f763...] [0eb2219f...] role=agent type=turn Absolutely! NYC has incredible dining options. For\n", - " [93f9f763...] [61ada8c9...] role=user type=turn I love Italian food. Are there any options that ar\n", - " [93f9f763...] [d7de15e4...] role=agent type=turn For budget-friendly Italian in NYC, check out L'in\n", - " [3283e3ce...] [summary_...] role=system type=summary The user planned a weekend trip to Seattle with sp\n", - " [3283e3ce...] [fact_6dd...] role=system type=fact For a weekend trip to Seattle, the user requires r\n", - " [3283e3ce...] [fact_7a7...] role=system type=fact For a weekend trip to Seattle, the user requires h\n", - " [3283e3ce...] [fact_07e...] role=system type=fact For a weekend trip to Seattle, the user prefers ac\n", - " [__user_s...] [user_sum...] role=system type=user_summary {\n", - " \"key_facts\": [],\n", - " \"personal_preferences\": [\n", - " \n", - " [9269dfde...] [6550cc6e...] role=user type=turn Change feed test message 1: Tell me about vector d\n", - " [9269dfde...] [2b249321...] role=user type=turn Change feed test message 2: Tell me about vector d\n", - " [9269dfde...] [ccced81a...] role=user type=turn Change feed test message 3: Tell me about vector d\n", - " [3e8c0348...] [1c85da9a...] role=agent type=turn Sure! I found round-trip flights departing Friday \n", - " [3e8c0348...] [ad231b3b...] role=user type=turn What's the weather like in Seattle this weekend?\n", - " [3e8c0348...] [0eba1fb4...] role=user type=turn Something near Pike Place Market would be great. K\n", - " [3e8c0348...] [95fd0352...] role=agent type=turn I found a round-trip on Alaska Airlines for $275 a\n", - " [3e8c0348...] [b63df7c7...] role=agent type=turn This weekend Seattle will be around 55°F with part\n", - " [cc7ba964...] [5a1dd03f...] role=user type=turn Can you recommend some good restaurants in New Yor\n", - " [cc7ba964...] [eab7a8dc...] role=agent type=turn Absolutely! NYC has incredible dining options. For\n", - " [cc7ba964...] [e353165a...] role=user type=turn I love Italian food. Are there any options that ar\n", - " [cc7ba964...] [043b1f73...] role=agent type=turn For budget-friendly Italian in NYC, check out L'in\n", - " [bfaa7891...] [1899de86...] role=user type=turn What's the weather like in Seattle this weekend?\n", - " [bfaa7891...] [3ecd376a...] role=agent type=turn Sure! I found round-trip flights departing Friday \n", - " [bfaa7891...] [d78560d0...] role=agent type=turn This weekend Seattle will be around 55°F with part\n", - " [bfaa7891...] [168452e9...] role=agent type=turn I found a round-trip on Alaska Airlines for $275 a\n", - " [bfaa7891...] [352b0816...] role=user type=turn Something near Pike Place Market would be great. K\n", - " [69b363f1...] [12da5f11...] role=user type=turn Can you recommend some good restaurants in New Yor\n", - " [69b363f1...] [678aae82...] role=agent type=turn Absolutely! NYC has incredible dining options. For\n", - " [69b363f1...] [f282cce3...] role=user type=turn I love Italian food. Are there any options that ar\n", - " [69b363f1...] [1b9459b6...] role=agent type=turn For budget-friendly Italian in NYC, check out L'in\n", - " [67df7d45...] [f48762ba...] role=agent type=turn I found a round-trip on Alaska Airlines for $275 a\n", - " [67df7d45...] [d922da49...] role=agent type=turn This weekend Seattle will be around 55°F with part\n", - " [67df7d45...] [ccdb6efc...] role=agent type=turn Sure! I found round-trip flights departing Friday \n", - " [67df7d45...] [eece0053...] role=user type=turn Something near Pike Place Market would be great. K\n", - " [67df7d45...] [78c59756...] role=user type=turn What's the weather like in Seattle this weekend?\n", - " [49296007...] [525fa21b...] role=user type=turn Can you recommend some good restaurants in New Yor\n", - " [49296007...] [eed6a8e5...] role=agent type=turn Absolutely! NYC has incredible dining options. For\n", - " [49296007...] [817d2b13...] role=user type=turn I love Italian food. Are there any options that ar\n", - " [49296007...] [495f8e55...] role=agent type=turn For budget-friendly Italian in NYC, check out L'in\n", - " [0087a4c7...] [7112974f...] role=user type=turn Something near Pike Place Market would be great. K\n", - " [0087a4c7...] [c8444bda...] role=agent type=turn Sure! I found round-trip flights departing Friday \n", - " [0087a4c7...] [aca1086e...] role=user type=turn What's the weather like in Seattle this weekend?\n", - " [0087a4c7...] [83b493a7...] role=agent type=turn This weekend Seattle will be around 55°F with part\n", - " [0087a4c7...] [1ff00508...] role=agent type=turn I found a round-trip on Alaska Airlines for $275 a\n", - " [a62f6290...] [3ca18d6c...] role=user type=turn Can you recommend some good restaurants in New Yor\n", - " [a62f6290...] [bb3e7800...] role=agent type=turn Absolutely! NYC has incredible dining options. For\n", - " [a62f6290...] [9fd37b3a...] role=user type=turn I love Italian food. Are there any options that ar\n", - " [a62f6290...] [926a875e...] role=agent type=turn For budget-friendly Italian in NYC, check out L'in\n", - " [64930fb1...] [a67d7b29...] role=user type=turn Change feed test message 1: Tell me about vector d\n", - " [64930fb1...] [2ccb8a00...] role=user type=turn Change feed test message 2: Tell me about vector d\n", - " [64930fb1...] [10c23217...] role=user type=turn Change feed test message 3: Tell me about vector d\n", - " [154bf409...] [c9f3116a...] role=user type=turn What's the weather like in Seattle this weekend?\n", - " [154bf409...] [799c324a...] role=agent type=turn I found a round-trip on Alaska Airlines for $275 a\n", - " [154bf409...] [3234f409...] role=agent type=turn This weekend Seattle will be around 55°F with part\n", - " [154bf409...] [e635815b...] role=agent type=turn Sure! I found round-trip flights departing Friday \n", - " [154bf409...] [c8dc5c13...] role=user type=turn Something near Pike Place Market would be great. K\n", - " [0fcdecee...] [ddc8b396...] role=user type=turn Can you recommend some good restaurants in New Yor\n", - " [0fcdecee...] [c2f5d5a5...] role=agent type=turn Absolutely! NYC has incredible dining options. For\n", - " [0fcdecee...] [f03aa200...] role=user type=turn I love Italian food. Are there any options that ar\n", - " [0fcdecee...] [cba4eb09...] role=agent type=turn For budget-friendly Italian in NYC, check out L'in\n", - " [3283e3ce...] [ep_420f4...] role=system type=episodic The user was planning a weekend trip to Seattle an\n", - " [30b8b16c...] [913e5379...] role=user type=turn Change feed test message 1: Tell me about vector d\n", - " [30b8b16c...] [e5e45fef...] role=user type=turn Change feed test message 2: Tell me about vector d\n", - " [30b8b16c...] [08dddc67...] role=user type=turn Change feed test message 3: Tell me about vector d\n", - " [t1...] [2af2a94e...] role=agent type=turn Agent response\n", - " [78ada42c...] [d288134a...] role=user type=turn Hi! I'm planning a trip to Tokyo next month.\n", - " [78ada42c...] [26821e00...] role=agent type=turn That sounds exciting! Tokyo is wonderful in spring\n", - " [78ada42c...] [bd2d2b5e...] role=user type=turn I'd love food recommendations. I'm vegetarian.\n", - " [78ada42c...] [104974d7...] role=agent type=turn Great choice! Try Ain Soph in Shinjuku for plant-b\n", - " [78ada42c...] [22e034f0...] role=user type=turn Also, what's the best way to get around the city?\n", - " [78ada42c...] [caaa7d25...] role=agent type=turn A Suica or Pasmo IC card is the easiest option. It\n", - " [dd0ad3f9...] [039bf606...] role=user type=turn I've been having trouble sleeping lately. Any tips\n", - " [dd0ad3f9...] [81fe48ff...] role=agent type=turn Keep a consistent sleep schedule, avoid screens 1 \n", - " [dd0ad3f9...] [5cb804de...] role=user type=turn Does caffeine really affect sleep that much?\n", - " [dd0ad3f9...] [e5b990ab...] role=agent type=turn Yes — caffeine has a half-life of about 5-6 hours,\n", - " [a402c62b...] [b5efa043...] role=user type=turn Can you remind me of the Tokyo restaurant suggesti\n", - " [a402c62b...] [426026b6...] role=agent type=turn Of course! Last time we discussed Ain Soph in Shin\n", - " [e2e2402e...] [a2ebd8fc...] role=user type=turn I'm planning a trip to Japan next spring. Any sugg\n", - " [e2e2402e...] [d37cf5bf...] role=agent type=turn Spring is a wonderful time to visit Japan! Cherry \n", - " [e2e2402e...] [e3e3d7ce...] role=user type=turn I'd love to see Kyoto and Tokyo. How long should I\n", - " [e2e2402e...] [5eebb35c...] role=agent type=turn 10–14 days lets you spend ~5 days in each city plu\n", - " [e2e2402e...] [summary_...] role=system type=summary The user planned a spring trip to Japan focused on\n", - " [e2e2402e...] [f194f077...] role=user type=turn What about food? I'm a vegetarian.\n", - " [e2e2402e...] [307dc427...] role=agent type=turn Japan has wonderful vegetarian options — try shoji\n", - " [e2e2402e...] [ba7e6fe2...] role=user type=turn Are there any vegetarian restaurants you'd recomme\n", - " [e2e2402e...] [53e01cf6...] role=agent type=turn Shigetsu inside Tenryu-ji temple is famous for its\n", - " [thread-0...] [f4734224...] role=user type=turn Hi! I love Cosmos DB.\n", - " [thread-0...] [d5e42a3c...] role=user type=turn Hi! I love Cosmos DB.\n", - " [thread-0...] [72aadb29...] role=agent type=turn Cosmos DB is fantastic for low-latency global apps\n", - " [thread-0...] [1cc0c040...] role=user type=turn Can it do vector search?\n", - " [thread-0...] [aa7d2515...] role=agent type=turn Yes — DiskANN indexes power semantic search native\n", - " [thread-0...] [5eddb02b...] role=user type=turn Great. What about hierarchical partition keys?\n", - " [thread-0...] [77886873...] role=agent type=turn HPK lets you co-locate related items for efficient\n", - " [thread-0...] [6099050f...] role=system type=fact The user loves Azure Cosmos DB.\n", - " [thread-0...] [b0c0dd47...] role=system type=fact Azure Cosmos DB supports vector search powered by \n", - " [thread-0...] [summary_...] role=system type=summary The conversation consisted of brief exchanges abou\n", - " [thread-0...] [6bb1605b...] role=system type=fact Azure Cosmos DB supports hierarchical partition ke\n", - " [thread-4...] [a38d21e1...] role=user type=turn Hi I love Cosmos\n", - " [thread-4...] [3e7ac221...] role=agent type=turn Cosmos is great\n", - " [thread-4...] [8a13148e...] role=user type=turn vector search?\n", - " [thread-4...] [5dc2cf5b...] role=agent type=turn yes DiskANN\n", - " [thread-4...] [f555f850...] role=user type=turn HPK?\n", - " [thread-4...] [99f7cf33...] role=agent type=turn colocates data\n", - " [thread-4...] [summary_...] role=system type=summary The conversation briefly touched on Microsoft Azur\n", - " [thread-0...] [58d255e2...] role=user type=turn Hi! I love Cosmos DB.\n", - " [thread-0...] [0349d4e5...] role=agent type=turn Cosmos DB is fantastic for low-latency global apps\n", - " [thread-0...] [13a6491b...] role=user type=turn Can it do vector search?\n", - " [thread-0...] [efea8437...] role=agent type=turn Yes — DiskANN indexes power semantic search native\n", - " [thread-0...] [8ce337ef...] role=user type=turn Great. What about hierarchical partition keys?\n", - " [thread-0...] [3bec5407...] role=agent type=turn HPK lets you co-locate related items for efficient\n", - " [thread-9...] [bc800311...] role=user type=turn I'm planning a hiking trip to Olympic National Par\n", - " [__user_s...] [user_sum...] role=system type=user_summary The user lives in Seattle, WA.; The user is allerg\n", - " [thread-0...] [aa91e94e...] role=user type=turn Hi! I love Cosmos DB.\n", - " [thread-0...] [3cb84a20...] role=agent type=turn Cosmos DB is fantastic for low-latency global apps\n", - " [thread-0...] [02c03996...] role=user type=turn Can it do vector search?\n", - " [thread-0...] [57ea857b...] role=agent type=turn Yes — DiskANN indexes power semantic search native\n", - " [thread-0...] [9055c362...] role=user type=turn Great. What about hierarchical partition keys?\n", - " [thread-0...] [0f628302...] role=agent type=turn HPK lets you co-locate related items for efficient\n", - " [thread-0...] [793a5ee5...] role=user type=turn Hi! I love Cosmos DB.\n", - " [thread-0...] [06666f17...] role=agent type=turn Cosmos DB is fantastic for low-latency global apps\n", - " [thread-0...] [d208eeea...] role=user type=turn Can it do vector search?\n", - " [thread-0...] [548dd8a9...] role=agent type=turn Yes — DiskANN indexes power semantic search native\n", - " [thread-0...] [978dcff8...] role=user type=turn Great. What about hierarchical partition keys?\n", - " [thread-0...] [bd139b4f...] role=agent type=turn HPK lets you co-locate related items for efficient\n", - " [thread-2...] [79fca8cc...] role=user type=turn I'm planning a hiking trip to Olympic National Par\n", - " [thread-2...] [02c7e958...] role=agent type=turn Great choice! Hoh Rainforest and Hurricane Ridge a\n", - " [thread-2...] [89959614...] role=user type=turn I'd like to camp 2 nights. Any permit guidance?\n", - " [thread-2...] [6def8d60...] role=agent type=turn You'll need a wilderness permit from recreation.go\n", - " [thread-2...] [8b910b34...] role=user type=turn Thanks — also, I'm vegetarian, please remember tha\n", - " [thread-2...] [summary_...] role=system type=summary The user discussed planning a hiking and camping t\n", - " [thread-2...] [fact_0c0...] role=system type=fact The user is planning a hiking trip to Olympic Nati\n", - " [thread-2...] [fact_206...] role=system type=fact The user plans to camp for two nights during the O\n", - " [thread-2...] [fact_b39...] role=system type=fact The user follows a vegetarian diet.\n", - " [test-thr...] [3c31c8da...] role=user type=turn Test message 214ecc\n", - " [test-thr...] [9380bb97...] role=user type=turn Test message 6e6446\n", - " [test-thr...] [1944068a...] role=user type=turn Test message 0eff02\n", - " [test-thr...] [summary_...] role=system type=summary The user sent three short test messages containing\n", - " [e9cdb066...] [fact_ade...] role=system type=fact The user lives in Seattle.\n", - " [e9cdb066...] [fact_716...] role=system type=fact The user works at Microsoft as a software engineer\n", - " [e9cdb066...] [fact_cfe...] role=system type=fact The user prefers Python over JavaScript for backen\n", - " [__proced...] [proc_6a4...] role=system type=procedural When asked about deployment, always check the reso\n", - " [e9cdb066...] [ep_4a734...] role=system type=episodic The user traveled to Japan during cherry blossom s\n", - " [5672dff1...] [summary_...] role=system type=summary The user shared details about their daily running \n", - " [f28bdc49...] [summary_...] role=system type=summary The user shared their enthusiasm for Italian cooki\n", - " [5672dff1...] [fact_8da...] role=system type=fact The user goes running every morning before work, c\n", - " [f28bdc49...] [fact_512...] role=system type=fact The user loves Italian cooking, especially pasta.\n", - " [f28bdc49...] [fact_661...] role=system type=fact The user makes homemade fettuccine every weekend.\n", - " [test-thr...] [e8afd5dd...] role=user type=turn Test message ac3aa2\n", - " [test-thr...] [ecce99ca...] role=user type=turn Test message 15ec87\n", - " [test-thr...] [a43a8567...] role=user type=turn Test message fca3a8\n", - " [test-thr...] [summary_...] role=system type=summary The user sent three separate test messages contain\n", - " [test-thr...] [94c5afad...] role=user type=turn Test message e4a27e\n", - " [test-thr...] [476a9588...] role=user type=turn Test message 330890\n", - " [test-thr...] [4bdf8f28...] role=user type=turn Test message 506cf6\n", - " [test-thr...] [summary_...] role=system type=summary The conversation consisted of three standalone tes\n", - " [5622a10b...] [fact_cb8...] role=system type=fact The user lives in Seattle.\n", - " [5622a10b...] [fact_493...] role=system type=fact The user works at Microsoft as a software engineer\n", - " [5622a10b...] [fact_a13...] role=system type=fact The user prefers Python over JavaScript for backen\n", - " [__proced...] [proc_1f4...] role=system type=procedural When discussing deployment, always check the resou\n", - " [5622a10b...] [ep_0d448...] role=system type=episodic The user traveled to Japan during cherry blossom s\n", - " [c90da0a1...] [summary_...] role=system type=summary The conversation was a brief exchange about the us\n", - " [c90da0a1...] [fact_e6a...] role=system type=fact The user loves Italian cooking, especially pasta.\n", - " [c90da0a1...] [fact_d86...] role=system type=fact The user makes homemade fettuccine every weekend.\n", - " [thread-0...] [3771c68f...] role=user type=turn Hi! I love Cosmos DB.\n", - " [thread-0...] [b8db28d6...] role=agent type=turn Cosmos DB is fantastic for low-latency global apps\n", - " [thread-0...] [8f280507...] role=user type=turn Can it do vector search?\n", - " [thread-0...] [cbf0f0be...] role=agent type=turn Yes — DiskANN indexes power semantic search native\n", - " [thread-0...] [7bc1a0bd...] role=user type=turn Great. What about hierarchical partition keys?\n", - " [thread-0...] [771971c9...] role=agent type=turn HPK lets you co-locate related items for efficient\n", - " [thread-0...] [638e47a9...] role=user type=turn Hi! I love Cosmos DB.\n", - " [thread-0...] [80f6b374...] role=agent type=turn Cosmos DB is fantastic for low-latency global apps\n", - " [thread-0...] [7207f7da...] role=user type=turn Can it do vector search?\n", - " [thread-0...] [c5c544d6...] role=agent type=turn Yes — DiskANN indexes power semantic search native\n", - " [thread-0...] [ec28abb0...] role=user type=turn Great. What about hierarchical partition keys?\n", - " [thread-0...] [2c69aa14...] role=agent type=turn HPK lets you co-locate related items for efficient\n", - " [test-thr...] [eb09e3b8...] role=user type=turn Test message c67925\n", - " [test-thr...] [390f2924...] role=user type=turn Test message 5c0bc7\n", - " [test-thr...] [9c356b00...] role=user type=turn Test message 075f33\n", - " [test-thr...] [summary_...] role=system type=summary The user sent three separate test messages contain\n", - " [c60acfe1...] [fact_9eb...] role=system type=fact The user lives in Seattle.\n", - " [c60acfe1...] [fact_a13...] role=system type=fact The user works at Microsoft as a software engineer\n", - " [c60acfe1...] [fact_6e6...] role=system type=fact The user prefers Python over JavaScript for backen\n", - " [__proced...] [proc_699...] role=system type=procedural When discussing deployment, always check the resou\n", - " [c60acfe1...] [ep_a1e72...] role=system type=episodic The user traveled to Japan during cherry blossom s\n", - " [08a365ae...] [fact_d32...] role=system type=fact The user makes homemade fettuccine every weekend.\n", - " [08a365ae...] [summary_...] role=system type=summary The user shared their enthusiasm for Italian cooki\n", - " [4d28c3df...] [fact_b23...] role=system type=fact The user runs approximately 5 kilometres each day.\n", - " [4d28c3df...] [summary_...] role=system type=summary The conversation was about the user’s daily runnin\n", - " [test-thr...] [3cb4cee8...] role=user type=turn Test message 396b1a\n", - " [test-thr...] [ee9ba6ab...] role=user type=turn Test message ce1cff\n", - " [test-thr...] [0c4ad50f...] role=user type=turn Test message 35de30\n", - " [test-thr...] [summary_...] role=system type=summary The conversation consisted of three short test mes\n", - " [6a0c8737...] [fact_318...] role=system type=fact The user lives in Seattle.\n", - " [6a0c8737...] [fact_c00...] role=system type=fact The user works at Microsoft as a software engineer\n", - " [6a0c8737...] [fact_234...] role=system type=fact The user prefers Python over JavaScript for backen\n", - " [__proced...] [proc_1f2...] role=system type=procedural When asked about deployment, always check the reso\n", - " [6a0c8737...] [ep_b5220...] role=system type=episodic The user traveled to Japan during cherry blossom s\n", - " [a8ea2e65...] [fact_7b9...] role=system type=fact The user goes running every morning before work, t\n", - " [8216c24f...] [fact_31f...] role=system type=fact The user enjoys Italian cooking, especially pasta \n", - " [8216c24f...] [fact_7ba...] role=system type=fact The user makes homemade fettuccine every weekend.\n", - " [cc830eaa...] [fact_7d5...] role=system type=fact The user has a golden retriever named Buddy.\n", - " [cc830eaa...] [fact_b66...] role=system type=fact Buddy is 3 years old.\n", - " [cc830eaa...] [fact_8b1...] role=system type=fact Buddy loves playing fetch at the park.\n", - " [thread-0...] [f4d39b04...] role=user type=turn Hi! I love Cosmos DB.\n", - " [thread-0...] [b9161808...] role=agent type=turn Cosmos DB is fantastic for low-latency global apps\n", - " [thread-0...] [c3a74683...] role=user type=turn Can it do vector search?\n", - " [thread-0...] [a27126d6...] role=agent type=turn Yes — DiskANN indexes power semantic search native\n", - " [thread-0...] [91c3e7dc...] role=user type=turn Great. What about hierarchical partition keys?\n", - " [thread-0...] [98e2d8de...] role=agent type=turn HPK lets you co-locate related items for efficient\n", - " [thread-0...] [cd0271bc...] role=user type=turn Hi! I love Cosmos DB.\n", - " [thread-0...] [805cf355...] role=agent type=turn Cosmos DB is fantastic for low-latency global apps\n", - " [thread-0...] [826c773c...] role=user type=turn Can it do vector search?\n", - " [thread-0...] [7c3af0fe...] role=agent type=turn Yes — DiskANN indexes power semantic search native\n", - " [thread-0...] [012f758c...] role=user type=turn Great. What about hierarchical partition keys?\n", - " [thread-0...] [72cdd403...] role=agent type=turn HPK lets you co-locate related items for efficient\n", - " [thread-b...] [9b72c25d...] role=user type=turn I'm planning a hiking trip to Olympic National Par\n", - " [thread-b...] [30296030...] role=agent type=turn Great choice! Hoh Rainforest and Hurricane Ridge a\n", - " [thread-b...] [efabc25b...] role=user type=turn I'd like to camp 2 nights. Any permit guidance?\n", - " [thread-b...] [a64b3ad1...] role=agent type=turn You'll need a wilderness permit from recreation.go\n", - " [thread-b...] [105b6260...] role=user type=turn Thanks — also, I'm vegetarian, please remember tha\n", - " [thread-b...] [summary_...] role=system type=summary The user discussed planning a hiking trip to Olymp\n", - " [t1...] [b7bbcd71...] role=user type=turn Hello from quickstart!\n", - " [t1...] [8422cbfd...] role=agent type=turn Agent response\n", - " [d0421430...] [5cb583cf...] role=user type=turn I live in Seattle and work at Microsoft as a softw\n", - " [d0421430...] [47eae793...] role=agent type=turn Got it! You're based in Seattle working at Microso\n", - " [d0421430...] [7ae79706...] role=user type=turn My favourite programming language is Python and I'\n", - " [d0421430...] [13017c8c...] role=agent type=turn 8 years of Python experience is impressive!\n", - " [d0421430...] [76abf10b...] role=user type=turn I'm currently working on a project involving large\n", - " [d0421430...] [22d94ba6...] role=agent type=turn That's a great area! LLMs combined with RAG can un\n", - " [d0421430...] [5b337ad5...] role=user type=turn Last spring I went hiking on Mount Rainier with my\n", - " [d0421430...] [b019f3b9...] role=user type=turn When debugging an LLM, always check the prompt fir\n", - " [d0421430...] [fact_ab2...] role=system type=fact The user lives in Seattle.\n", - " [d0421430...] [fact_f60...] role=system type=fact The user works at Microsoft as a software engineer\n", - " [d0421430...] [fact_0f6...] role=system type=fact The user's favourite programming language is Pytho\n", - " [d0421430...] [fact_83f...] role=system type=fact The user has 8 years of experience using Python.\n", - " [d0421430...] [fact_606...] role=system type=fact The user is currently working on a project involvi\n", - " [__proced...] [proc_1d3...] role=system type=procedural When debugging a large language model, always chec\n", - " [d0421430...] [ep_c4c50...] role=system type=episodic Last spring, the user went hiking on Mount Rainier\n", - " [dd381d0c...] [8a755754...] role=user type=turn I'm planning a trip to Japan next spring. Any sugg\n", - " [dd381d0c...] [8f58418d...] role=agent type=turn Spring is a wonderful time to visit Japan! Cherry \n", - " [dd381d0c...] [59506060...] role=user type=turn I'd love to see Kyoto and Tokyo. How long should I\n", - " [dd381d0c...] [d7e35289...] role=agent type=turn 10–14 days lets you spend ~5 days in each city plu\n", - " [d0421430...] [summary_...] role=system type=summary The user shared personal and professional backgrou\n", - " [d0421430...] [fact_58d...] role=system type=fact The user's favorite programming language is Python\n", - " [d0421430...] [fact_9de...] role=system type=fact The user is currently working on a project involvi\n", - " [d0421430...] [ep_918b6...] role=system type=episodic Last spring, the user went hiking on Mount Rainier\n", - " [dd381d0c...] [summary_...] role=system type=summary The user planned a spring trip to Japan focused on\n", - " [dd381d0c...] [50dd67ed...] role=user type=turn What about food? I'm a vegetarian.\n", - " [dd381d0c...] [46fda2e6...] role=agent type=turn Japan has wonderful vegetarian options — try shoji\n", - " [dd381d0c...] [747e073c...] role=user type=turn Are there any vegetarian restaurants you'd recomme\n", - " [dd381d0c...] [de105f27...] role=agent type=turn Shigetsu inside Tenryu-ji temple is famous for its\n", - " [dd381d0c...] [fact_982...] role=system type=fact The user is planning a trip to Japan next spring.\n", - " [dd381d0c...] [fact_cd7...] role=system type=fact The user wants to visit Kyoto and Tokyo during the\n", - " [dd381d0c...] [fact_555...] role=system type=fact The user follows a vegetarian diet.\n", - " [1a5388ca...] [553b498c...] role=user type=turn What's a good pasta recipe for a weeknight dinner?\n", - " [1a5388ca...] [f64a1f54...] role=agent type=turn Try aglio e olio — pasta, garlic, olive oil, chill\n", - " [1a5388ca...] [fa9e29e3...] role=user type=turn Sounds great. I love simple Italian food, especial\n", - " [1a5388ca...] [efb3613c...] role=agent type=turn Italian cuisine emphasises quality ingredients pre\n", - " [1a5388ca...] [fact_aa1...] role=system type=fact The user prefers simple Italian food made with fre\n", - " [1a5388ca...] [fact_088...] role=system type=fact The user loves simple Italian food, especially dis\n", - " [1a5388ca...] [summary_...] role=system type=summary The user asked for a good weeknight pasta recipe a\n", - " [462c0b89...] [5148d545...] role=user type=turn I want to visit Italy next year — Rome, Florence, \n", - " [462c0b89...] [4e8648c0...] role=agent type=turn Great itinerary! Tuscany is amazing in autumn — wi\n", - " [462c0b89...] [aedd2520...] role=user type=turn Perfect — I love wine, especially Chianti and Brun\n", - " [462c0b89...] [1fe994b2...] role=agent type=turn Brunello di Montalcino producers offer wonderful c\n", - " [462c0b89...] [fact_82d...] role=system type=fact The user plans to visit Italy next year, including\n", - " [462c0b89...] [fact_bf6...] role=system type=fact The user loves wine, especially Chianti and Brunel\n", - " [462c0b89...] [summary_...] role=system type=summary The user discussed plans to visit Italy next year,\n", - " [82849ac6...] [56c4c3c3...] role=user type=turn What's the best way to deploy a Python FastAPI app\n", - " [82849ac6...] [24cf1624...] role=agent type=turn Azure Container Apps is a great fit for FastAPI.\n", - " [82849ac6...] [99893621...] role=user type=turn Cool. I'm a Python engineer building AI tooling.\n", - " [82849ac6...] [7ea3e0ac...] role=agent type=turn Azure has excellent AI services — AI Foundry, AI S\n", - " [82849ac6...] [fact_dad...] role=system type=fact The user is a Python engineer building AI tooling.\n", - " [__user_s...] [user_sum...] role=system type=user_summary The user is a Python engineer.; The user is buildi\n", - " [82849ac6...] [summary_...] role=system type=summary The user asked about the best way to deploy a Pyth\n", - " [de98eb46...] [summary_...] role=system type=summary The user discussed building a hybrid recommendatio\n", - " [de98eb46...] [fact_5e8...] role=system type=fact The user is building a recommendation engine for a\n", - " [de98eb46...] [fact_c9e...] role=system type=fact The user chose a hybrid recommendation approach us\n", - " [de98eb46...] [fact_f77...] role=system type=fact The user prefers Python and plans to use FastAPI f\n", - " [de98eb46...] [ep_3a65f...] role=system type=episodic Last quarter, the user implemented a recommendatio\n", - " [de98eb46...] [fact_3a9...] role=system type=fact The user plans to implement a hybrid recommendatio\n", - " [de98eb46...] [fact_9d1...] role=system type=fact The user intends to use embeddings on book descrip\n", - " [e9d75005...] [c3b41618...] role=user type=turn I love hiking in the Pacific Northwest\n", - " [e9d75005...] [831c50e2...] role=agent type=turn The PNW has amazing trails like the Wonderland Tra\n", - " [de98eb46...] [fact_a37...] role=system type=fact The user prefers Python for development.\n", - " [de98eb46...] [fact_15f...] role=system type=fact The user wants to use FastAPI for the API layer of\n", - " [de98eb46...] [ep_53f68...] role=system type=episodic Last quarter, the user implemented a similar recom\n", - " [e9d75005...] [88803076...] role=user type=fact My favorite food is sushi, especially salmon nigir\n", - " [e9d75005...] [820486f6...] role=user type=turn I usually run 5 miles every morning before work\n", - " [e9d75005...] [3e754348...] role=agent type=turn Running is a great way to stay fit! Do you prefer \n", - " [e9d75005...] [d983c7e3...] role=user type=fact I work as a software engineer at a startup in Seat\n", - " [e9d75005...] [a001039f...] role=user type=fact My preferred programming language is Python\n", - " [e9d75005...] [2d8ad427...] role=agent type=turn Python is very popular for AI/ML workloads. What f\n", - " [75d8811b...] [b6b19602...] role=user type=turn Hi! I'm planning a trip to Tokyo next month.\n", - " [75d8811b...] [f792c4e7...] role=agent type=turn That sounds exciting! Tokyo is wonderful in spring\n", - " [75d8811b...] [17ccb199...] role=user type=turn I'd love food recommendations. I'm vegetarian.\n", - " [75d8811b...] [8a41f22a...] role=agent type=turn Great choice! Try Ain Soph in Shinjuku for plant-b\n", - " [75d8811b...] [532d93ee...] role=user type=turn Also, what's the best way to get around the city?\n", - " [75d8811b...] [20f5c5de...] role=agent type=turn A Suica or Pasmo IC card is the easiest option. It\n", - " [e8f0a465...] [a630e370...] role=user type=turn I've been having trouble sleeping lately. Any tips\n", - " [e8f0a465...] [efcc37f1...] role=agent type=turn Keep a consistent sleep schedule, avoid screens 1 \n", - " [e8f0a465...] [bcd60808...] role=user type=turn Does caffeine really affect sleep that much?\n", - " [e8f0a465...] [d1569024...] role=agent type=turn Yes — caffeine has a half-life of about 5-6 hours,\n", - " [e9d75005...] [summary_...] role=system type=summary The user shared personal background information in\n", - " [45853aeb...] [1cf925ed...] role=user type=turn Can you remind me of the Tokyo restaurant suggesti\n", - " [45853aeb...] [2094ee58...] role=agent type=turn Of course! Last time we discussed Ain Soph in Shin\n", - " [e9d75005...] [fact_fb7...] role=system type=fact The user loves hiking in the Pacific Northwest.\n", - " [e9d75005...] [fact_6ee...] role=system type=fact The user usually runs 5 miles every morning before\n", - " [ticket-9...] [ed75dc84...] role=user type=turn Hi, I'm having issues with my Surface Pro 9. The b\n", - " [ticket-9...] [6743a768...] role=agent type=turn I'm sorry to hear that. Could you share when you b\n", - " [ticket-9...] [090753e4...] role=user type=turn I bought it in March 2024 from the Microsoft Store\n", - " [ticket-9...] [5cf00dc0...] role=agent type=turn Thanks. I'll check warranty status. Could you also\n", - " [ticket-9...] [4fba41de...] role=user type=turn It's alex.chen@example.com. The order number was M\n", - " [ticket-9...] [3aec4d8c...] role=agent type=turn Verified — the device is under warranty. I've init\n", - " [ticket-9...] [3f14a39f...] role=user type=turn OK, will do. By the way, I work as a software engi\n", - " [e8f0a465...] [summary_...] role=system type=summary The user asked for help with recent sleep difficul\n", - " [75d8811b...] [fact_74b...] role=system type=fact The user is planning a trip to Tokyo next month.\n", - " [75d8811b...] [fact_858...] role=system type=fact The user follows a vegetarian diet.\n", - " [e8f0a465...] [fact_e49...] role=system type=fact The user has been having trouble sleeping lately.\n", - " [75d8811b...] [summary_...] role=system type=summary The user discussed plans for a trip to Tokyo next \n", - " [__user_s...] [user_sum...] role=system type=user_summary The user is planning a trip to Tokyo next month (m\n", - " [ticket-9...] [summary_...] role=system type=summary The user reported that their Surface Pro 9 battery\n", - " [ticket-9...] [fact_5d4...] role=system type=fact The user owns a Surface Pro 9 with a battery that \n", - " [ticket-9...] [fact_d40...] role=system type=fact The user purchased the Surface Pro 9 in March 2024\n", - " [ticket-9...] [fact_dfd...] role=system type=fact The user's email address is alex.chen@example.com.\n", - " [ticket-9...] [fact_d88...] role=system type=fact The order number for the Surface Pro 9 purchase is\n", - " [ticket-9...] [fact_b5d...] role=system type=fact The user's Surface Pro 9 is currently under warran\n", - " [ticket-9...] [fact_d3e...] role=system type=fact The user works as a software engineer and relies o\n", - " [ticket-9...] [fact_b88...] role=system type=fact The user agreed to run the Surface app diagnostic \n", - " [ticket-9...] [fact_772...] role=system type=fact The contact email associated with the Surface Pro \n", - " [ticket-9...] [fact_4e4...] role=system type=fact The user owns a Surface Pro 9 that currently exper\n", - " [ticket-9...] [fact_ac3...] role=system type=fact The order number for the user's Surface Pro 9 purc\n", - " [ticket-f...] [e1f26087...] role=user type=turn Hello again — Alex from the previous battery ticke\n", - " [ticket-f...] [5d5a3234...] role=agent type=turn Welcome back, Alex! Yes, that confirms the diagnos\n", - " [ticket-f...] [65e5092f...] role=user type=turn Great. While we're talking, can you recommend a US\n", - " [ticket-f...] [e2aff8e0...] role=agent type=turn The Surface Dock 2 or the Anker 778 are excellent \n", - " [ticket-f...] [28bd61e6...] role=user type=turn Multi-monitor is exactly what I need — I run 3 dis\n", - " [ticket-f...] [summary_...] role=system type=summary Alex reported a degraded battery on a Surface Pro \n", - " [ticket-f...] [fact_165...] role=system type=fact The Surface app diagnostic reported that the user'\n", - " [ticket-f...] [fact_9cf...] role=system type=fact A replacement battery service unit will be shipped\n", - " [ticket-f...] [fact_343...] role=system type=fact The user requires a USB-C dock compatible with the\n", - " [__user_s...] [user_sum...] role=system type=user_summary The user's name is Alex Chen.; The user's email ad\n", - " [ticket-f...] [fact_d81...] role=system type=fact The Surface app diagnostic reports that the user's\n", - " [ticket-f...] [fact_6ba...] role=system type=fact The user needs a USB-C dock compatible with the Su\n", - " [ticket-f...] [fact_8af...] role=system type=fact The user runs three displays for development work.\n", - " [ticket-f...] [ep_802fc...] role=system type=episodic The user's Surface Pro 9 was experiencing rapid ba\n", - " [ticket-b...] [4fea4556...] role=user type=turn Hi, I have a quick question about my Microsoft 365\n", - " [ticket-b...] [c8451dd2...] role=agent type=turn Welcome back, Alex! Happy to help with your Micros\n", - " [84350066...] [fbf439c3...] role=user type=turn Compare the environmental impact of electric vehic\n", - " [84350066...] [cc6e41cf...] role=agent type=turn PLAN:\n", - " 1. Research manufacturing impact (battery \n", - " [84350066...] [c8a01395...] role=agent type=turn FINDING 1 — Manufacturing: EV battery production e\n", - " [84350066...] [9a5c4e1d...] role=agent type=turn FINDING 2 — Energy source: EVs charged on renewabl\n", - " [84350066...] [6b1206fd...] role=agent type=turn FINDING 3 — End-of-life: Li-ion battery recycling \n", - " [84350066...] [25903ff0...] role=agent type=turn RECOMMENDATION: For urban fleets, battery-electric\n", - " [thread-e...] [666e8ef8...] role=system type=fact User prefers Python over Java for backend work\n", - " [thread-e...] [dcecaffb...] role=system type=fact User is allergic to peanuts\n", - " [thread-e...] [e26acf75...] role=system type=fact User lives in Seattle, WA\n", - " [thread-e...] [7f5e185b...] role=system type=episodic Last Friday the user shipped a Cosmos-backed searc\n", - " [thread-e...] [0bee2a1f...] role=system type=episodic User attended PyCon 2024 in Pittsburgh\n", - " [thread-e...] [fb81b994...] role=system type=procedural When the user says 'deploy', run `azd up` and tail\n", - " [thread-e...] [ad19e9c8...] role=system type=procedural Always confirm before purging Cosmos containers\n", - " [84350066...] [summary_...] role=system type=summary The conversation analyzed the environmental impact\n", - " [4c99b9ba...] [c1dffbb4...] role=user type=turn What's the weather like in Seattle this weekend?\n", - " [4c99b9ba...] [d1d42c19...] role=agent type=turn This weekend Seattle will be around 55°F with part\n", - " [4c99b9ba...] [6587d05b...] role=agent type=turn Sure! I found round-trip flights departing Friday \n", - " [4c99b9ba...] [477bfcf3...] role=user type=turn Something near Pike Place Market would be great. K\n", - " [4c99b9ba...] [f133d14c...] role=agent type=turn I found a round-trip on Alaska Airlines for $275 a\n", - " [73810c6b...] [6a262048...] role=user type=turn Can you recommend some good restaurants in New Yor\n", - " [73810c6b...] [4a24bc5a...] role=agent type=turn Absolutely! NYC has incredible dining options. For\n", - " [73810c6b...] [752b35cc...] role=user type=turn I love Italian food. Are there any options that ar\n", - " [73810c6b...] [6037ae5b...] role=agent type=turn For budget-friendly Italian in NYC, check out L'in\n", - " [73810c6b...] [fact_8c6...] role=system type=fact The user loves Italian food.\n", - " [73810c6b...] [summary_...] role=system type=summary The user asked for restaurant recommendations in N\n", - " [4c99b9ba...] [summary_...] role=system type=summary The user inquired about the weather in Seattle for\n", - " [2b2d0c38...] [995608e2...] role=user type=turn Change feed test message 1: Tell me about vector d\n", - " [2b2d0c38...] [c9765c5e...] role=user type=turn Change feed test message 2: Tell me about vector d\n", - " [2b2d0c38...] [00e02473...] role=user type=turn Change feed test message 3: Tell me about vector d\n", - " [2b2d0c38...] [summary_...] role=system type=summary The user sent three consecutive test messages aski\n", - " [34249f73...] [eb3f86b6...] role=agent type=turn I found a round-trip on Alaska Airlines for $275 a\n", - " [34249f73...] [81d468be...] role=agent type=turn This weekend Seattle will be around 55°F with part\n", - " [34249f73...] [d9fd8db5...] role=user type=turn What's the weather like in Seattle this weekend?\n", - " [34249f73...] [c00391d0...] role=user type=turn Something near Pike Place Market would be great. K\n", - " [34249f73...] [71a3704f...] role=agent type=turn Sure! I found round-trip flights departing Friday \n", - " [eb1efd30...] [29e6e76e...] role=user type=turn Can you recommend some good restaurants in New Yor\n", - " [eb1efd30...] [d943c1a2...] role=agent type=turn Absolutely! NYC has incredible dining options. For\n", - " [eb1efd30...] [a7cb61d7...] role=user type=turn I love Italian food. Are there any options that ar\n", - " [eb1efd30...] [fbf6a5a9...] role=agent type=turn For budget-friendly Italian in NYC, check out L'in\n", - " [eb1efd30...] [summary_...] role=system type=summary The user asked for restaurant recommendations in N\n", - " [34249f73...] [summary_...] role=system type=summary The user inquired about the weather in Seattle for\n", - " [3283e3ce...] [ep_e85c2...] role=system type=episodic The user was planning a weekend trip to Seattle an\n", - " [a55e80a2...] [91c849c4...] role=user type=turn Change feed test message 1: Tell me about vector d\n", - " [a55e80a2...] [1c317519...] role=user type=turn Change feed test message 2: Tell me about vector d\n", - " [a55e80a2...] [e8aef776...] role=user type=turn Change feed test message 3: Tell me about vector d\n", - " [a55e80a2...] [summary_...] role=system type=summary The user sent three consecutive messages requestin\n", - " [ae1eb483...] [3241461e...] role=user type=turn Can you recommend some good restaurants in New Yor\n", - " [ae1eb483...] [a2d755ba...] role=agent type=turn Absolutely! NYC has incredible dining options. For\n", - " [ae1eb483...] [3fee9eaa...] role=user type=turn I love Italian food. Are there any options that ar\n", - " [ae1eb483...] [1eabf113...] role=agent type=turn For budget-friendly Italian in NYC, check out L'in\n", - " [__user_s...] [user_sum...] role=system type=user_summary {\n", - " \"key_facts\": [],\n", - " \"personal_preferences\": [\n", - " \n", - " [ae1eb483...] [summary_...] role=system type=summary The user asked for restaurant recommendations in N\n", - " [3283e3ce...] [ep_3c6fb...] role=system type=episodic The user planned a weekend trip to Seattle and req\n", - " [da6adb20...] [fact_e99...] role=system type=fact The user took a trip to Japan during cherry blosso\n", - " [__proced...] [proc_d2c...] role=system type=procedural When discussing deployment, always check the resou\n", - " [05c82d43...] [summary_...] role=system type=summary The conversation was about the user’s interest in \n", - " [05c82d43...] [fact_5b6...] role=system type=fact The user loves Italian cooking, especially pasta.\n", - " [05c82d43...] [fact_9bf...] role=system type=fact The user makes homemade fettuccine every weekend.\n", - " [f34d2765...] [summary_...] role=system type=summary The conversation was about the user’s daily runnin\n", - " [f34d2765...] [fact_cee...] role=system type=fact The user runs approximately 5 kilometres each day.\n", - " [151e417e...] [667d1b16...] role=user type=turn What's the weather like in Seattle this weekend?\n", - " [151e417e...] [00f1ec4f...] role=agent type=turn This weekend Seattle will be around 55°F with part\n", - " [151e417e...] [a49ad927...] role=agent type=turn Sure! I found round-trip flights departing Friday \n", - " [151e417e...] [a5a39119...] role=user type=turn Something near Pike Place Market would be great. K\n", - " [151e417e...] [374d57e5...] role=agent type=turn I found a round-trip on Alaska Airlines for $275 a\n", - " [75b607c1...] [f2156f30...] role=user type=turn Can you recommend some good restaurants in New Yor\n", - " [75b607c1...] [18d7b346...] role=agent type=turn Absolutely! NYC has incredible dining options. For\n", - " [75b607c1...] [f5ec5d91...] role=user type=turn I love Italian food. Are there any options that ar\n", - " [75b607c1...] [22c624a7...] role=agent type=turn For budget-friendly Italian in NYC, check out L'in\n", - " [75b607c1...] [summary_...] role=system type=summary The user asked for restaurant recommendations in N\n", - " [151e417e...] [summary_...] role=system type=summary The user inquired about the weather in Seattle for\n", - " [b09413cf...] [ff54043b...] role=user type=turn Change feed test message 1: Tell me about vector d\n", - " [b09413cf...] [b97e629e...] role=user type=turn Change feed test message 2: Tell me about vector d\n", - " [b09413cf...] [d99569a7...] role=user type=turn Change feed test message 3: Tell me about vector d\n", - " [b09413cf...] [summary_...] role=system type=summary The user submitted three consecutive test messages\n", - " [18ec5623...] [48c350cb...] role=user type=turn What's the weather like in Seattle this weekend?\n", - " [18ec5623...] [20ddefe7...] role=agent type=turn This weekend Seattle will be around 55°F with part\n", - " [18ec5623...] [17a3e670...] role=agent type=turn I found a round-trip on Alaska Airlines for $275 a\n", - " [18ec5623...] [963a36a6...] role=user type=turn Something near Pike Place Market would be great. K\n", - " [18ec5623...] [d53dad25...] role=agent type=turn Sure! I found round-trip flights departing Friday \n", - " [6514d03a...] [a6a9534e...] role=user type=turn Can you recommend some good restaurants in New Yor\n", - " [6514d03a...] [2fbee9d5...] role=agent type=turn Absolutely! NYC has incredible dining options. For\n", - " [6514d03a...] [6d1d2965...] role=user type=turn I love Italian food. Are there any options that ar\n", - " [6514d03a...] [08f3076a...] role=agent type=turn For budget-friendly Italian in NYC, check out L'in\n", - " [6514d03a...] [summary_...] role=system type=summary The user asked for restaurant recommendations in N\n", - " [18ec5623...] [summary_...] role=system type=summary The user inquired about a weekend trip to Seattle,\n", - " [8c19d9fd...] [44bd3992...] role=user type=turn Change feed test message 1: Tell me about vector d\n", - " [8c19d9fd...] [5bf99e0c...] role=user type=turn Change feed test message 2: Tell me about vector d\n", - " [8c19d9fd...] [72485888...] role=user type=turn Change feed test message 3: Tell me about vector d\n", - " [8c19d9fd...] [summary_...] role=system type=summary The user posted three consecutive test messages as\n", - " [thread-0...] [2b72e0ee...] role=user type=turn Hi! I love Cosmos DB.\n", - " [thread-0...] [1f6ffd63...] role=agent type=turn Cosmos DB is fantastic for low-latency global apps\n", - " [thread-0...] [95ed7676...] role=user type=turn Can it do vector search?\n", - " [thread-0...] [3a203195...] role=agent type=turn Yes — DiskANN indexes power semantic search native\n", - " [thread-0...] [3f725325...] role=user type=turn Great. What about hierarchical partition keys?\n", - " [thread-0...] [a92f4b54...] role=agent type=turn HPK lets you co-locate related items for efficient\n", - " [thread-0...] [9f3e86e1...] role=user type=turn Hi! I love Cosmos DB.\n", - " [thread-0...] [6370552e...] role=agent type=turn Cosmos DB is fantastic for low-latency global apps\n", - " [thread-0...] [97b7e174...] role=user type=turn Can it do vector search?\n", - " [thread-0...] [e38ecbee...] role=agent type=turn Yes — DiskANN indexes power semantic search native\n", - " [thread-0...] [70962375...] role=user type=turn Great. What about hierarchical partition keys?\n", - " [thread-0...] [72ddcc06...] role=agent type=turn HPK lets you co-locate related items for efficient\n", - " [thread-5...] [609929f8...] role=user type=turn I'm planning a hiking trip to Olympic National Par\n", - " [thread-5...] [c3c713fa...] role=agent type=turn Great choice! Hoh Rainforest and Hurricane Ridge a\n", - " [thread-5...] [39d808cf...] role=user type=turn I'd like to camp 2 nights. Any permit guidance?\n", - " [thread-5...] [c7364e90...] role=agent type=turn You'll need a wilderness permit from recreation.go\n", - " [thread-5...] [f5b81eba...] role=user type=turn Thanks — also, I'm vegetarian, please remember tha\n", - " [thread-3...] [8db09cea...] role=user type=turn I'm planning a hiking trip to Olympic National Par\n", - " [thread-3...] [c527bd97...] role=agent type=turn Great choice! Hoh Rainforest and Hurricane Ridge a\n", - " [thread-3...] [70722057...] role=user type=turn I'd like to camp 2 nights. Any permit guidance?\n", - " [thread-3...] [7371ee6c...] role=agent type=turn You'll need a wilderness permit from recreation.go\n", - " [thread-3...] [c405fc0b...] role=user type=turn Thanks — also, I'm vegetarian, please remember tha\n", - " [thread-0...] [d0e5e3c0...] role=user type=turn Hi! I love Cosmos DB.\n", - " [thread-0...] [95d62050...] role=agent type=turn Cosmos DB is fantastic for low-latency global apps\n", - " [thread-0...] [d5a09f4a...] role=user type=turn Can it do vector search?\n", - " [thread-0...] [be0085d4...] role=agent type=turn Yes — DiskANN indexes power semantic search native\n", - " [thread-0...] [cc7d040a...] role=user type=turn Great. What about hierarchical partition keys?\n", - " [thread-0...] [c09230e7...] role=agent type=turn HPK lets you co-locate related items for efficient\n", - " [thread-c...] [61bff06f...] role=user type=turn I'm planning a hiking trip to Olympic National Par\n", - " [thread-c...] [3582eb74...] role=agent type=turn Great choice! Hoh Rainforest and Hurricane Ridge a\n", - " [thread-c...] [8133e553...] role=user type=turn I'd like to camp 2 nights. Any permit guidance?\n", - " [thread-c...] [598dff39...] role=agent type=turn You'll need a wilderness permit from recreation.go\n", - " [thread-c...] [4bb7b2c4...] role=user type=turn Thanks — also, I'm vegetarian, please remember tha\n", - " [thread-c...] [summary_...] role=system type=summary The user discussed planning a hiking and camping t\n", - " [2dec0199...] [492d9dbb...] role=user type=turn What's the weather like in Seattle this weekend?\n", - " [2dec0199...] [d53348b1...] role=agent type=turn This weekend Seattle will be around 55°F with part\n", - " [2dec0199...] [048b347d...] role=agent type=turn Sure! I found round-trip flights departing Friday \n", - " [2dec0199...] [f170341e...] role=user type=turn Something near Pike Place Market would be great. K\n", - " [2dec0199...] [f3b2e998...] role=agent type=turn I found a round-trip on Alaska Airlines for $275 a\n", - " [97d1c7d2...] [b34510a1...] role=user type=turn Can you recommend some good restaurants in New Yor\n", - " [97d1c7d2...] [45d6f3eb...] role=agent type=turn Absolutely! NYC has incredible dining options. For\n", - " [97d1c7d2...] [d57ed8f9...] role=user type=turn I love Italian food. Are there any options that ar\n", - " [97d1c7d2...] [61ec5e9b...] role=agent type=turn For budget-friendly Italian in NYC, check out L'in\n", - " [2dec0199...] [summary_...] role=system type=summary The user inquired about the weather in Seattle for\n", - " [97d1c7d2...] [summary_...] role=system type=summary The user asked for restaurant recommendations in N\n", - " [437580e8...] [1eefde64...] role=user type=turn Can you recommend some good restaurants in New Yor\n", - " [437580e8...] [741b0b83...] role=agent type=turn Absolutely! NYC has incredible dining options. For\n", - " [437580e8...] [41fcd871...] role=user type=turn I love Italian food. Are there any options that ar\n", - " [437580e8...] [ebb06dba...] role=agent type=turn For budget-friendly Italian in NYC, check out L'in\n", - " [437580e8...] [summary_...] role=system type=summary The user asked for restaurant recommendations in N\n", - " [3283e3ce...] [ep_c489a...] role=system type=episodic The user was planning a weekend trip to Seattle an\n", - " [f6e63541...] [43830249...] role=user type=turn Change feed test message 1: Tell me about vector d\n", - " [f6e63541...] [9c052937...] role=user type=turn Change feed test message 2: Tell me about vector d\n", - " [f6e63541...] [8b2c0b88...] role=user type=turn Change feed test message 3: Tell me about vector d\n", - " [f6e63541...] [summary_...] role=system type=summary The user sent three consecutive test messages requ\n", - " [9ed6e905...] [10da44e8...] role=user type=turn What's the weather like in Seattle this weekend?\n", - " [9ed6e905...] [f200bbc0...] role=agent type=turn This weekend Seattle will be around 55°F with part\n", - " [9ed6e905...] [59877c89...] role=agent type=turn Sure! I found round-trip flights departing Friday \n", - " [9ed6e905...] [30b9b34f...] role=user type=turn Something near Pike Place Market would be great. K\n", - " [9ed6e905...] [9a2a651c...] role=agent type=turn I found a round-trip on Alaska Airlines for $275 a\n", - " [9ed6e905...] [d7f74720...] role=user type=turn Whenever you book a flight for me, always book an \n", - " [9ed6e905...] [bfb488e8...] role=agent type=turn Got it. I'll always select an aisle seat for your \n", - " [9ed6e905...] [1498a6b1...] role=user type=turn Also, if a round-trip flight ever costs more than \n", - " [9ed6e905...] [0d216b3d...] role=agent type=turn Understood — I'll confirm with you before booking \n", - " [9ed6e905...] [5123cac9...] role=user type=turn One more thing: when picking a hotel, always check\n", - " [9ed6e905...] [c9b3d5ab...] role=agent type=turn Will do. I'll filter hotel suggestions to only tho\n", - " [ede78157...] [6f6aec0d...] role=user type=turn Can you recommend some good restaurants in New Yor\n", - " [ede78157...] [d89aa694...] role=agent type=turn Absolutely! NYC has incredible dining options. For\n", - " [ede78157...] [2bd4f216...] role=user type=turn I love Italian food. Are there any options that ar\n", - " [ede78157...] [bda83ce2...] role=agent type=turn For budget-friendly Italian in NYC, check out L'in\n", - " [ede78157...] [summary_...] role=system type=summary The user asked for restaurant recommendations in N\n", - " [9ed6e905...] [summary_...] role=system type=summary The conversation focused on planning a weekend tri\n", - " [__proced...] [proc_931...] role=system type=procedural Always select an aisle seat when booking flights f\n", - " [__proced...] [proc_bb3...] role=system type=procedural If a round-trip flight costs more than $300, stop \n", - " [__proced...] [proc_d15...] role=system type=procedural Always verify that breakfast is included before re\n", - " [c627fc8c...] [3a23f2c1...] role=user type=turn Change feed test message 1: Tell me about vector d\n", - " [c627fc8c...] [3fb6ea61...] role=user type=turn Change feed test message 2: Tell me about vector d\n", - " [c627fc8c...] [166d689f...] role=user type=turn Change feed test message 3: Tell me about vector d\n", - " [c627fc8c...] [summary_...] role=system type=summary The user sent three consecutive messages asking fo\n", - " [e2422aed...] [0cc39f4a...] role=agent type=turn This weekend Seattle will be around 55°F with part\n", - " [e2422aed...] [a5c17037...] role=user type=turn Something near Pike Place Market would be great. K\n", - " [e2422aed...] [d2d28ce4...] role=agent type=turn I found a round-trip on Alaska Airlines for $275 a\n", - " [e2422aed...] [bed9110b...] role=user type=turn What's the weather like in Seattle this weekend?\n", - " [e2422aed...] [a0ebc75c...] role=agent type=turn Got it. I'll always select an aisle seat for your \n", - " [e2422aed...] [a07d551b...] role=agent type=turn Sure! I found round-trip flights departing Friday \n", - " [e2422aed...] [85416876...] role=user type=turn Whenever you book a flight for me, always book an \n", - " [e2422aed...] [602974a7...] role=user type=turn One more thing: when picking a hotel, always check\n", - " [e2422aed...] [a5595e14...] role=user type=turn Also, if a round-trip flight ever costs more than \n", - " [e2422aed...] [fac38202...] role=agent type=turn Will do. I'll filter hotel suggestions to only tho\n", - " [e2422aed...] [01b514c0...] role=agent type=turn Understood — I'll confirm with you before booking \n", - " [ba2753c5...] [e5242b96...] role=user type=turn Can you recommend some good restaurants in New Yor\n", - " [ba2753c5...] [f62c3be1...] role=agent type=turn Absolutely! NYC has incredible dining options. For\n", - " [ba2753c5...] [256f126e...] role=user type=turn I love Italian food. Are there any options that ar\n", - " [ba2753c5...] [5f541c2a...] role=agent type=turn For budget-friendly Italian in NYC, check out L'in\n", - " [ba2753c5...] [summary_...] role=system type=summary The user asked for restaurant recommendations in N\n", - " [e2422aed...] [summary_...] role=system type=summary The user inquired about a weekend trip to Seattle,\n", - " [3283e3ce...] [ep_69c22...] role=system type=episodic The user planned a weekend trip to Seattle and req\n", - " [e761b38f...] [644b1c65...] role=user type=turn Change feed test message 1: Tell me about vector d\n", - " [e761b38f...] [187cb97b...] role=user type=turn Change feed test message 2: Tell me about vector d\n", - " [e761b38f...] [1a4868c7...] role=user type=turn Change feed test message 3: Tell me about vector d\n", - " [e761b38f...] [summary_...] role=system type=summary The user repeatedly requested information about ve\n", - " [d3a73355...] [07408ee7...] role=user type=turn What's the weather like in Seattle this weekend?\n", - " [d3a73355...] [7fc1a400...] role=agent type=turn This weekend Seattle will be around 55°F with part\n", - " [d3a73355...] [a895d314...] role=agent type=turn Sure! I found round-trip flights departing Friday \n", - " [d3a73355...] [64d95944...] role=user type=turn Something near Pike Place Market would be great. K\n", - " [d3a73355...] [05901836...] role=agent type=turn I found a round-trip on Alaska Airlines for $275 a\n", - " [d3a73355...] [f0588b81...] role=user type=turn Whenever you book a flight for me, always book an \n", - " [d3a73355...] [a762cd26...] role=agent type=turn Got it. I'll always select an aisle seat for your \n", - " [d3a73355...] [fb3b29cb...] role=user type=turn Also, if a round-trip flight ever costs more than \n", - " [d3a73355...] [81ce6316...] role=agent type=turn Understood — I'll confirm with you before booking \n", - " [d3a73355...] [b7132ab4...] role=user type=turn One more thing: when picking a hotel, always check\n", - " [d3a73355...] [86a404c9...] role=agent type=turn Will do. I'll filter hotel suggestions to only tho\n", - " [e9ed3070...] [cd7f6b1e...] role=user type=turn Can you recommend some good restaurants in New Yor\n", - " [e9ed3070...] [9cf12919...] role=agent type=turn Absolutely! NYC has incredible dining options. For\n", - " [e9ed3070...] [fe00ba5d...] role=user type=turn I love Italian food. Are there any options that ar\n", - " [e9ed3070...] [8712d011...] role=agent type=turn For budget-friendly Italian in NYC, check out L'in\n", - " [e9ed3070...] [summary_...] role=system type=summary The user asked for restaurant recommendations in N\n", - " [d3a73355...] [summary_...] role=system type=summary The conversation centered on planning a weekend tr\n", - " [62a3a5c8...] [aa370d97...] role=user type=turn Change feed test message 1: Tell me about vector d\n", - " [62a3a5c8...] [14ab61c9...] role=user type=turn Change feed test message 2: Tell me about vector d\n", - " [62a3a5c8...] [26ee5819...] role=user type=turn Change feed test message 3: Tell me about vector d\n", - " [62a3a5c8...] [summary_...] role=system type=summary The user sent three consecutive messages asking fo\n", - " [92fcfce7...] [8db42544...] role=user type=turn What's the weather like in Seattle this weekend?\n", - " [92fcfce7...] [9b497f45...] role=agent type=turn This weekend Seattle will be around 55°F with part\n", - " [92fcfce7...] [2ac1f955...] role=agent type=turn Sure! I found round-trip flights departing Friday \n", - " [92fcfce7...] [9e72adc1...] role=user type=turn Something near Pike Place Market would be great. K\n", - " [92fcfce7...] [340d4e33...] role=agent type=turn I found a round-trip on Alaska Airlines for $275 a\n", - " [92fcfce7...] [1eb0d2c3...] role=user type=turn Whenever you book a flight for me, always book an \n", - " [92fcfce7...] [3a3d1544...] role=agent type=turn Got it. I'll always select an aisle seat for your \n", - " [92fcfce7...] [60277430...] role=user type=turn For trip planning, my workflow is: first check the\n", - " [92fcfce7...] [ba8c8d52...] role=agent type=turn Noted — I'll follow that order: weather, then flig\n", - " [92fcfce7...] [d9b1592b...] role=user type=turn And never book me into anything that departs or ar\n", - " [92fcfce7...] [2485f06d...] role=agent type=turn Will do — no overnight bookings without your expli\n", - " [26392a45...] [793c6f84...] role=user type=turn Can you recommend some good restaurants in New Yor\n", - " [26392a45...] [41f1ba4d...] role=agent type=turn Absolutely! NYC has incredible dining options. For\n", - " [26392a45...] [3fd7590b...] role=user type=turn I love Italian food. Are there any options that ar\n", - " [26392a45...] [54cf4894...] role=agent type=turn For budget-friendly Italian in NYC, check out L'in\n", - " [26392a45...] [summary_...] role=system type=summary The user asked for restaurant recommendations in N\n", - " [__proced...] [proc_62f...] role=system type=procedural When planning a trip for the user, first check the\n", - " [__proced...] [proc_b28...] role=system type=procedural Never book flights that depart or arrive between m\n", - " [92fcfce7...] [summary_...] role=system type=summary The conversation focused on planning a weekend tri\n", - " [3a9921f9...] [7ca8f672...] role=user type=turn Change feed test message 1: Tell me about vector d\n", - " [3a9921f9...] [b081cfa7...] role=user type=turn Change feed test message 2: Tell me about vector d\n", - " [3a9921f9...] [b2f71697...] role=user type=turn Change feed test message 3: Tell me about vector d\n", - " [3a9921f9...] [summary_...] role=system type=summary The user repeatedly asked for information about ve\n", - " [f0fd9a78...] [bc85dd29...] role=user type=turn What's the weather like in Seattle this weekend?\n", - " [f0fd9a78...] [7df1661f...] role=agent type=turn This weekend Seattle will be around 55°F with part\n", - " [f0fd9a78...] [1f84e8ac...] role=agent type=turn Sure! I found round-trip flights departing Friday \n", - " [f0fd9a78...] [62abba0b...] role=user type=turn Something near Pike Place Market would be great. K\n", - " [f0fd9a78...] [034bd98c...] role=agent type=turn I found a round-trip on Alaska Airlines for $275 a\n", - " [f0fd9a78...] [77ac6f91...] role=user type=turn Whenever you book a flight for me, always book an \n", - " [f0fd9a78...] [9bc141ef...] role=agent type=turn Got it. I'll always select an aisle seat for your \n", - " [f0fd9a78...] [a9d6ffc0...] role=user type=turn For trip planning, my workflow is: first check the\n", - " [f0fd9a78...] [51227197...] role=agent type=turn Noted — I'll follow that order: weather, then flig\n", - " [f0fd9a78...] [043fc770...] role=user type=turn And never book me into anything that departs or ar\n", - " [f0fd9a78...] [f6cd2184...] role=agent type=turn Will do — no overnight bookings without your expli\n", - " [5c3287a4...] [3e7d7dd6...] role=user type=turn Can you recommend some good restaurants in New Yor\n", - " [5c3287a4...] [5955e0e9...] role=agent type=turn Absolutely! NYC has incredible dining options. For\n", - " [5c3287a4...] [f45c05b0...] role=user type=turn I love Italian food. Are there any options that ar\n", - " [5c3287a4...] [9866371e...] role=agent type=turn For budget-friendly Italian in NYC, check out L'in\n", - " [5c3287a4...] [summary_...] role=system type=summary The user asked for restaurant recommendations in N\n", - " [f0fd9a78...] [summary_...] role=system type=summary The user inquired about a weekend trip to Seattle,\n", - " [2f517f40...] [468248fe...] role=user type=turn Change feed test message 1: Tell me about vector d\n", - " [2f517f40...] [13be98ec...] role=user type=turn Change feed test message 2: Tell me about vector d\n", - " [2f517f40...] [46cd74c8...] role=user type=turn Change feed test message 3: Tell me about vector d\n", - " [2f517f40...] [summary_...] role=system type=summary The user sent three identical test messages asking\n", - " [b48abfd4...] [220e3777...] role=user type=turn What's the weather like in Seattle this weekend?\n", - " [b48abfd4...] [04627b70...] role=agent type=turn This weekend Seattle will be around 55°F with part\n", - " [b48abfd4...] [8cd6cac1...] role=agent type=turn Sure! I found round-trip flights departing Friday \n", - " [b48abfd4...] [01c33d7d...] role=user type=turn Something near Pike Place Market would be great. K\n", - " [b48abfd4...] [b022017e...] role=agent type=turn I found a round-trip on Alaska Airlines for $275 a\n", - " [b48abfd4...] [6a317eda...] role=user type=turn Whenever you book a flight for me, always book an \n", - " [b48abfd4...] [83a30869...] role=agent type=turn Got it. I'll always select an aisle seat for your \n", - " [b48abfd4...] [f8df8e80...] role=user type=turn For trip planning, my workflow is: first check the\n", - " [b48abfd4...] [1d2f503d...] role=agent type=turn Noted — I'll follow that order: weather, then flig\n", - " [b48abfd4...] [d363effd...] role=user type=turn And never book me into anything that departs or ar\n", - " [b48abfd4...] [a087dfa4...] role=agent type=turn Will do — no overnight bookings without your expli\n", - " [dbdc90d0...] [1b4a20d8...] role=user type=turn Can you recommend some good restaurants in New Yor\n", - " [dbdc90d0...] [8aaead6f...] role=agent type=turn Absolutely! NYC has incredible dining options. For\n", - " [dbdc90d0...] [83df810c...] role=user type=turn I love Italian food. Are there any options that ar\n", - " [dbdc90d0...] [e2e684e6...] role=agent type=turn For budget-friendly Italian in NYC, check out L'in\n", - " [dbdc90d0...] [summary_...] role=system type=summary The user asked for restaurant recommendations in N\n", - " [b48abfd4...] [summary_...] role=system type=summary The conversation focused on planning a weekend tri\n", - " [8adaad5f...] [614a52a8...] role=user type=turn Change feed test message 1: Tell me about vector d\n", - " [8adaad5f...] [628b5e82...] role=user type=turn Change feed test message 2: Tell me about vector d\n", - " [8adaad5f...] [f05774e7...] role=user type=turn Change feed test message 3: Tell me about vector d\n", - " [8adaad5f...] [summary_...] role=system type=summary The user repeatedly requested information about ve\n", - " [a1210ca7...] [8f8c0453...] role=user type=turn What's the weather like in Seattle this weekend?\n", - " [a1210ca7...] [8486acee...] role=agent type=turn This weekend Seattle will be around 55°F with part\n", - " [a1210ca7...] [1329afa7...] role=agent type=turn Sure! I found round-trip flights departing Friday \n", - " [a1210ca7...] [210b1234...] role=user type=turn Something near Pike Place Market would be great. K\n", - " [a1210ca7...] [0712700a...] role=agent type=turn I found a round-trip on Alaska Airlines for $275 a\n", - " [a1210ca7...] [33dfad55...] role=user type=turn Whenever you book a flight for me, always book an \n", - " [a1210ca7...] [3a6887c4...] role=agent type=turn Got it. I'll always select an aisle seat for your \n", - " [a1210ca7...] [a9a357fb...] role=user type=turn For trip planning, my workflow is: first check the\n", - " [a1210ca7...] [9c18002a...] role=agent type=turn Noted — I'll follow that order: weather, then flig\n", - " [a1210ca7...] [8bc59512...] role=user type=turn And never book me into anything that departs or ar\n", - " [a1210ca7...] [7835ebd2...] role=agent type=turn Will do — no overnight bookings without your expli\n", - " [e97abcfc...] [86bbc4ef...] role=user type=turn Can you recommend some good restaurants in New Yor\n", - " [e97abcfc...] [c40acde3...] role=agent type=turn Absolutely! NYC has incredible dining options. For\n", - " [e97abcfc...] [bcab2b5c...] role=user type=turn I love Italian food. Are there any options that ar\n", - " [e97abcfc...] [25890ac3...] role=agent type=turn For budget-friendly Italian in NYC, check out L'in\n", - " [e97abcfc...] [summary_...] role=system type=summary The user asked for restaurant recommendations in N\n", - " [a1210ca7...] [summary_...] role=system type=summary The user inquired about a weekend trip to Seattle,\n", - " [a1210ca7...] [fact_ccc...] role=system type=fact The user requires round-trip flights to cost under\n", - " [__proced...] [proc_408...] role=system type=procedural Always select an aisle seat when booking flights f\n", - " [__proced...] [proc_6da...] role=system type=procedural Follow this order for trip planning: first check t\n", - " [__proced...] [proc_778...] role=system type=procedural Never book flights that depart or arrive between m\n", - " [__user_s...] [user_sum...] role=system type=user_summary For the planned Seattle weekend trip, the user set\n", - " [a1210ca7...] [fact_e7b...] role=system type=fact The user prefers to stay near Pike Place Market wh\n", - " [__proced...] [proc_056...] role=system type=procedural Always book an aisle seat when reserving flights f\n", - " [__proced...] [proc_074...] role=system type=procedural Follow the trip planning order: first check the we\n", - " [__proced...] [proc_b50...] role=system type=procedural Never book travel that departs or arrives between \n", - " [ee162c4e...] [15dd4113...] role=user type=turn Change feed test message 1: Tell me about vector d\n", - " [ee162c4e...] [b6abc60f...] role=user type=turn Change feed test message 2: Tell me about vector d\n", - " [ee162c4e...] [70dd5fba...] role=user type=turn Change feed test message 3: Tell me about vector d\n", - " [a1210ca7...] [fact_44d...] role=system type=fact The user requires hotel stays to cost under $200 p\n", - " [ee162c4e...] [summary_...] role=system type=summary The user repeatedly asked for information about ve\n", - " [8f82e8c2...] [5431ec91...] role=user type=turn What's the weather like in Seattle this weekend?\n", - " [8f82e8c2...] [86395b5c...] role=agent type=turn This weekend Seattle will be around 55°F with part\n", - " [8f82e8c2...] [f810ee90...] role=agent type=turn Sure! I found round-trip flights departing Friday \n", - " [8f82e8c2...] [adf43f71...] role=user type=turn Something near Pike Place Market would be great. K\n", - " [8f82e8c2...] [2c53284f...] role=agent type=turn I found a round-trip on Alaska Airlines for $275 a\n", - " [8f82e8c2...] [824b7d06...] role=user type=turn Whenever you book a flight for me, always book an \n", - " [8f82e8c2...] [03f4f090...] role=agent type=turn Got it. I'll always select an aisle seat for your \n", - " [8f82e8c2...] [4e39a623...] role=user type=turn For trip planning, my workflow is: first check the\n", - " [8f82e8c2...] [e61823c0...] role=agent type=turn Noted — I'll follow that order: weather, then flig\n", - " [8f82e8c2...] [011604c6...] role=user type=turn And never book me into anything that departs or ar\n", - " [8f82e8c2...] [de44f072...] role=agent type=turn Will do — no overnight bookings without your expli\n", - " [925c1a31...] [dd1a62f4...] role=user type=turn Whenever you book a flight for me, always book an \n", - " [925c1a31...] [1bc3a721...] role=agent type=turn Got it. I'll always select an aisle seat for your \n", - " [925c1a31...] [d334b9f8...] role=user type=turn For trip planning, my workflow is: first check the\n", - " [925c1a31...] [81c4308b...] role=agent type=turn Noted — I'll follow that order: weather, then flig\n", - " [925c1a31...] [03e66bf9...] role=user type=turn Never book me into anything that departs or arrive\n", - " [925c1a31...] [bbbce8be...] role=agent type=turn Will do — no overnight bookings without your expli\n", - " [925c1a31...] [6ad6dcd7...] role=user type=turn When picking a hotel, only recommend ones that inc\n", - " [925c1a31...] [490aeb85...] role=agent type=turn Understood — only hotels with complimentary breakf\n", - " [1aba6dfb...] [94d40c8a...] role=user type=turn Can you recommend some good restaurants in New Yor\n", - " [1aba6dfb...] [67c9d6d2...] role=agent type=turn Absolutely! NYC has incredible dining options. For\n", - " [1aba6dfb...] [d808c78f...] role=user type=turn I love Italian food. Are there any options that ar\n", - " [1aba6dfb...] [f973d01f...] role=agent type=turn For budget-friendly Italian in NYC, check out L'in\n", - " [925c1a31...] [summary_...] role=system type=summary The user established standing travel preferences a\n", - " [__proced...] [proc_433...] role=system type=procedural Always book an aisle seat and never select a windo\n", - " [__proced...] [proc_938...] role=system type=procedural For trip planning, first check the weather for the\n", - " [__proced...] [proc_ada...] role=system type=procedural Never book travel that departs or arrives between \n", - " [__user_s...] [user_sum...] role=system type=user_summary {\n", - " \"key_facts\": [],\n", - " \"personal_preferences\": [\n", - " \n", - " [__proced...] [proc_3c1...] role=system type=procedural Always book an aisle seat and never select a windo\n", - " [__proced...] [proc_2bf...] role=system type=procedural First check the weather, then check flights, and b\n", - " [8f82e8c2...] [summary_...] role=system type=summary The user inquired about a weekend trip to Seattle,\n", - " [1aba6dfb...] [summary_...] role=system type=summary The user asked for restaurant recommendations in N\n", - " [__proced...] [proc_4ac...] role=system type=procedural Only recommend hotels that include complimentary b\n", - " [8f82e8c2...] [fact_1fd...] role=system type=fact For the Seattle weekend trip, the user requires ro\n", - " [8f82e8c2...] [fact_b62...] role=system type=fact For the Seattle weekend trip, the user requires ho\n", - " [8f82e8c2...] [fact_555...] role=system type=fact For the Seattle weekend trip, the user prefers hot\n", - " [8f82e8c2...] [fact_5b6...] role=system type=fact No flight or hotel reservations were finalized for\n", - " [4c829316...] [d5b082ea...] role=user type=turn Change feed test message 1: Tell me about vector d\n", - " [4c829316...] [1a0a7275...] role=user type=turn Change feed test message 2: Tell me about vector d\n", - " [4c829316...] [85d26801...] role=user type=turn Change feed test message 3: Tell me about vector d\n", - " [4c829316...] [summary_...] role=system type=summary The user sent three consecutive test messages aski\n", - " [df2c66e2...] [a95f36c7...] role=user type=turn And never book me into anything that departs or ar\n", - " [df2c66e2...] [885e20a1...] role=agent type=turn Noted — I'll follow that order: weather, then flig\n", - " [df2c66e2...] [86f7ffdf...] role=user type=turn For trip planning, my workflow is: first check the\n", - " [df2c66e2...] [a14e680c...] role=agent type=turn This weekend Seattle will be around 55°F with part\n", - " [df2c66e2...] [291b33d2...] role=agent type=turn Got it. I'll always select an aisle seat for your \n", - " [df2c66e2...] [8ac8ad2d...] role=user type=turn Whenever you book a flight for me, always book an \n", - " [df2c66e2...] [c506e7b2...] role=user type=turn What's the weather like in Seattle this weekend?\n", - " [df2c66e2...] [0085b70d...] role=agent type=turn Sure! I found round-trip flights departing Friday \n", - " [ae1bb147...] [044f536b...] role=user type=turn Never book me into anything that departs or arrive\n", - " [ae1bb147...] [49f590c9...] role=agent type=turn Understood — only hotels with complimentary breakf\n", - " [ae1bb147...] [3863b2a1...] role=user type=turn Whenever you book a flight for me, always book an \n", - " [ae1bb147...] [e5a7e19f...] role=user type=turn For trip planning, my workflow is: first check the\n", - " [ae1bb147...] [36fc3840...] role=agent type=turn Got it. I'll always select an aisle seat for your \n", - " [df2c66e2...] [d2b63415...] role=agent type=turn Will do — no overnight bookings without your expli\n", - " [df2c66e2...] [293d9579...] role=agent type=turn I found a round-trip on Alaska Airlines for $275 a\n", - " [ae1bb147...] [6d68214d...] role=agent type=turn Will do — no overnight bookings without your expli\n", - " [ae1bb147...] [88479523...] role=agent type=turn Noted — I'll follow that order: weather, then flig\n", - " [df2c66e2...] [44f1c083...] role=user type=turn Something near Pike Place Market would be great. K\n", - " [ae1bb147...] [fffe6fde...] role=user type=turn When picking a hotel, only recommend ones that inc\n", - " [85e74267...] [7cfd003e...] role=user type=turn Can you recommend some good restaurants in New Yor\n", - " [85e74267...] [32b3911a...] role=agent type=turn Absolutely! NYC has incredible dining options. For\n", - " [85e74267...] [046fc368...] role=user type=turn I love Italian food. Are there any options that ar\n", - " [85e74267...] [2594fb41...] role=agent type=turn For budget-friendly Italian in NYC, check out L'in\n", - " [85e74267...] [summary_...] role=system type=summary The user asked for restaurant recommendations in N\n", - " [__proced...] [proc_b00...] role=system type=procedural Always book an aisle seat and never select a windo\n", - " [ae1bb147...] [summary_...] role=system type=summary The user established standing travel booking prefe\n", - " [__user_s...] [user_sum...] role=system type=user_summary {\n", - " \"key_facts\": [],\n", - " \"personal_preferences\": [\n", - " \n", - " [__proced...] [proc_4b0...] role=system type=procedural First check the weather, then check flights, and b\n", - " [__proced...] [proc_53a...] role=system type=procedural Never book travel that departs or arrives between \n", - " [__proced...] [proc_eef...] role=system type=procedural Only recommend hotels that include complimentary b\n", - " [df2c66e2...] [summary_...] role=system type=summary The user inquired about a weekend trip to Seattle,\n", - " [df2c66e2...] [fact_f5d...] role=system type=fact For the Seattle trip, the user requires round-trip\n", - " [df2c66e2...] [fact_a7d...] role=system type=fact For the Seattle trip, the user requires hotel rate\n", - " [df2c66e2...] [fact_53c...] role=system type=fact For the Seattle trip, the user prefers hotels loca\n", - " [__proced...] [proc_ef1...] role=system type=procedural Always book an aisle seat when reserving flights f\n", - " [__proced...] [proc_286...] role=system type=procedural When planning a trip, first check the weather for \n", - " [__proced...] [proc_9a3...] role=system type=procedural Never book flights that depart or arrive between m\n", - " [1a2686a2...] [72643b0a...] role=agent type=turn Sure! I found round-trip flights departing Friday \n", - " [1a2686a2...] [653a328a...] role=user type=turn Whenever you book a flight for me, always book an \n", - " [1a2686a2...] [0ce72055...] role=agent type=turn This weekend Seattle will be around 55°F with part\n", - " [1a2686a2...] [36f4abfe...] role=user type=turn What's the weather like in Seattle this weekend?\n", - " [1a2686a2...] [62e4971c...] role=user type=turn Something near Pike Place Market would be great. K\n", - " [1a2686a2...] [c91a8397...] role=agent type=turn Will do — no overnight bookings without your expli\n", - " [1a2686a2...] [b0f0f031...] role=agent type=turn I found a round-trip on Alaska Airlines for $275 a\n", - " [1a2686a2...] [de786284...] role=agent type=turn Got it. I'll always select an aisle seat for your \n", - " [1a2686a2...] [863a0e92...] role=agent type=turn Noted — I'll follow that order: weather, then flig\n", - " [1a2686a2...] [440b3ccd...] role=user type=turn For trip planning, my workflow is: first check the\n", - " [1a2686a2...] [6c71c103...] role=user type=turn And never book me into anything that departs or ar\n", - " [6c5e0b18...] [9d94e048...] role=agent type=turn Noted — I'll follow that order: weather, then flig\n", - " [6c5e0b18...] [a9ca1c0c...] role=user type=turn Never book me into anything that departs or arrive\n", - " [6c5e0b18...] [b8d706b5...] role=user type=turn For trip planning, my workflow is: first check the\n", - " [6c5e0b18...] [8079f2a5...] role=user type=turn Whenever you book a flight for me, always book an \n", - " [6c5e0b18...] [6ec3f38c...] role=user type=turn When picking a hotel, only recommend ones that inc\n", - " [6c5e0b18...] [b3cac85c...] role=agent type=turn Got it. I'll always select an aisle seat for your \n", - " [6c5e0b18...] [bce69f91...] role=agent type=turn Will do — no overnight bookings without your expli\n", - " [6c5e0b18...] [096d24da...] role=agent type=turn Understood — only hotels with complimentary breakf\n", - " [ac8cf2db...] [3b3f7880...] role=user type=turn Can you recommend some good restaurants in New Yor\n", - " [ac8cf2db...] [e388f6c6...] role=agent type=turn Absolutely! NYC has incredible dining options. For\n", - " [ac8cf2db...] [47cf2489...] role=user type=turn I love Italian food. Are there any options that ar\n", - " [ac8cf2db...] [ad4aa222...] role=agent type=turn For budget-friendly Italian in NYC, check out L'in\n", - " [ac8cf2db...] [summary_...] role=system type=summary The user asked for restaurant recommendations in N\n", - " [__proced...] [proc_372...] role=system type=procedural Always book an aisle seat and never select a windo\n", - " [__proced...] [proc_5c8...] role=system type=procedural Follow this order for trip planning: first check t\n", - " [__proced...] [proc_9f3...] role=system type=procedural Never book flights that depart or arrive between m\n", - " [__proced...] [proc_eb7...] role=system type=procedural Only recommend hotels that include complimentary b\n", - " [6c5e0b18...] [summary_...] role=system type=summary The user established persistent travel booking pre\n", - " [__user_s...] [user_sum...] role=system type=user_summary {\n", - " \"key_facts\": [],\n", - " \"personal_preferences\": [\n", - " \n", - " [1a2686a2...] [fact_f0a...] role=system type=fact The user prefers hotels located near Pike Place Ma\n", - " [1a2686a2...] [fact_67a...] role=system type=fact The user requires round-trip flights to cost under\n", - " [1a2686a2...] [summary_...] role=system type=summary The conversation focused on planning a weekend tri\n", - " [1a2686a2...] [fact_92f...] role=system type=fact The user requires hotels to cost under $200 per ni\n", - " [__proced...] [proc_d23...] role=system type=procedural Always book an aisle seat when reserving flights f\n", - " [__proced...] [proc_210...] role=system type=procedural For trip planning, first check the destination wea\n", - " [__proced...] [proc_afd...] role=system type=procedural Never book travel that departs or arrives between \n", - " [30387fc9...] [d0e2a4c7...] role=user type=turn Change feed test message 1: Tell me about vector d\n", - " [30387fc9...] [e81a71eb...] role=user type=turn Change feed test message 2: Tell me about vector d\n", - " [30387fc9...] [3b386db9...] role=user type=turn Change feed test message 3: Tell me about vector d\n", - " [30387fc9...] [summary_...] role=system type=summary The user repeatedly asked for information about ve\n", - " [0df5b6dc...] [f79fbed6...] role=user type=turn What's the weather like in Seattle this weekend?\n", - " [0df5b6dc...] [26681a8e...] role=agent type=turn Around 55°F with partly cloudy skies on Saturday a\n", - " [0df5b6dc...] [87fa4b2f...] role=user type=turn Can you book me a weekend trip there? Flights unde\n", - " [0df5b6dc...] [864f087a...] role=agent type=turn I found a $275 Alaska Airlines round-trip and a $1\n", - " [0df5b6dc...] [7f1c2807...] role=user type=turn Whenever you book a flight for me, always book an \n", - " [0df5b6dc...] [0cdaa994...] role=agent type=turn Got it — aisle seats only.\n", - " [0df5b6dc...] [6595962f...] role=user type=turn For trip planning, my workflow is: first weather, \n", - " [0df5b6dc...] [4f35ab5b...] role=agent type=turn Noted — weather → flights → hotel.\n", - " [0df5b6dc...] [872bf1fb...] role=user type=turn Never book me into anything between midnight and 6\n", - " [0df5b6dc...] [ab9e45ba...] role=agent type=turn Understood — no overnight bookings without your ap\n", - " [__user_s...] [user_sum...] role=system type=user_summary {\n", - " \"key_facts\": [],\n", - " \"personal_preferences\": [\n", - " \n", - " [0df5b6dc...] [summary_...] role=system type=summary The user inquired about a weekend trip to Seattle,\n", - " [bc4a98cb...] [16bb8e00...] role=user type=turn What's the weather like in Seattle this weekend?\n", - " [bc4a98cb...] [1076e63c...] role=agent type=turn Around 55°F with partly cloudy skies on Saturday a\n", - " [bc4a98cb...] [740137c4...] role=user type=turn Can you book me a weekend trip there? Flights unde\n", - " [bc4a98cb...] [6ba1d437...] role=agent type=turn I found a $275 Alaska Airlines round-trip and a $1\n", - " [bc4a98cb...] [c97de899...] role=user type=turn Whenever you book a flight for me, always book an \n", - " [bc4a98cb...] [fcf81c7c...] role=agent type=turn Got it — aisle seats only.\n", - " [bc4a98cb...] [059c3307...] role=user type=turn For trip planning, my workflow is: first weather, \n", - " [bc4a98cb...] [45e487f4...] role=agent type=turn Noted — weather → flights → hotel.\n", - " [bc4a98cb...] [0a31dba0...] role=user type=turn Never book me into anything between midnight and 6\n", - " [bc4a98cb...] [1c81ae44...] role=agent type=turn Understood — no overnight bookings without your ap\n", - " [0df5b6dc...] [fact_f54...] role=system type=fact The user requires flights to cost under $300 when \n", - " [0df5b6dc...] [fact_cd2...] role=system type=fact The user requires hotels to cost under $200 per ni\n", - " [__proced...] [proc_de5...] role=system type=procedural Always book an aisle seat and never select a windo\n", - " [__proced...] [proc_7d7...] role=system type=procedural Follow the sequence weather → flights → hotel when\n", - " [__proced...] [proc_4d7...] role=system type=procedural Never book flights or accommodations scheduled bet\n", - " [__user_s...] [user_sum...] role=system type=user_summary {\n", - " \"key_facts\": [],\n", - " \"personal_preferences\": [\n", - " \n", - " [bc4a98cb...] [summary_...] role=system type=summary The user inquired about the weather in Seattle for\n", - " [bc4a98cb...] [fact_008...] role=system type=fact The user prefers aisle seats and does not want win\n", - " [__proced...] [proc_4b6...] role=system type=procedural Always book an aisle seat and never select a windo\n", - " [__proced...] [proc_781...] role=system type=procedural Follow the trip planning sequence: first check wea\n", - " [bc4a98cb...] [fact_84c...] role=system type=fact The user requires flights to cost under $300 and h\n", - " [__proced...] [proc_861...] role=system type=procedural Always book an aisle seat when booking flights for\n", - " [__proced...] [proc_fc7...] role=system type=procedural Follow the sequence weather → flights → hotel when\n", - " [__proced...] [proc_f86...] role=system type=procedural Never book any flights, hotels, or other travel ar\n", - " [bc4a98cb...] [fact_ef8...] role=system type=fact The user requires flights to cost under $300 when \n", - " [bc4a98cb...] [fact_48a...] role=system type=fact The user requires hotels to cost under $200 per ni\n", - " [__proced...] [proc_7a9...] role=system type=procedural Always book an aisle seat when reserving flights f\n", - " [__proced...] [proc_f7a...] role=system type=procedural Never book any travel or reservations between midn\n", - " [bdd72079...] [c35421d5...] role=user type=turn What's the weather like in Seattle this weekend?\n", - " [bdd72079...] [9a99982d...] role=agent type=turn Around 55°F with partly cloudy skies on Saturday a\n", - " [bdd72079...] [23949c83...] role=user type=turn Can you book me a weekend trip there? Flights unde\n", - " [bdd72079...] [f17db44a...] role=agent type=turn I found a $275 Alaska Airlines round-trip and a $1\n", - " [bdd72079...] [037bdee7...] role=user type=turn Whenever you book a flight for me, always book an \n", - " [bdd72079...] [804c1f25...] role=agent type=turn Got it — aisle seats only.\n", - " [bdd72079...] [c8b3bc80...] role=user type=turn For trip planning, my workflow is: first weather, \n", - " [bdd72079...] [56d4e04b...] role=agent type=turn Noted — weather → flights → hotel.\n", - " [bdd72079...] [3ba30ca4...] role=user type=turn Never book me into anything between midnight and 6\n", - " [bdd72079...] [9857a10d...] role=agent type=turn Understood — no overnight bookings without your ap\n", - " [__user_s...] [user_sum...] role=system type=user_summary {\n", - " \"key_facts\": [],\n", - " \"personal_preferences\": [\n", - " \n", - " [bdd72079...] [summary_...] role=system type=summary The conversation centered on planning a potential \n", - " [bdd72079...] [fact_18e...] role=system type=fact The user requires flights under $300 and hotels un\n", - " [__proced...] [proc_352...] role=system type=procedural Always book an aisle seat when reserving flights f\n", - " [__proced...] [proc_df7...] role=system type=procedural Follow the sequence: check weather first, then boo\n", - " [__proced...] [proc_a79...] role=system type=procedural Never book flights, hotels, or other travel arrang\n", - " [42b91b2c...] [18d9c7c9...] role=user type=turn What's the weather like in Seattle this weekend?\n", - " [42b91b2c...] [aee54464...] role=agent type=turn Around 55°F with partly cloudy skies on Saturday a\n", - " [42b91b2c...] [eb65d898...] role=user type=turn Can you book me a weekend trip there? Flights unde\n", - " [42b91b2c...] [2610f0f2...] role=agent type=turn I found a $275 Alaska Airlines round-trip and a $1\n", - " [42b91b2c...] [a2c8f719...] role=user type=turn Whenever you book a flight for me, always book an \n", - " [42b91b2c...] [81e4ae3f...] role=agent type=turn Got it — aisle seats only.\n", - " [42b91b2c...] [d8bb773e...] role=user type=turn For trip planning, my workflow is: first weather, \n", - " [42b91b2c...] [88c29041...] role=agent type=turn Noted — weather → flights → hotel.\n", - " [42b91b2c...] [e72a7a00...] role=user type=turn Never book me into anything between midnight and 6\n", - " [42b91b2c...] [aec0a2ba...] role=agent type=turn Understood — no overnight bookings without your ap\n", - " [__user_s...] [user_sum...] role=system type=user_summary {\n", - " \"key_facts\": [],\n", - " \"personal_preferences\": [\n", - " \n", - " [42b91b2c...] [summary_...] role=system type=summary The user inquired about a weekend trip to Seattle,\n", - " [42b91b2c...] [fact_95d...] role=system type=fact The user requested booking a weekend trip to Seatt\n", - " [42b91b2c...] [fact_81e...] role=system type=fact The user requires flights to cost under $300 and h\n", - " [__proced...] [proc_d89...] role=system type=procedural Always book an aisle seat and never book a window \n", - " [__proced...] [proc_5ed...] role=system type=procedural Follow the sequence weather first, then flights, t\n", - " [__proced...] [proc_afb...] role=system type=procedural Never book flights or accommodations between midni\n", - " [e50f775e...] [3e4513c7...] role=user type=turn What's the weather like in Seattle this weekend?\n", - " [e50f775e...] [88a718fa...] role=agent type=turn This weekend Seattle will be around 55°F with part\n", - " [e50f775e...] [5d25077d...] role=agent type=turn Sure! I found round-trip flights departing Friday \n", - " [e50f775e...] [79dae6a8...] role=user type=turn Something near Pike Place Market would be great. K\n", - " [e50f775e...] [4f8721a6...] role=agent type=turn I found a round-trip on Alaska Airlines for $275 a\n", - " [e50f775e...] [fb17aeea...] role=user type=turn Whenever you book a flight for me, always book an \n", - " [e50f775e...] [3f00a18c...] role=agent type=turn Got it. I'll always select an aisle seat for your \n", - " [e50f775e...] [a8485c36...] role=user type=turn For trip planning, my workflow is: first check the\n", - " [e50f775e...] [4d4926ec...] role=agent type=turn Noted — I'll follow that order: weather, then flig\n", - " [e50f775e...] [4e597b6d...] role=user type=turn And never book me into anything that departs or ar\n", - " [e50f775e...] [96aa9017...] role=agent type=turn Will do — no overnight bookings without your expli\n", - " [8f42e1b5...] [d060a91b...] role=user type=turn Whenever you book a flight for me, always book an \n", - " [8f42e1b5...] [26ba3a10...] role=agent type=turn Got it. I'll always select an aisle seat for your \n", - " [8f42e1b5...] [4efc2fe2...] role=user type=turn For trip planning, my workflow is: first check the\n", - " [8f42e1b5...] [2430022a...] role=agent type=turn Noted — I'll follow that order: weather, then flig\n", - " [8f42e1b5...] [61a8ac71...] role=user type=turn Never book me into anything that departs or arrive\n", - " [8f42e1b5...] [300757b0...] role=agent type=turn Will do — no overnight bookings without your expli\n", - " [8f42e1b5...] [1fe93ba3...] role=user type=turn When picking a hotel, only recommend ones that inc\n", - " [8f42e1b5...] [c997e440...] role=agent type=turn Understood — only hotels with complimentary breakf\n", - " [7b8fc78b...] [0ad9d278...] role=user type=turn Can you recommend some good restaurants in New Yor\n", - " [7b8fc78b...] [0e5d8a0a...] role=agent type=turn Absolutely! NYC has incredible dining options. For\n", - " [7b8fc78b...] [ec1a3a5d...] role=user type=turn I love Italian food. Are there any options that ar\n", - " [7b8fc78b...] [c0437ffe...] role=agent type=turn For budget-friendly Italian in NYC, check out L'in\n", - " [8f42e1b5...] [summary_...] role=system type=summary The user established persistent travel booking pre\n", - " [7b8fc78b...] [summary_...] role=system type=summary The user asked for restaurant recommendations in N\n", - " [__proced...] [proc_afe...] role=system type=procedural Always book an aisle seat and never select a windo\n", - " [__proced...] [proc_c12...] role=system type=procedural Follow this order for trip planning: first check t\n", - " [__proced...] [proc_c6f...] role=system type=procedural Never book travel that departs or arrives between \n", - " [__user_s...] [user_sum...] role=system type=user_summary {\n", - " \"key_facts\": [],\n", - " \"personal_preferences\": [\n", - " \n", - " [__proced...] [proc_9d5...] role=system type=procedural Only recommend hotels that include complimentary b\n", - " [e50f775e...] [summary_...] role=system type=summary The user inquired about a weekend trip to Seattle,\n", - " [e50f775e...] [fact_9e9...] role=system type=fact The user prefers hotels located near Pike Place Ma\n", - " [e50f775e...] [fact_2ad...] role=system type=fact The user requires round-trip flights to cost under\n", - " [e50f775e...] [fact_230...] role=system type=fact The user requires hotel rates to be under $200 per\n", - " [__proced...] [proc_dee...] role=system type=procedural Always book an aisle seat when reserving flights f\n", - " [807c3bc6...] [c6b6827e...] role=agent type=turn This weekend Seattle will be around 55°F with part\n", - " [807c3bc6...] [101560c2...] role=agent type=turn Sure! I found round-trip flights departing Friday \n", - " [807c3bc6...] [558654f4...] role=user type=turn What's the weather like in Seattle this weekend?\n", - " [c1138077...] [47eef782...] role=user type=turn Whenever you book a flight for me, always book an \n", - " [c1138077...] [30da082b...] role=agent type=turn Will do — no overnight bookings without your expli\n", - " [c1138077...] [40665284...] role=agent type=turn Got it. I'll always select an aisle seat for your \n", - " [c1138077...] [c5d66e1a...] role=user type=turn Never book me into anything that departs or arrive\n", - " [807c3bc6...] [5544d374...] role=user type=turn For trip planning, my workflow is: first check the\n", - " [807c3bc6...] [3ee542c4...] role=agent type=turn Got it. I'll always select an aisle seat for your \n", - " [807c3bc6...] [67cee94e...] role=agent type=turn I found a round-trip on Alaska Airlines for $275 a\n", - " [807c3bc6...] [afe25494...] role=user type=turn Something near Pike Place Market would be great. K\n", - " [c1138077...] [2b7e104d...] role=agent type=turn Noted — I'll follow that order: weather, then flig\n", - " [807c3bc6...] [bb55ae9b...] role=user type=turn Whenever you book a flight for me, always book an \n", - " [c1138077...] [4e5b3a7d...] role=agent type=turn Understood — only hotels with complimentary breakf\n", - " [c1138077...] [15f9f705...] role=user type=turn For trip planning, my workflow is: first check the\n", - " [807c3bc6...] [97401d13...] role=agent type=turn Will do — no overnight bookings without your expli\n", - " [807c3bc6...] [3a42a459...] role=agent type=turn Noted — I'll follow that order: weather, then flig\n", - " [807c3bc6...] [056e8fcb...] role=user type=turn And never book me into anything that departs or ar\n", - " [c1138077...] [705626cf...] role=user type=turn When picking a hotel, only recommend ones that inc\n", - " [6b59bbaf...] [cc399b5f...] role=user type=turn Can you recommend some good restaurants in New Yor\n", - " [6b59bbaf...] [6a66be86...] role=agent type=turn Absolutely! NYC has incredible dining options. For\n", - " [6b59bbaf...] [287c7246...] role=user type=turn I love Italian food. Are there any options that ar\n", - " [6b59bbaf...] [546aff6a...] role=agent type=turn For budget-friendly Italian in NYC, check out L'in\n" - ] - } - ], - "source": [ - "# Delete the tool memory from Cosmos (async)\n", - "tool_mems = await memory.get_memories(user_id=\"user-002\", role=\"tool\")\n", - "print(tool_mems[0])\n", - "if tool_mems:\n", - " await memory.delete_cosmos(\n", - " tool_mems[0][\"id\"],\n", - " thread_id=tool_mems[0][\"thread_id\"],\n", - " user_id=tool_mems[0][\"user_id\"],\n", - " )\n", - " print(f\"Deleted tool memory {tool_mems[0]['id'][:8]}...\")\n", - "\n", - "# Verify\n", - "remaining = await memory.get_memories()\n", - "print(f\"\\nRemaining memories in Cosmos DB: {len(remaining)}\")\n", - "for r in remaining:\n", - " print(f\" [{r['thread_id'][:8]}...] [{r['id'][:8]}...] role={r['role']:<6} type={r['type']:<8} {r['content'][:50]}\")" - ] - }, - { - "cell_type": "markdown", - "id": "007708d5", - "metadata": {}, - "source": [ - "### 3e. Retrieve a full thread with `get_thread`\n", - "\n", - "Same parameters: `thread_id` (required), `user_id` (optional), `recent_k` (optional)." - ] - }, - { - "cell_type": "code", - "execution_count": 13, - "id": "3ed613d3", - "metadata": { - "ExecuteTime": { - "end_time": "2026-04-07T22:07:40.340577Z", - "start_time": "2026-04-07T22:07:40.138825Z" - }, - "execution": { - "iopub.execute_input": "2026-05-04T20:25:50.014174Z", - "iopub.status.busy": "2026-05-04T20:25:50.014096Z", - "iopub.status.idle": "2026-05-04T20:25:50.246063Z", - "shell.execute_reply": "2026-05-04T20:25:50.245174Z" - } - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Using thread_id: 807c3bc6-c021-4f66-b996-07bc5ef781ab\n", - "\n", - "All memories in thread: 11\n", - " [807c3bc6...] [558654f4...] role=user type=turn What's the weather like in Seattle this weekend?\n", - " [807c3bc6...] [c6b6827e...] role=agent type=turn This weekend Seattle will be around 55°F with partly cloudy \n", - " [807c3bc6...] [101560c2...] role=agent type=turn Sure! I found round-trip flights departing Friday evening an\n", - " [807c3bc6...] [afe25494...] role=user type=turn Something near Pike Place Market would be great. Keep flight\n", - " [807c3bc6...] [67cee94e...] role=agent type=turn I found a round-trip on Alaska Airlines for $275 and two hot\n", - " [807c3bc6...] [bb55ae9b...] role=user type=turn Whenever you book a flight for me, always book an aisle seat\n", - " [807c3bc6...] [3ee542c4...] role=agent type=turn Got it. I'll always select an aisle seat for your bookings.\n", - " [807c3bc6...] [5544d374...] role=user type=turn For trip planning, my workflow is: first check the weather f\n", - " [807c3bc6...] [3a42a459...] role=agent type=turn Noted — I'll follow that order: weather, then flights, then \n", - " [807c3bc6...] [056e8fcb...] role=user type=turn And never book me into anything that departs or arrives betw\n", - " [807c3bc6...] [97401d13...] role=agent type=turn Will do — no overnight bookings without your explicit approv\n", - "\n", - "Most recent 2 memories:\n", - " [807c3bc6...] [056e8fcb...] role=user type=turn And never book me into anything that departs or arrives betw\n", - " [807c3bc6...] [97401d13...] role=agent type=turn Will do — no overnight bookings without your explicit approv\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\n", - "Thread memories for user-ea5eba7a: 11\n" - ] - } - ], - "source": [ - "# Use the CURRENT seed thread (from cell 5) so we operate on the data we just wrote.\n", - "thread_id = THREAD_ID\n", - "print(f\"Using thread_id: {thread_id}\\n\")\n", - "\n", - "# Get all documents in the thread\n", - "thread_all = await memory.get_thread(thread_id=thread_id)\n", - "print(f\"All memories in thread: {len(thread_all)}\")\n", - "for m in thread_all:\n", - " print(f\" [{m['thread_id'][:8]}...] [{m['id'][:8]}...] role={m.get('role','?'):6} type={m['type']:8} {m['content'][:60]}\")\n", - "\n", - "recent = await memory.get_thread(thread_id=thread_id, recent_k=2)\n", - "print(f\"\\nMost recent 2 memories:\")\n", - "for m in recent:\n", - " print(f\" [{m['thread_id'][:8]}...] [{m['id'][:8]}...] role={m.get('role','?'):6} type={m['type']:8} {m['content'][:60]}\")\n", - "\n", - "thread_user = await memory.get_thread(thread_id=thread_id, user_id=USER_ID)\n", - "print(f\"\\nThread memories for {USER_ID}: {len(thread_user)}\")\n" - ] - }, - { - "cell_type": "markdown", - "id": "06a9f99d", - "metadata": {}, - "source": [ - "## 4. Thread Summary (in-process)\n", - "\n", - "`AsyncCosmosMemoryClient.generate_thread_summary()` runs the summarisation pipeline **in-process** — no Azure Functions required. The async client uses the AI Foundry async openai client and the async Cosmos SDK, so calls don't block the event loop.\n", - "\n", - "If a prior summary exists, the call performs an **incremental update** that preserves the metadata-tracked `source_count`.\n" - ] - }, - { - "cell_type": "code", - "execution_count": 14, - "id": "9bc68919", - "metadata": { - "ExecuteTime": { - "end_time": "2026-04-07T22:08:08.478793Z", - "start_time": "2026-04-07T22:07:45.385054Z" - }, - "execution": { - "iopub.execute_input": "2026-05-04T20:25:50.247941Z", - "iopub.status.busy": "2026-05-04T20:25:50.247791Z", - "iopub.status.idle": "2026-05-04T20:26:03.871259Z", - "shell.execute_reply": "2026-05-04T20:26:03.870396Z" - } - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Summarizing thread_id=807c3bc6-c021-4f66-b996-07bc5ef781ab user_id=user-ea5eba7a\n", - "\n" - ] - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - "LLM model=gpt-5.2-chat rejected 'temperature'; retrying without it.\n" - ] - } - ], - "source": [ - "thread_id = THREAD_ID\n", - "user_id = USER_ID\n", - "print(f\"Summarizing thread_id={thread_id} user_id={user_id}\\n\")\n", - "\n", - "summary_doc = await memory.generate_thread_summary(user_id=user_id, thread_id=thread_id)\n" - ] - }, - { - "cell_type": "code", - "execution_count": 15, - "id": "da4cba4f", - "metadata": { - "ExecuteTime": { - "end_time": "2026-04-07T22:08:13.446032Z", - "start_time": "2026-04-07T22:08:13.390800Z" - }, - "execution": { - "iopub.execute_input": "2026-05-04T20:26:03.875835Z", - "iopub.status.busy": "2026-05-04T20:26:03.875663Z", - "iopub.status.idle": "2026-05-04T20:26:03.879262Z", - "shell.execute_reply": "2026-05-04T20:26:03.878646Z" - } - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Summary document:\n", - " id: summary_user-ea5eba7a_807c3bc6-c021-4f66-b996-07bc5ef781ab\n", - " content: The conversation centered on planning a weekend trip to Seattle, including checking the weather, identifying flights and hotels near Pike Place Market within specified budgets, and establishing the us...\n", - " source_count: 11\n", - " embedding length: 1536\n" - ] - } - ], - "source": [ - "print(\"Summary document:\")\n", - "print(f\" id: {summary_doc['id']}\")\n", - "print(f\" content: {summary_doc['content'][:200]}...\")\n", - "print(f\" source_count: {summary_doc.get('metadata', {}).get('source_count')}\")\n", - "print(f\" embedding length: {len(summary_doc.get('embedding', []))}\")\n" - ] - }, - { - "cell_type": "markdown", - "id": "3cd2e4f8", - "metadata": {}, - "source": [ - "## 5. Memory Extraction (facts + episodic + procedural)\n", - "\n", - "`extract_memories()` runs a single LLM call that produces three structured memory types:\n", - "\n", - "| Type | Description |\n", - "|--------------|--------------------------------------------------------------------------|\n", - "| `fact` | Stable, atomic facts about the user. |\n", - "| `episodic` | Discrete past events the user described. |\n", - "| `procedural` | How-to guidance the agent should follow. |\n", - "\n", - "Each derived memory is embedded and stored in Cosmos DB with auto-generated tags and a salience score.\n" - ] - }, - { - "cell_type": "code", - "execution_count": 16, - "id": "e4d57e2d", - "metadata": { - "ExecuteTime": { - "end_time": "2026-04-07T22:08:23.444563Z", - "start_time": "2026-04-07T22:08:17.255145Z" - }, - "execution": { - "iopub.execute_input": "2026-05-04T20:26:03.881644Z", - "iopub.status.busy": "2026-05-04T20:26:03.881553Z", - "iopub.status.idle": "2026-05-04T20:26:11.858903Z", - "shell.execute_reply": "2026-05-04T20:26:11.857972Z" - } - }, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "LLM model=gpt-5.2-chat rejected 'temperature'; retrying without it.\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Seed thread extraction: {'facts_count': 1, 'procedural_count': 0, 'episodic_count': 0, 'updated_count': 0}\n" - ] - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - "LLM model=gpt-5.2-chat rejected 'temperature'; retrying without it.\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Rules thread extraction: {'facts_count': 0, 'procedural_count': 0, 'episodic_count': 0, 'updated_count': 0}\n" - ] - } - ], - "source": [ - "# Extract memories from both the SEED and the pure-procedural RULES thread.\n", - "result_main = await memory.extract_memories(user_id=USER_ID, thread_id=THREAD_ID)\n", - "print(\"Seed thread extraction:\", result_main)\n", - "\n", - "result_rules = await memory.extract_memories(user_id=USER_ID, thread_id=RULES_THREAD_ID)\n", - "print(\"Rules thread extraction:\", result_rules)\n" - ] - }, - { - "cell_type": "code", - "execution_count": 17, - "id": "795e8634", - "metadata": { - "ExecuteTime": { - "end_time": "2026-04-07T22:08:26.904418Z", - "start_time": "2026-04-07T22:08:26.587707Z" - }, - "execution": { - "iopub.execute_input": "2026-05-04T20:26:11.861697Z", - "iopub.status.busy": "2026-05-04T20:26:11.861551Z", - "iopub.status.idle": "2026-05-04T20:26:12.283813Z", - "shell.execute_reply": "2026-05-04T20:26:12.283042Z" - } - }, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "get_memories returned empty results\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\n", - "FACTS (3):\n", - " • The user prefers round-trip flights under $300. [salience=0.7]\n", - " • The user prefers hotels under $200 per night. [salience=0.7]\n", - " • The user prefers hotels located near Pike Place Market when staying in Seattle. [salience=0.6]\n", - "\n", - "EPISODICS (0):\n", - "\n", - "PROCEDURALS (7):\n", - " • Always book an aisle seat when reserving flights for the user, and never select a window or middle s [salience=0.9]\n", - " • For trip planning, first check the weather, then check flights, and book the hotel last after everyt [salience=0.85]\n", - " • Never book travel that departs or arrives between midnight and 6am unless the user explicitly approv [salience=0.9]\n", - " • Only recommend hotels that include complimentary breakfast. [salience=0.85]\n", - " • Always book an aisle seat and never select a window or middle seat when booking flights for the user [salience=0.9]\n", - " • Follow this trip planning order: first check the weather, then check flights, and book the hotel las [salience=0.85]\n", - " • Never book flights that depart or arrive between midnight and 6am unless the user explicitly approve [salience=0.9]\n" - ] - } - ], - "source": [ - "# Inspect the persisted derived memories across BOTH threads for this user.\n", - "for mt in (\"fact\", \"episodic\", \"procedural\"):\n", - " docs = await memory.get_memories(user_id=USER_ID, memory_types=[mt])\n", - " print(f\"\\n{mt.upper()}S ({len(docs)}):\")\n", - " for d in docs:\n", - " print(f\" • {d['content'][:100]} [salience={d.get('salience')}]\")\n" - ] - }, - { - "cell_type": "markdown", - "id": "3ad14e69", - "metadata": {}, - "source": [ - "## 6. User Summary (cross-thread profile)\n", - "\n", - "`generate_user_summary()` aggregates memories **across all threads** for a user and produces a structured profile (preferences, account state, behavioural patterns, …). The result is stored in Cosmos DB with `type: \"user_summary\"`.\n", - "\n", - "Retrieve the latest stored profile at any time with `get_user_summary(user_id)`.\n" - ] - }, - { - "cell_type": "code", - "execution_count": 18, - "id": "cbd3806f", - "metadata": { - "ExecuteTime": { - "end_time": "2026-04-07T22:08:37.628678Z", - "start_time": "2026-04-07T22:08:29.322243Z" - }, - "execution": { - "iopub.execute_input": "2026-05-04T20:26:12.285934Z", - "iopub.status.busy": "2026-05-04T20:26:12.285802Z", - "iopub.status.idle": "2026-05-04T20:26:22.526266Z", - "shell.execute_reply": "2026-05-04T20:26:22.525613Z" - } - }, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "LLM model=gpt-5.2-chat rejected 'temperature'; retrying without it.\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "User summary id: user_summary_user-ea5eba7a\n", - "\n", - "Content:\n", - " {\n", - " \"key_facts\": [],\n", - " \"personal_preferences\": [\n", - " \"The user prefers aisle seats for all flight bookings and explicitly does not want window or middle seats.\",\n", - " \"The user does not want flights that depart or arrive between midnight and 6am unless they explicitly approve it.\",\n", - " \"For trip planning, the user prefers the workflow: first check the weather, then check flights, and book the hotel last after everything else is confirmed.\",\n", - " \"When selecting hotels, the user only wants options that include complimentary breakfast.\",\n", - " \"The user prefers round-trip flights under $300 when set ...\n", - "\n", - "Structured profile keys: ['key_facts', 'personal_preferences', 'account_environment', 'goals_current_work', 'behavioral_patterns', 'compliance_requirements', 'open_items', 'topics']\n" - ] - } - ], - "source": [ - "# Generate a user-level summary across all threads.\n", - "user_summary_doc = await memory.generate_user_summary(user_id=user_id)\n", - "print(\"User summary id:\", user_summary_doc[\"id\"])\n", - "print(\"\\nContent:\\n\", user_summary_doc[\"content\"][:600], \"...\")\n", - "print(\"\\nStructured profile keys:\", list(user_summary_doc.get(\"metadata\", {}).get(\"structured_summary\", {}).keys()))\n" - ] - }, - { - "cell_type": "code", - "execution_count": 19, - "id": "97ddc94f", - "metadata": { - "ExecuteTime": { - "end_time": "2026-04-07T22:08:39.653532Z", - "start_time": "2026-04-07T22:08:39.229659Z" - }, - "execution": { - "iopub.execute_input": "2026-05-04T20:26:22.528078Z", - "iopub.status.busy": "2026-05-04T20:26:22.527959Z", - "iopub.status.idle": "2026-05-04T20:26:22.618478Z", - "shell.execute_reply": "2026-05-04T20:26:22.618055Z" - } - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "User Summary for user-ea5eba7a\n", - "{\n", - " \"key_facts\": [],\n", - " \"personal_preferences\": [\n", - " \"The user prefers aisle seats for all flight bookings and explicitly does not want window or middle seats.\",\n", - " \"The user does not want flights that depart or arrive between midnight and 6am unless they explicitly approve it.\",\n", - " \"For trip planning, the user prefers the workflow: first check the weather, then check flights, and book the hotel last after everything else is confirmed.\",\n", - " \"When selecting hotels, the user only wants options that include complimentary breakfast.\",\n", - " \"The user prefers round-trip flights under $300 when setting flight budgets.\",\n", - " \"The user prefers hotels under $200 per night when setting lodging budgets.\",\n", - " \"When staying in Seattle, the user prefers hotels located near Pike Place Market.\"\n", - " ],\n", - " \"account_environment\": [],\n", - " \"goals_current_work\": [\n", - " \"The user is planning a weekend trip to Seattle with a goal of keeping flights under $300 round trip and hotels under $200 per night near Pike Place Market.\"\n", - " ],\n", - " \"behavioral_patterns\": [\n", - " \"The user provides clear, rule-based constraints for travel bookings and expects them to be remembered and consistently applied.\",\n", - " \"The user refines requirements mid-conversation, such as clarifying hotel budget limits.\",\n", - " \"The user repeats key travel preferences across threads to reinforce persistent booking rules.\"\n", - " ],\n", - " \"compliance_requirements\": [],\n", - " \"open_items\": [\n", - " \"No final decision has been made on whether to reserve the identified $275 round-trip Alaska Airlines flight to Seattle.\",\n", - " \"No hotel selection has been finalized between the Inn at the Market and the Hilton Garden Inn for the Seattle trip.\"\n", - " ],\n", - " \"topics\": [\n", - " \"travel\",\n", - " \"trip planning\",\n", - " \"flights\",\n", - " \"hotels\",\n", - " \"budget travel\",\n", - " \"seattle\"\n", - " ]\n", - "}\n" - ] - } - ], - "source": [ - "# Retrieve the stored user summary from Cosmos DB (async)\n", - "stored = await memory.get_user_summary(user_id=user_id)\n", - "if stored:\n", - " print(\"User Summary for\", user_id)\n", - " print(stored[\"content\"])\n", - "else:\n", - " print(\"No user summary found — run the generate_user_summary cell first.\")\n" - ] - }, - { - "cell_type": "markdown", - "id": "92e5d32b", - "metadata": {}, - "source": [ - "### 7. Vector search with `search_cosmos`\n", - "\n", - "Same as the sync version — embeds the query and runs a `VectorDistance` similarity search." - ] - }, - { - "cell_type": "code", - "execution_count": 20, - "id": "af4afa77", - "metadata": { - "ExecuteTime": { - "end_time": "2026-04-07T22:08:46.028010Z", - "start_time": "2026-04-07T22:08:43.195430Z" - }, - "execution": { - "iopub.execute_input": "2026-05-04T20:26:22.619506Z", - "iopub.status.busy": "2026-05-04T20:26:22.619453Z", - "iopub.status.idle": "2026-05-04T20:26:24.825313Z", - "shell.execute_reply": "2026-05-04T20:26:24.824663Z" - } - }, - "outputs": [], - "source": [ - "results_search_async = await memory.search_cosmos(\n", - " search_terms=\"What did the user ask about the weather?\",\n", - " user_id=USER_ID,\n", - " top_k=3, hybrid_search= True\n", - ")" - ] - }, - { - "cell_type": "code", - "execution_count": 21, - "id": "c0471fd4", - "metadata": { - "ExecuteTime": { - "end_time": "2026-04-07T22:08:47.537201Z", - "start_time": "2026-04-07T22:08:47.500038Z" - }, - "execution": { - "iopub.execute_input": "2026-05-04T20:26:24.827496Z", - "iopub.status.busy": "2026-05-04T20:26:24.827365Z", - "iopub.status.idle": "2026-05-04T20:26:24.830446Z", - "shell.execute_reply": "2026-05-04T20:26:24.829891Z" - } - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Top 3 results:\n", - "\n", - " [summary_...] score=N/A The conversation centered on planning a weekend trip to Seat\n", - " [user_sum...] score=N/A {\n", - " \"key_facts\": [],\n", - " \"personal_preferences\": [\n", - " \"The us\n", - " [fact_023...] score=N/A The user prefers hotels located near Pike Place Market when \n" - ] - } - ], - "source": [ - "print(f\"Top {len(results_search_async)} results:\\n\")\n", - "for r in results_search_async:\n", - " score = r.get(\"score\", \"N/A\")\n", - " print(f\" [{r['id'][:8]}...] score={score} {r['content'][:60]}\")" - ] - }, - { - "cell_type": "code", - "execution_count": 22, - "id": "bb4cc8f8", - "metadata": { - "ExecuteTime": { - "end_time": "2026-04-07T22:08:49.434405Z", - "start_time": "2026-04-07T22:08:49.164046Z" - }, - "execution": { - "iopub.execute_input": "2026-05-04T20:26:24.831979Z", - "iopub.status.busy": "2026-05-04T20:26:24.831863Z", - "iopub.status.idle": "2026-05-04T20:26:24.835490Z", - "shell.execute_reply": "2026-05-04T20:26:24.834936Z" - } - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Async clients closed.\n" - ] - } - ], - "source": [ - "# Clean up async clients when done\n", - "await memory.close()\n", - "print(\"Async clients closed.\")" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "py314", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.11.15" - } - }, - "nbformat": 4, - "nbformat_minor": 5 -} diff --git a/Samples/Demo.ipynb b/Samples/Notebooks/Demo.ipynb similarity index 99% rename from Samples/Demo.ipynb rename to Samples/Notebooks/Demo.ipynb index f98a547..d7c5c83 100644 --- a/Samples/Demo.ipynb +++ b/Samples/Notebooks/Demo.ipynb @@ -19,7 +19,7 @@ "8. **Tagging, salience & deduplication** – tag mutation, salience filter, `reconcile()`\n", "9. **Automatic processing (Change Feed)** – optional Azure Function for background processing\n", "\n", - "> 💡 **Tip:** the synchronous `CosmosMemoryClient` accepts an optional `processor=` kwarg (defaults to `InProcessProcessor`). Pass `DurableFunctionProcessor()` to delegate summarization to the sibling Azure Function app — see `Samples/scenario_remote_processor.py`.\n" + "> 💡 **Tip:** the synchronous `CosmosMemoryClient` accepts an optional `processor=` kwarg (defaults to `InProcessProcessor`). Pass `DurableFunctionProcessor()` to delegate summarization to the sibling Azure Function app — see `Samples/Scenarios/scenario_remote_processor.py`.\n" ] }, { @@ -34,7 +34,7 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": null, "id": "843cc6f6", "metadata": { "ExecuteTime": { @@ -65,43 +65,22 @@ ], "source": [ "import os, json\n", - "\n", "from dotenv import load_dotenv\n", - "\n", "from azure.identity import DefaultAzureCredential\n", "\n", - "\n", - "\n", "# Add parent directory to path so we can import the package easily\n", - "\n", "import sys\n", - "\n", "sys.path.insert(0, os.path.abspath(\"..\"))\n", - "\n", - "\n", - "\n", "from agent_memory_toolkit import CosmosMemoryClient\n", - "\n", - "\n", - "\n", "# Load environment variables from .env in the repo root\n", "\n", "load_dotenv(os.path.join(\"..\", \".env\"))\n", - "\n", - "\n", - "\n", "print(\"COSMOS_DB_ENDPOINT:\", os.getenv(\"COSMOS_DB_ENDPOINT\"))\n", - "\n", "print(\"COSMOS_DB_DATABASE:\", os.getenv(\"COSMOS_DB_DATABASE\"))\n", - "\n", "print(\"COSMOS_DB_CONTAINER:\", os.getenv(\"COSMOS_DB_CONTAINER\"))\n", - "\n", "print(\"COSMOS_DB_COUNTERS_CONTAINER:\", os.getenv(\"COSMOS_DB_COUNTERS_CONTAINER\", \"counter\"))\n", - "\n", "print(\"COSMOS_DB_LEASE_CONTAINER:\", os.getenv(\"COSMOS_DB_LEASE_CONTAINER\", \"leases\"))\n", - "\n", "print(\"COSMOS_DB_THROUGHPUT_MODE:\", os.getenv(\"COSMOS_DB_THROUGHPUT_MODE\", \"serverless\"))\n", - "\n", "print(\"COSMOS_DB_AUTOSCALE_MAX_RU:\", os.getenv(\"COSMOS_DB_AUTOSCALE_MAX_RU\", \"1000\"))" ] }, diff --git a/Samples/Notebooks/Demo_async.ipynb b/Samples/Notebooks/Demo_async.ipynb new file mode 100644 index 0000000..5875b2d --- /dev/null +++ b/Samples/Notebooks/Demo_async.ipynb @@ -0,0 +1,1399 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "04a283f1", + "metadata": {}, + "source": [ + "## 1. Setup\n", + "\n", + "Install/import dependencies and load environment variables from `.env`." + ] + }, + { + "cell_type": "code", + "execution_count": 20, + "id": "15434fb9", + "metadata": { + "ExecuteTime": { + "end_time": "2026-04-07T22:06:39.082693Z", + "start_time": "2026-04-07T22:06:38.712684Z" + }, + "execution": { + "iopub.execute_input": "2026-05-04T20:25:45.211452Z", + "iopub.status.busy": "2026-05-04T20:25:45.211356Z", + "iopub.status.idle": "2026-05-04T20:25:45.346501Z", + "shell.execute_reply": "2026-05-04T20:25:45.346098Z" + } + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Loaded .env: /Users/jcodella/github/AgentMemoryToolkit/.env\n", + "COSMOS_DB_ENDPOINT host: cosmos-db-demos.documents.azure.com:443\n", + "COSMOS_DB_DATABASE: ai_memory\n", + "COSMOS_DB_CONTAINER: memories\n", + "COSMOS_DB_COUNTERS_CONTAINER: counter\n", + "COSMOS_DB_LEASE_CONTAINER: leases\n", + "COSMOS_DB_THROUGHPUT_MODE: serverless\n", + "COSMOS_DB_AUTOSCALE_MAX_RU: 1000\n", + "AI_FOUNDRY_ENDPOINT host: jacodel-test.openai.azure.com\n", + "AI_FOUNDRY_CHAT_DEPLOYMENT_NAME: gpt-4o-mini\n" + ] + } + ], + "source": [ + "import os, json, sys\n", + "from pathlib import Path\n", + "from urllib.parse import urlparse\n", + "from dotenv import load_dotenv\n", + "from agent_memory_toolkit.aio import AsyncCosmosMemoryClient\n", + "\n", + "# Find the repo root from either the notebook folder or the current kernel cwd.\n", + "candidates = [Path.cwd(), *Path.cwd().parents]\n", + "repo_root = next(path for path in candidates if (path / \"pyproject.toml\").exists())\n", + "sys.path.insert(0, str(repo_root))\n", + "\n", + "# Load environment variables from .env in the repo root.\n", + "env_path = repo_root / \".env\"\n", + "if not env_path.exists():\n", + " raise FileNotFoundError(f\"Missing {env_path}. Copy .env.template to .env and fill in your Azure values.\")\n", + "load_dotenv(env_path, override=True)\n", + "\n", + "def _host(value: str | None) -> str:\n", + " if not value:\n", + " return \"\"\n", + " parsed = urlparse(value)\n", + " return parsed.netloc or value\n", + "\n", + "print(\"Loaded .env:\", env_path)\n", + "print(\"COSMOS_DB_ENDPOINT host:\", _host(os.getenv(\"COSMOS_DB_ENDPOINT\")))\n", + "print(\"COSMOS_DB_DATABASE:\", os.getenv(\"COSMOS_DB_DATABASE\"))\n", + "print(\"COSMOS_DB_CONTAINER:\", os.getenv(\"COSMOS_DB_CONTAINER\"))\n", + "print(\"COSMOS_DB_COUNTERS_CONTAINER:\", os.getenv(\"COSMOS_DB_COUNTERS_CONTAINER\", \"counter\"))\n", + "print(\"COSMOS_DB_LEASE_CONTAINER:\", os.getenv(\"COSMOS_DB_LEASE_CONTAINER\", \"leases\"))\n", + "print(\"COSMOS_DB_THROUGHPUT_MODE:\", os.getenv(\"COSMOS_DB_THROUGHPUT_MODE\", \"serverless\"))\n", + "print(\"COSMOS_DB_AUTOSCALE_MAX_RU:\", os.getenv(\"COSMOS_DB_AUTOSCALE_MAX_RU\", \"1000\"))\n", + "print(\"AI_FOUNDRY_ENDPOINT host:\", _host(os.getenv(\"AI_FOUNDRY_ENDPOINT\")))\n", + "print(\"AI_FOUNDRY_CHAT_DEPLOYMENT_NAME:\", os.getenv(\"AI_FOUNDRY_CHAT_DEPLOYMENT_NAME\", \"gpt-4o-mini\"))" + ] + }, + { + "cell_type": "code", + "execution_count": 21, + "id": "75bf151787e8aaa2", + "metadata": { + "ExecuteTime": { + "end_time": "2026-04-07T22:06:41.229355Z", + "start_time": "2026-04-07T22:06:41.014359Z" + }, + "execution": { + "iopub.execute_input": "2026-05-04T20:25:45.347628Z", + "iopub.status.busy": "2026-05-04T20:25:45.347566Z", + "iopub.status.idle": "2026-05-04T20:25:45.652841Z", + "shell.execute_reply": "2026-05-04T20:25:45.652467Z" + } + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "AsyncCosmosMemoryClient instance created\n", + "Throughput mode: serverless\n", + "AI Foundry host: jacodel-test.openai.azure.com\n", + "Chat deployment: gpt-4o-mini\n", + "Local memory store: []\n" + ] + } + ], + "source": [ + "from azure.identity.aio import DefaultAzureCredential as AsyncDefaultAzureCredential\n", + "\n", + "required_env = [\n", + " \"COSMOS_DB_ENDPOINT\",\n", + " \"COSMOS_DB_DATABASE\",\n", + " \"COSMOS_DB_CONTAINER\",\n", + " \"AI_FOUNDRY_ENDPOINT\",\n", + "]\n", + "missing = [name for name in required_env if not os.getenv(name)]\n", + "if missing:\n", + " raise ValueError(f\"Missing required environment variables: {', '.join(missing)}\")\n", + "\n", + "ai_endpoint_host = urlparse(os.environ[\"AI_FOUNDRY_ENDPOINT\"]).netloc\n", + "if not ai_endpoint_host or \"<\" in ai_endpoint_host or \">\" in ai_endpoint_host:\n", + " raise ValueError(\"AI_FOUNDRY_ENDPOINT must be a real Azure OpenAI endpoint, not the .env.template placeholder.\")\n", + "\n", + "# Credential priority: explicit cosmos_credential > explicit cosmos_key > DefaultAzureCredential.\n", + "# Set COSMOS_DB_KEY in your .env if you don't yet have control-plane RBAC (currently in private preview).\n", + "memory = AsyncCosmosMemoryClient(\n", + " cosmos_endpoint=os.getenv(\"COSMOS_DB_ENDPOINT\"),\n", + " cosmos_database=os.getenv(\"COSMOS_DB_DATABASE\"),\n", + " cosmos_container=os.getenv(\"COSMOS_DB_CONTAINER\"),\n", + " cosmos_counter_container=os.getenv(\"COSMOS_DB_COUNTERS_CONTAINER\", \"counter\"),\n", + " cosmos_lease_container=os.getenv(\"COSMOS_DB_LEASE_CONTAINER\", \"leases\"),\n", + " cosmos_throughput_mode=os.getenv(\"COSMOS_DB_THROUGHPUT_MODE\", \"serverless\"),\n", + " cosmos_autoscale_max_ru=int(os.getenv(\"COSMOS_DB_AUTOSCALE_MAX_RU\", \"1000\")),\n", + " cosmos_key=os.getenv(\"COSMOS_DB_KEY\"),\n", + " ai_foundry_endpoint=os.getenv(\"AI_FOUNDRY_ENDPOINT\"),\n", + " ai_foundry_api_key=os.getenv(\"AI_FOUNDRY_API_KEY\"),\n", + " embedding_deployment_name=os.getenv(\"AI_FOUNDRY_EMBEDDING_DEPLOYMENT_NAME\", \"text-embedding-3-large\"),\n", + " chat_deployment_name=os.getenv(\"AI_FOUNDRY_CHAT_DEPLOYMENT_NAME\", \"gpt-4o-mini\"),\n", + " use_default_credential=True,\n", + ")\n", + "\n", + "print(\"AsyncCosmosMemoryClient instance created\")\n", + "print(\"Throughput mode:\", os.getenv(\"COSMOS_DB_THROUGHPUT_MODE\", \"serverless\"))\n", + "print(\"AI Foundry host:\", ai_endpoint_host)\n", + "print(\"Chat deployment:\", os.getenv(\"AI_FOUNDRY_CHAT_DEPLOYMENT_NAME\", \"gpt-4o-mini\"))\n", + "print(\"Local memory store:\", memory.local_memory)" + ] + }, + { + "cell_type": "markdown", + "id": "3ed9ad79", + "metadata": {}, + "source": [ + "## 2. Local Memory Operations\n", + "\n", + "`AsyncCosmosMemoryClient` mirrors the sync API. Local operations (`add_local`, `get_local`, `update_local`, `delete_local`) are synchronous under the hood (in-memory list), but the class is designed for use in async code paths.\n", + "\n", + "> **Note:** In Jupyter you can `await` directly in cells without wrapping in `asyncio.run()`." + ] + }, + { + "cell_type": "markdown", + "id": "56eadc55", + "metadata": {}, + "source": [ + "### 2a. Add memories with `add_local`" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "id": "5619b2ed", + "metadata": { + "ExecuteTime": { + "end_time": "2026-04-07T22:06:45.409758Z", + "start_time": "2026-04-07T22:06:45.149684Z" + }, + "execution": { + "iopub.execute_input": "2026-05-04T20:25:45.653810Z", + "iopub.status.busy": "2026-05-04T20:25:45.653720Z", + "iopub.status.idle": "2026-05-04T20:25:45.655764Z", + "shell.execute_reply": "2026-05-04T20:25:45.655372Z" + } + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "User ID: user-c1c219f9\n", + "Thread ID: 14987669-804b-4e38-ae6d-9299e76403c0\n", + "\n" + ] + } + ], + "source": [ + "import uuid\n", + "THREAD_ID = str(uuid.uuid4())\n", + "# Use a unique user_id per demo run so we get a clean extraction without\n", + "# inheriting facts from prior runs that would dedup new content away.\n", + "USER_ID = f\"user-{uuid.uuid4().hex[:8]}\"\n", + "print(f\"User ID: {USER_ID}\")\n", + "print(f\"Thread ID: {THREAD_ID}\\n\")\n" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "id": "5ce1b88c", + "metadata": { + "ExecuteTime": { + "end_time": "2026-04-07T22:06:47.709471Z", + "start_time": "2026-04-07T22:06:47.682021Z" + }, + "execution": { + "iopub.execute_input": "2026-05-04T20:25:45.656663Z", + "iopub.status.busy": "2026-05-04T20:25:45.656610Z", + "iopub.status.idle": "2026-05-04T20:25:45.660512Z", + "shell.execute_reply": "2026-05-04T20:25:45.660236Z" + } + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Added 12 memories\n", + "[\n", + " {\n", + " \"id\": \"66f1525d-1728-4822-9456-07a1b45df0e0\",\n", + " \"user_id\": \"user-c1c219f9\",\n", + " \"thread_id\": \"14987669-804b-4e38-ae6d-9299e76403c0\",\n", + " \"role\": \"user\",\n", + " \"type\": \"turn\",\n", + " \"content\": \"What's the weather like in Seattle this weekend?\",\n", + " \"metadata\": {},\n", + " \"created_at\": \"2026-05-19T17:00:22.388274+00:00\",\n", + " \"tags\": [],\n", + " \"ttl\": 2592000\n", + " },\n", + " {\n", + " \"id\": \"cc0ba15b-4228-43c0-b659-a1ca4f9783e0\",\n", + " \"user_id\": \"user-c1c219f9\",\n", + " \"thread_id\": \"14987669-804b-4e38-ae6d-9299e76403c0\",\n", + " \"role\": \"agent\",\n", + " \"type\": \"turn\",\n", + " \"content\": \"This weekend Seattle will be around 55\\u00b0F with partly cloudy skies on Saturday and light rain expected Sunday.\",\n", + " \"metadata\": {},\n", + " \"created_at\": \"2026-05-19T17:00:22.388331+00:00\",\n", + " \"tags\": [],\n", + " \"ttl\": 2592000\n", + " },\n", + " {\n", + " \"id\": \"49aec190-5f31-46b6-b940-f6fa03173b1d\",\n", + " \"user_id\": \"user-c1c219f9\",\n", + " \"thread_id\": \"14987669-804b-4e38-ae6d-9299e76403c0\",\n", + " \"role\": \"user\",\n", + " \"type\": \"turn\",\n", + " \"content\": \"That sounds nice enough. Can you help me book a trip to Seattle for this weekend?\",\n", + " \"metadata\": {},\n", + " \"created_at\": \"2026-05-19T17:00:22.388367+00:00\",\n", + " \"tags\": [],\n", + " \"ttl\": 2592000\n", + " },\n", + " {\n", + " \"id\": \"ea7f6099-f2d8-4624-846a-8c9072718bdb\",\n", + " \"user_id\": \"user-c1c219f9\",\n", + " \"thread_id\": \"14987669-804b-4e38-ae6d-9299e76403c0\",\n", + " \"role\": \"agent\",\n", + " \"type\": \"turn\",\n", + " \"content\": \"Sure! I found round-trip flights departing Friday evening and returning Sunday night. There are also several hotels in downtown Seattle with availability. Would you like me to look at specific airlines or neighborhoods?\",\n", + " \"metadata\": {},\n", + " \"created_at\": \"2026-05-19T17:00:22.388397+00:00\",\n", + " \"tags\": [],\n", + " \"ttl\": 2592000\n", + " },\n", + " {\n", + " \"id\": \"5946bd03-a444-4100-9502-ead01906d4a2\",\n", + " \"user_id\": \"user-c1c219f9\",\n", + " \"thread_id\": \"14987669-804b-4e38-ae6d-9299e76403c0\",\n", + " \"role\": \"user\",\n", + " \"type\": \"turn\",\n", + " \"content\": \"Something near Pike Place Market would be great. And keep the flights under $300 round trip if possible.\",\n", + " \"metadata\": {},\n", + " \"created_at\": \"2026-05-19T17:00:22.388423+00:00\",\n", + " \"tags\": [],\n", + " \"ttl\": 2592000\n", + " },\n", + " {\n", + " \"id\": \"6f1be223-f9b4-4a09-ab59-32e936a8374e\",\n", + " \"user_id\": \"user-c1c219f9\",\n", + " \"thread_id\": \"14987669-804b-4e38-ae6d-9299e76403c0\",\n", + " \"role\": \"agent\",\n", + " \"type\": \"turn\",\n", + " \"content\": \"I found a round-trip on Alaska Airlines for $275 and two hotel options within a 5-minute walk of Pike Place Market: the Inn at the Market ($189/night) and a Hilton Garden Inn ($145/night). Want me to reserve one of these?\",\n", + " \"metadata\": {},\n", + " \"created_at\": \"2026-05-19T17:00:22.388449+00:00\",\n", + " \"tags\": [],\n", + " \"ttl\": 2592000\n", + " },\n", + " {\n", + " \"id\": \"388855db-2392-48b1-abb6-694971686e4d\",\n", + " \"user_id\": \"user-c1c219f9\",\n", + " \"thread_id\": \"14987669-804b-4e38-ae6d-9299e76403c0\",\n", + " \"role\": \"user\",\n", + " \"type\": \"turn\",\n", + " \"content\": \"Whenever you book a flight for me, always book an aisle seat \\u2014 never a window or middle.\",\n", + " \"metadata\": {},\n", + " \"created_at\": \"2026-05-19T17:00:22.388474+00:00\",\n", + " \"tags\": [],\n", + " \"ttl\": 2592000\n", + " },\n", + " {\n", + " \"id\": \"b0ccab7e-acaa-4dce-b192-aea044ebb553\",\n", + " \"user_id\": \"user-c1c219f9\",\n", + " \"thread_id\": \"14987669-804b-4e38-ae6d-9299e76403c0\",\n", + " \"role\": \"agent\",\n", + " \"type\": \"turn\",\n", + " \"content\": \"Got it. I'll always select an aisle seat for your bookings.\",\n", + " \"metadata\": {},\n", + " \"created_at\": \"2026-05-19T17:00:22.388499+00:00\",\n", + " \"tags\": [],\n", + " \"ttl\": 2592000\n", + " },\n", + " {\n", + " \"id\": \"2d4d2743-c938-4e4d-ab58-64466c548a3e\",\n", + " \"user_id\": \"user-c1c219f9\",\n", + " \"thread_id\": \"14987669-804b-4e38-ae6d-9299e76403c0\",\n", + " \"role\": \"user\",\n", + " \"type\": \"turn\",\n", + " \"content\": \"For trip planning, my workflow is: first check the weather for the destination, then check flights, then book the hotel last after everything else is confirmed.\",\n", + " \"metadata\": {},\n", + " \"created_at\": \"2026-05-19T17:00:22.388524+00:00\",\n", + " \"tags\": [],\n", + " \"ttl\": 2592000\n", + " },\n", + " {\n", + " \"id\": \"6ce24c22-2b58-4f04-87f6-6c1ddd5a61da\",\n", + " \"user_id\": \"user-c1c219f9\",\n", + " \"thread_id\": \"14987669-804b-4e38-ae6d-9299e76403c0\",\n", + " \"role\": \"agent\",\n", + " \"type\": \"turn\",\n", + " \"content\": \"Noted \\u2014 I'll follow that order: weather, then flights, then hotel.\",\n", + " \"metadata\": {},\n", + " \"created_at\": \"2026-05-19T17:00:22.388549+00:00\",\n", + " \"tags\": [],\n", + " \"ttl\": 2592000\n", + " },\n", + " {\n", + " \"id\": \"48f0d817-d8d8-4e6d-8d97-b118881506ec\",\n", + " \"user_id\": \"user-c1c219f9\",\n", + " \"thread_id\": \"14987669-804b-4e38-ae6d-9299e76403c0\",\n", + " \"role\": \"user\",\n", + " \"type\": \"turn\",\n", + " \"content\": \"And never book me into anything that departs or arrives between midnight and 6am unless I explicitly approve it.\",\n", + " \"metadata\": {},\n", + " \"created_at\": \"2026-05-19T17:00:22.388573+00:00\",\n", + " \"tags\": [],\n", + " \"ttl\": 2592000\n", + " },\n", + " {\n", + " \"id\": \"d1323f4d-5db3-4f02-b3f8-9ade955b0177\",\n", + " \"user_id\": \"user-c1c219f9\",\n", + " \"thread_id\": \"14987669-804b-4e38-ae6d-9299e76403c0\",\n", + " \"role\": \"agent\",\n", + " \"type\": \"turn\",\n", + " \"content\": \"Will do \\u2014 no overnight bookings without your explicit approval.\",\n", + " \"metadata\": {},\n", + " \"created_at\": \"2026-05-19T17:00:22.388598+00:00\",\n", + " \"tags\": [],\n", + " \"ttl\": 2592000\n", + " }\n", + "]\n", + "Rules thread ID: 42ce68be-b686-4d91-8ea9-8ed5cfe94cf7 (8 turns)\n" + ] + } + ], + "source": [ + "# Add sample conversation: weather in Seattle → booking a trip (6 turns)\n", + "memory.add_local(\n", + " user_id=USER_ID, role=\"user\", thread_id=THREAD_ID,\n", + " content=\"What's the weather like in Seattle this weekend?\",\n", + ")\n", + "memory.add_local(\n", + " user_id=USER_ID, role=\"agent\", thread_id=THREAD_ID,\n", + " content=\"This weekend Seattle will be around 55°F with partly cloudy skies on Saturday and light rain expected Sunday.\",\n", + ")\n", + "memory.add_local(\n", + " user_id=USER_ID, role=\"user\", thread_id=THREAD_ID,\n", + " content=\"That sounds nice enough. Can you help me book a trip to Seattle for this weekend?\",\n", + ")\n", + "memory.add_local(\n", + " user_id=USER_ID, role=\"agent\", thread_id=THREAD_ID,\n", + " content=\"Sure! I found round-trip flights departing Friday evening and returning Sunday night. There are also several hotels in downtown Seattle with availability. Would you like me to look at specific airlines or neighborhoods?\",\n", + ")\n", + "memory.add_local(\n", + " user_id=USER_ID, role=\"user\", thread_id=THREAD_ID,\n", + " content=\"Something near Pike Place Market would be great. And keep the flights under $300 round trip if possible.\",\n", + ")\n", + "memory.add_local(\n", + " user_id=USER_ID, role=\"agent\", thread_id=THREAD_ID,\n", + " content=\"I found a round-trip on Alaska Airlines for $275 and two hotel options within a 5-minute walk of Pike Place Market: the Inn at the Market ($189/night) and a Hilton Garden Inn ($145/night). Want me to reserve one of these?\",\n", + ")\n", + "\n", + "memory.add_local(\n", + " user_id=USER_ID, role=\"user\", thread_id=THREAD_ID,\n", + " content=\"Whenever you book a flight for me, always book an aisle seat — never a window or middle.\",\n", + ")\n", + "memory.add_local(\n", + " user_id=USER_ID, role=\"agent\", thread_id=THREAD_ID,\n", + " content=\"Got it. I'll always select an aisle seat for your bookings.\",\n", + ")\n", + "memory.add_local(\n", + " user_id=USER_ID, role=\"user\", thread_id=THREAD_ID,\n", + " content=\"For trip planning, my workflow is: first check the weather for the destination, then check flights, then book the hotel last after everything else is confirmed.\",\n", + ")\n", + "memory.add_local(\n", + " user_id=USER_ID, role=\"agent\", thread_id=THREAD_ID,\n", + " content=\"Noted — I'll follow that order: weather, then flights, then hotel.\",\n", + ")\n", + "memory.add_local(\n", + " user_id=USER_ID, role=\"user\", thread_id=THREAD_ID,\n", + " content=\"And never book me into anything that departs or arrives between midnight and 6am unless I explicitly approve it.\",\n", + ")\n", + "memory.add_local(\n", + " user_id=USER_ID, role=\"agent\", thread_id=THREAD_ID,\n", + " content=\"Will do — no overnight bookings without your explicit approval.\",\n", + ")\n", + "\n", + "print(f\"Added {len(memory.local_memory)} memories\")\n", + "print(json.dumps(memory.get_local(), indent=2))\n", + "\n", + "# A second short thread of pure procedural-style instructions. Demonstrates\n", + "# that the extractor produces clean procedural items when the conversation is\n", + "# focused on rules/workflows rather than mixed with factual booking specifics.\n", + "RULES_THREAD_ID = str(uuid.uuid4())\n", + "for role, content in [\n", + " (\"user\", \"Whenever you book a flight for me, always book an aisle seat — never a window or middle.\"),\n", + " (\"agent\", \"Got it. I'll always select an aisle seat for your bookings.\"),\n", + " (\"user\", \"For trip planning, my workflow is: first check the weather, then check flights, and book the hotel last after everything else is confirmed.\"),\n", + " (\"agent\", \"Noted — I'll follow that order: weather, then flights, then hotel.\"),\n", + " (\"user\", \"Never book me into anything that departs or arrives between midnight and 6am unless I explicitly approve it.\"),\n", + " (\"agent\", \"Will do — no overnight bookings without your explicit approval.\"),\n", + " (\"user\", \"When picking a hotel, only recommend ones that include complimentary breakfast.\"),\n", + " (\"agent\", \"Understood — only hotels with complimentary breakfast.\"),\n", + "]:\n", + " memory.add_local(user_id=USER_ID, role=role, thread_id=RULES_THREAD_ID, content=content)\n", + "\n", + "print(f\"Rules thread ID: {RULES_THREAD_ID} ({sum(1 for m in memory.local_memory if m['thread_id']==RULES_THREAD_ID)} turns)\")\n" + ] + }, + { + "cell_type": "markdown", + "id": "9a0aac22", + "metadata": {}, + "source": [ + "### 2b. Query memories with `get_local`" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "id": "942e3714", + "metadata": { + "ExecuteTime": { + "end_time": "2026-04-07T22:06:50.682868Z", + "start_time": "2026-04-07T22:06:50.661470Z" + }, + "execution": { + "iopub.execute_input": "2026-05-04T20:25:45.661416Z", + "iopub.status.busy": "2026-05-04T20:25:45.661371Z", + "iopub.status.idle": "2026-05-04T20:25:45.663639Z", + "shell.execute_reply": "2026-05-04T20:25:45.663296Z" + } + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Total memories: 20\n", + "\n", + "Memories for user-001: 20\n", + "Tool memories: 10\n", + " [cc0ba15b...] This weekend Seattle will be around 55°F with partly cloudy \n", + " [ea7f6099...] Sure! I found round-trip flights departing Friday evening an\n", + " [6f1be223...] I found a round-trip on Alaska Airlines for $275 and two hot\n", + " [b0ccab7e...] Got it. I'll always select an aisle seat for your bookings.\n", + " [6ce24c22...] Noted — I'll follow that order: weather, then flights, then \n", + " [d1323f4d...] Will do — no overnight bookings without your explicit approv\n", + " [9b9cb3d0...] Got it. I'll always select an aisle seat for your bookings.\n", + " [b2d86bf3...] Noted — I'll follow that order: weather, then flights, then \n", + " [e0918ccb...] Will do — no overnight bookings without your explicit approv\n", + " [8d121233...] Understood — only hotels with complimentary breakfast.\n", + "\n", + "Fact memories: 0\n", + "\n", + "Agent memories for user-001: 10\n" + ] + } + ], + "source": [ + "# Get all memories\n", + "all_memories = memory.get_local()\n", + "print(f\"Total memories: {len(all_memories)}\\n\")\n", + "\n", + "# Filter by user_id\n", + "user1_memories = memory.get_local(user_id=USER_ID)\n", + "print(f\"Memories for user-001: {len(user1_memories)}\")\n", + "\n", + "# Filter by role\n", + "tool_memories = memory.get_local(role=\"agent\")\n", + "print(f\"Tool memories: {len(tool_memories)}\")\n", + "for m in tool_memories:\n", + " print(f\" [{m['id'][:8]}...] {m['content'][:60]}\")\n", + "\n", + "# Filter by type\n", + "facts = memory.get_local(memory_types=[\"fact\"])\n", + "print(f\"\\nFact memories: {len(facts)}\")\n", + "for m in facts:\n", + " print(f\" [{m['id'][:8]}...] {m['content']}\")\n", + "\n", + "# Combine filters: user-001 + agent role\n", + "user1_agent = memory.get_local(user_id=USER_ID, role=\"agent\")\n", + "print(f\"\\nAgent memories for user-001: {len(user1_agent)}\")" + ] + }, + { + "cell_type": "markdown", + "id": "ba973a1c", + "metadata": {}, + "source": [ + "### 2c. Update & Delete with `update_local` / `delete_local`" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "id": "4ca36086", + "metadata": { + "ExecuteTime": { + "end_time": "2026-04-07T22:06:53.605394Z", + "start_time": "2026-04-07T22:06:53.576655Z" + }, + "execution": { + "iopub.execute_input": "2026-05-04T20:25:45.664504Z", + "iopub.status.busy": "2026-05-04T20:25:45.664457Z", + "iopub.status.idle": "2026-05-04T20:25:45.666846Z", + "shell.execute_reply": "2026-05-04T20:25:45.666497Z" + } + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Before update:\n", + "{\n", + " \"id\": \"5946bd03-a444-4100-9502-ead01906d4a2\",\n", + " \"user_id\": \"user-c1c219f9\",\n", + " \"thread_id\": \"14987669-804b-4e38-ae6d-9299e76403c0\",\n", + " \"role\": \"user\",\n", + " \"type\": \"turn\",\n", + " \"content\": \"Something near Pike Place Market would be great. And keep the flights under $300 round trip if possible.\",\n", + " \"metadata\": {},\n", + " \"created_at\": \"2026-05-19T17:00:22.388423+00:00\",\n", + " \"tags\": [],\n", + " \"ttl\": 2592000\n", + "}\n", + "\n", + "After update:\n", + "{\n", + " \"id\": \"5946bd03-a444-4100-9502-ead01906d4a2\",\n", + " \"user_id\": \"user-c1c219f9\",\n", + " \"thread_id\": \"14987669-804b-4e38-ae6d-9299e76403c0\",\n", + " \"role\": \"user\",\n", + " \"type\": \"turn\",\n", + " \"content\": \"Something near Pike Place Market would be great. Keep flights under $300 round trip and hotels under $200/night.\",\n", + " \"metadata\": {\n", + " \"edited\": true,\n", + " \"reason\": \"user clarified hotel budget\"\n", + " },\n", + " \"created_at\": \"2026-05-19T17:00:22.388423+00:00\",\n", + " \"tags\": [],\n", + " \"ttl\": 2592000,\n", + " \"updated_at\": \"2026-05-19T17:00:23.483773+00:00\"\n", + "}\n", + "\n", + "Deleting memory 49aec190...\n", + "\n", + "Remaining memories: 19\n", + " [14987669...] [66f1525d...] role=user type=turn What's the weather like in Seattle this weekend?\n", + " [14987669...] [cc0ba15b...] role=agent type=turn This weekend Seattle will be around 55°F with part\n", + " [14987669...] [ea7f6099...] role=agent type=turn Sure! I found round-trip flights departing Friday \n", + " [14987669...] [5946bd03...] role=user type=turn Something near Pike Place Market would be great. K\n", + " [14987669...] [6f1be223...] role=agent type=turn I found a round-trip on Alaska Airlines for $275 a\n", + " [14987669...] [388855db...] role=user type=turn Whenever you book a flight for me, always book an \n", + " [14987669...] [b0ccab7e...] role=agent type=turn Got it. I'll always select an aisle seat for your \n", + " [14987669...] [2d4d2743...] role=user type=turn For trip planning, my workflow is: first check the\n", + " [14987669...] [6ce24c22...] role=agent type=turn Noted — I'll follow that order: weather, then flig\n", + " [14987669...] [48f0d817...] role=user type=turn And never book me into anything that departs or ar\n", + " [14987669...] [d1323f4d...] role=agent type=turn Will do — no overnight bookings without your expli\n", + " [42ce68be...] [4f2f0cbd...] role=user type=turn Whenever you book a flight for me, always book an \n", + " [42ce68be...] [9b9cb3d0...] role=agent type=turn Got it. I'll always select an aisle seat for your \n", + " [42ce68be...] [7f44886a...] role=user type=turn For trip planning, my workflow is: first check the\n", + " [42ce68be...] [b2d86bf3...] role=agent type=turn Noted — I'll follow that order: weather, then flig\n", + " [42ce68be...] [26e0ef8e...] role=user type=turn Never book me into anything that departs or arrive\n", + " [42ce68be...] [e0918ccb...] role=agent type=turn Will do — no overnight bookings without your expli\n", + " [42ce68be...] [efa017f2...] role=user type=turn When picking a hotel, only recommend ones that inc\n", + " [42ce68be...] [8d121233...] role=agent type=turn Understood — only hotels with complimentary breakf\n" + ] + } + ], + "source": [ + "# Update the user's budget constraint to be more specific\n", + "target_id = memory.local_memory[4][\"id\"] # \"Something near Pike Place Market...\"\n", + "print(f\"Before update:\\n{json.dumps(memory.get_local(memory_id=target_id)[0], indent=2)}\\n\")\n", + "\n", + "memory.update_local(\n", + " memory_id=target_id,\n", + " content=\"Something near Pike Place Market would be great. Keep flights under $300 round trip and hotels under $200/night.\",\n", + " metadata={\"edited\": True, \"reason\": \"user clarified hotel budget\"},\n", + ")\n", + "print(f\"After update:\\n{json.dumps(memory.get_local(memory_id=target_id)[0], indent=2)}\")\n", + "\n", + "# Delete the third memory (index 2 — the user's booking request)\n", + "del_target_id = memory.local_memory[2][\"id\"]\n", + "print(f\"\\nDeleting memory {del_target_id[:8]}...\")\n", + "memory.delete_local(del_target_id)\n", + "\n", + "# Verify it's gone\n", + "print(f\"\\nRemaining memories: {len(memory.get_local())}\")\n", + "for m in memory.get_local():\n", + " print(f\" [{m['thread_id'][:8]}...] [{m['id'][:8]}...] role={m['role']:<6} type={m['type']:<8} {m['content'][:50]}\")" + ] + }, + { + "cell_type": "markdown", + "id": "bad8c2b6", + "metadata": {}, + "source": [ + "## 3. Cosmos DB Operations\n", + "\n", + "### 3a. Connect and create the memory store\n", + "\n", + "The async client auto-connects on the first Cosmos DB operation. Call `create_memory_store()` to create the database and container if they do not already exist, including the hierarchical partition key, vector index, and full-text index.\n", + "\n", + "> **Note:** `create_memory_store()` is safe to run more than once." + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "id": "82b363d7", + "metadata": { + "ExecuteTime": { + "end_time": "2026-04-07T22:06:58.478498Z", + "start_time": "2026-04-07T22:06:57.474753Z" + }, + "execution": { + "iopub.execute_input": "2026-05-04T20:25:45.667704Z", + "iopub.status.busy": "2026-05-04T20:25:45.667661Z", + "iopub.status.idle": "2026-05-04T20:25:46.372667Z", + "shell.execute_reply": "2026-05-04T20:25:46.371834Z" + } + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Connected: True\n" + ] + } + ], + "source": [ + "# The async client auto-creates the database and container on the first Cosmos operation.\n", + "# You can also call create_memory_store() explicitly if needed.\n", + "await memory.create_memory_store()\n", + "print(f\"Connected: {memory._container_client is not None}\")" + ] + }, + { + "cell_type": "markdown", + "id": "5c18edf3", + "metadata": {}, + "source": [ + "### 3b. Add memories to Cosmos DB with `add_cosmos`" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "id": "b7d0939d", + "metadata": { + "execution": { + "iopub.execute_input": "2026-05-04T20:25:46.375244Z", + "iopub.status.busy": "2026-05-04T20:25:46.375091Z", + "iopub.status.idle": "2026-05-04T20:25:46.627003Z", + "shell.execute_reply": "2026-05-04T20:25:46.626193Z" + } + }, + "outputs": [], + "source": [ + "await memory.connect_cosmos()" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "id": "e0b3b5fc", + "metadata": { + "ExecuteTime": { + "end_time": "2026-04-07T22:07:08.081103Z", + "start_time": "2026-04-07T22:07:07.860764Z" + }, + "execution": { + "iopub.execute_input": "2026-05-04T20:25:46.629264Z", + "iopub.status.busy": "2026-05-04T20:25:46.629134Z", + "iopub.status.idle": "2026-05-04T20:25:47.111769Z", + "shell.execute_reply": "2026-05-04T20:25:47.111092Z" + } + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "New Thread ID: 410b280c-357e-47dc-8fc7-16e989e0a578\n", + "\n", + "Local memory count (should be unchanged): 19\n", + "\n", + "Memories in Cosmos DB for new thread: 5\n", + " [410b280c...] [e37d898c...] role=user Can you recommend some good restaurants in New York City?\n", + " [410b280c...] [f8b56fb3...] role=tool {\"query\": \"top restaurants NYC\", \"results\": [\"Carbone\", \"Nob\n", + " [410b280c...] [51fcd56a...] role=agent Absolutely! NYC has incredible dining options. For Italian, \n", + " [410b280c...] [5f602bb0...] role=user I love Italian food. Are there any options that are budget-f\n", + " [410b280c...] [67a14f36...] role=agent For budget-friendly Italian in NYC, check out L'industrie Pi\n" + ] + } + ], + "source": [ + "await memory.push_to_cosmos()\n", + "\n", + "# Push a new thread directly to Cosmos DB without adding to local memory first\n", + "new_thread_id = str(uuid.uuid4())\n", + "print(f\"New Thread ID: {new_thread_id}\\n\")\n", + "\n", + "# Add memories directly to Cosmos DB using add_cosmos\n", + "await memory.add_cosmos(\n", + " user_id=\"user-002\", role=\"user\", thread_id=new_thread_id,\n", + " content=\"Can you recommend some good restaurants in New York City?\",\n", + ")\n", + "await memory.add_cosmos(\n", + " user_id=\"user-002\", role=\"tool\", thread_id=new_thread_id,\n", + " content='{\"query\": \"top restaurants NYC\", \"results\": [\"Carbone\", \"Nobu\", \"Katz\\'s Deli\", \"Le Bernardin\"]}',\n", + " metadata={\"tool_name\": \"restaurant_search\", \"tool_call_id\": \"call_abc123\"},\n", + ")\n", + "await memory.add_cosmos(\n", + " user_id=\"user-002\", role=\"agent\", thread_id=new_thread_id,\n", + " content=\"Absolutely! NYC has incredible dining options. For Italian, try Carbone in Greenwich Village. For sushi, Nobu in Tribeca is world-class. For a classic NYC experience, Katz's Delicatessen on the Lower East Side is a must.\",\n", + ")\n", + "await memory.add_cosmos(\n", + " user_id=\"user-002\", role=\"user\", thread_id=new_thread_id,\n", + " content=\"I love Italian food. Are there any options that are budget-friendly?\",\n", + ")\n", + "await memory.add_cosmos(\n", + " user_id=\"user-002\", role=\"agent\", thread_id=new_thread_id,\n", + " content=\"For budget-friendly Italian in NYC, check out L'industrie Pizzeria in Williamsburg or Artichoke Basille's Pizza. Both are highly rated and won't break the bank.\",\n", + ")\n", + "\n", + "# Verify the memories were added directly to Cosmos DB (not in local memory)\n", + "print(f\"Local memory count (should be unchanged): {len(memory.local_memory)}\\n\")\n", + "\n", + "cosmos_results = await memory.get_memories(user_id=\"user-002\", thread_id=new_thread_id)\n", + "print(f\"Memories in Cosmos DB for new thread: {len(cosmos_results)}\")\n", + "for r in cosmos_results:\n", + " print(f\" [{r['thread_id'][:8]}...] [{r['id'][:8]}...] role={r['role']:<6} {r['content'][:60]}\")" + ] + }, + { + "cell_type": "markdown", + "id": "b04679dd", + "metadata": {}, + "source": [ + "### 3c. Retrieve memories from Cosmos DB with `get_memories`\n", + "\n", + "Supports the same filters as `get_local`: `memory_id`, `user_id`, `role`, `memory_type`." + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "id": "a13b2301", + "metadata": { + "ExecuteTime": { + "end_time": "2026-04-07T22:07:11.561128Z", + "start_time": "2026-04-07T22:07:11.474440Z" + }, + "execution": { + "iopub.execute_input": "2026-05-04T20:25:47.113447Z", + "iopub.status.busy": "2026-05-04T20:25:47.113322Z", + "iopub.status.idle": "2026-05-04T20:25:47.262048Z", + "shell.execute_reply": "2026-05-04T20:25:47.260997Z" + } + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Memories for user-001: 19\n", + "\n", + " [42ce68be...] [e0918ccb...] role=agent type=turn Will do — no overnight bookings without your expli\n", + " [14987669...] [ea7f6099...] role=agent type=turn Sure! I found round-trip flights departing Friday \n", + " [42ce68be...] [b2d86bf3...] role=agent type=turn Noted — I'll follow that order: weather, then flig\n", + " [14987669...] [5946bd03...] role=user type=turn Something near Pike Place Market would be great. K\n", + " [14987669...] [66f1525d...] role=user type=turn What's the weather like in Seattle this weekend?\n", + " [42ce68be...] [7f44886a...] role=user type=turn For trip planning, my workflow is: first check the\n", + " [42ce68be...] [efa017f2...] role=user type=turn When picking a hotel, only recommend ones that inc\n", + " [14987669...] [2d4d2743...] role=user type=turn For trip planning, my workflow is: first check the\n", + " [14987669...] [cc0ba15b...] role=agent type=turn This weekend Seattle will be around 55°F with part\n", + " [42ce68be...] [8d121233...] role=agent type=turn Understood — only hotels with complimentary breakf\n", + " [14987669...] [b0ccab7e...] role=agent type=turn Got it. I'll always select an aisle seat for your \n", + " [14987669...] [388855db...] role=user type=turn Whenever you book a flight for me, always book an \n", + " [14987669...] [48f0d817...] role=user type=turn And never book me into anything that departs or ar\n", + " [14987669...] [6f1be223...] role=agent type=turn I found a round-trip on Alaska Airlines for $275 a\n", + " [14987669...] [6ce24c22...] role=agent type=turn Noted — I'll follow that order: weather, then flig\n", + " [42ce68be...] [4f2f0cbd...] role=user type=turn Whenever you book a flight for me, always book an \n", + " [42ce68be...] [26e0ef8e...] role=user type=turn Never book me into anything that departs or arrive\n", + " [14987669...] [d1323f4d...] role=agent type=turn Will do — no overnight bookings without your expli\n", + " [42ce68be...] [9b9cb3d0...] role=agent type=turn Got it. I'll always select an aisle seat for your \n", + "\n", + "Agent memories: 12\n", + " [42ce68be...] [e0918ccb...] role=agent type=turn Will do — no overnight bookings without your expli\n", + " [14987669...] [ea7f6099...] role=agent type=turn Sure! I found round-trip flights departing Friday \n", + " [42ce68be...] [b2d86bf3...] role=agent type=turn Noted — I'll follow that order: weather, then flig\n", + " [14987669...] [cc0ba15b...] role=agent type=turn This weekend Seattle will be around 55°F with part\n", + " [42ce68be...] [8d121233...] role=agent type=turn Understood — only hotels with complimentary breakf\n", + " [14987669...] [b0ccab7e...] role=agent type=turn Got it. I'll always select an aisle seat for your \n", + " [14987669...] [6f1be223...] role=agent type=turn I found a round-trip on Alaska Airlines for $275 a\n", + " [14987669...] [6ce24c22...] role=agent type=turn Noted — I'll follow that order: weather, then flig\n", + " [14987669...] [d1323f4d...] role=agent type=turn Will do — no overnight bookings without your expli\n", + " [42ce68be...] [9b9cb3d0...] role=agent type=turn Got it. I'll always select an aisle seat for your \n", + " [410b280c...] [51fcd56a...] role=agent type=turn Absolutely! NYC has incredible dining options. For\n", + " [410b280c...] [67a14f36...] role=agent type=turn For budget-friendly Italian in NYC, check out L'in\n" + ] + } + ], + "source": [ + "# Get all memories for user-001\n", + "results = await memory.get_memories(user_id=USER_ID)\n", + "print(f\"Memories for user-001: {len(results)}\\n\")\n", + "for r in results:\n", + " print(f\" [{r['thread_id'][:8]}...] [{r['id'][:8]}...] role={r['role']:<6} type={r['type']:<8} {r['content'][:50]}\")\n", + "\n", + "# Get only agent memories\n", + "agent_results = await memory.get_memories(role=\"agent\")\n", + "print(f\"\\nAgent memories: {len(agent_results)}\")\n", + "for r in agent_results:\n", + " print(f\" [{r['thread_id'][:8]}...] [{r['id'][:8]}...] role={r['role']:<6} type={r['type']:<8} {r['content'][:50]}\")" + ] + }, + { + "cell_type": "markdown", + "id": "7e98a7c2", + "metadata": {}, + "source": [ + "### 3d. Update & Delete in Cosmos DB\n", + "\n", + "If the content changes, the embedding is automatically re-generated (awaited)." + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "id": "b0b61df9", + "metadata": { + "ExecuteTime": { + "end_time": "2026-04-07T22:07:16.784062Z", + "start_time": "2026-04-07T22:07:16.651689Z" + }, + "execution": { + "iopub.execute_input": "2026-05-04T20:25:47.264618Z", + "iopub.status.busy": "2026-05-04T20:25:47.264449Z", + "iopub.status.idle": "2026-05-04T20:25:47.395572Z", + "shell.execute_reply": "2026-05-04T20:25:47.394909Z" + } + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Before: Something near Pike Place Market would be great. Keep flights under $300 round trip and hotels under $200/night.\n", + "\n", + "After: Something near Pike Place Market would be great. Keep flights under $300 round trip and hotels under $200/night.\n" + ] + } + ], + "source": [ + "# Update the user's budget message to add a hotel budget constraint\n", + "user_msgs = await memory.get_memories(user_id=USER_ID, role=\"user\")\n", + "target = [m for m in user_msgs if \"Pike Place\" in m[\"content\"]][0]\n", + "print(f\"Before: {target['content']}\\n\")\n", + "\n", + "await memory.update_cosmos(\n", + " memory_id=target[\"id\"],\n", + " content=\"Something near Pike Place Market would be great. Keep flights under $300 round trip and hotels under $200/night.\",\n", + " metadata={\"edited\": True, \"reason\": \"user clarified hotel budget\"},\n", + ")\n", + "\n", + "updated = (await memory.get_memories(memory_id=target[\"id\"]))[0]\n", + "print(f\"After: {updated['content']}\")" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "id": "74874763", + "metadata": { + "ExecuteTime": { + "end_time": "2026-04-07T22:07:36.933417Z", + "start_time": "2026-04-07T22:07:36.641107Z" + }, + "execution": { + "iopub.execute_input": "2026-05-04T20:25:47.397837Z", + "iopub.status.busy": "2026-05-04T20:25:47.397690Z", + "iopub.status.idle": "2026-05-04T20:25:50.012907Z", + "shell.execute_reply": "2026-05-04T20:25:50.012517Z" + } + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'id': 'f8b56fb3-1a7b-43d6-8d7c-ba4aa013b9ef', 'user_id': 'user-002', 'thread_id': '410b280c-357e-47dc-8fc7-16e989e0a578', 'role': 'tool', 'type': 'turn', 'content': '{\"query\": \"top restaurants NYC\", \"results\": [\"Carbone\", \"Nobu\", \"Katz\\'s Deli\", \"Le Bernardin\"]}', 'metadata': {'tool_name': 'restaurant_search', 'tool_call_id': 'call_abc123'}, 'created_at': '2026-05-19T17:00:38.117248+00:00', 'tags': [], '_rid': 'T4ViAOVcpApKAAAAAAAAAA==', '_self': 'dbs/T4ViAA==/colls/T4ViAOVcpAo=/docs/T4ViAOVcpApKAAAAAAAAAA==/', '_etag': '\"0500678e-0000-0800-0000-6a0c97360000\"', '_attachments': 'attachments/', '_ts': 1779210038}\n", + "Deleted tool memory f8b56fb3...\n", + "\n", + "Remaining memories in Cosmos DB: 23\n", + " [42ce68be...] [e0918ccb...] role=agent type=turn Will do — no overnight bookings without your expli\n", + " [14987669...] [ea7f6099...] role=agent type=turn Sure! I found round-trip flights departing Friday \n", + " [42ce68be...] [b2d86bf3...] role=agent type=turn Noted — I'll follow that order: weather, then flig\n", + " [14987669...] [5946bd03...] role=user type=turn Something near Pike Place Market would be great. K\n", + " [14987669...] [66f1525d...] role=user type=turn What's the weather like in Seattle this weekend?\n", + " [42ce68be...] [7f44886a...] role=user type=turn For trip planning, my workflow is: first check the\n", + " [42ce68be...] [efa017f2...] role=user type=turn When picking a hotel, only recommend ones that inc\n", + " [14987669...] [2d4d2743...] role=user type=turn For trip planning, my workflow is: first check the\n", + " [14987669...] [cc0ba15b...] role=agent type=turn This weekend Seattle will be around 55°F with part\n", + " [42ce68be...] [8d121233...] role=agent type=turn Understood — only hotels with complimentary breakf\n", + " [14987669...] [b0ccab7e...] role=agent type=turn Got it. I'll always select an aisle seat for your \n", + " [14987669...] [388855db...] role=user type=turn Whenever you book a flight for me, always book an \n", + " [14987669...] [48f0d817...] role=user type=turn And never book me into anything that departs or ar\n", + " [14987669...] [6f1be223...] role=agent type=turn I found a round-trip on Alaska Airlines for $275 a\n", + " [14987669...] [6ce24c22...] role=agent type=turn Noted — I'll follow that order: weather, then flig\n", + " [42ce68be...] [4f2f0cbd...] role=user type=turn Whenever you book a flight for me, always book an \n", + " [42ce68be...] [26e0ef8e...] role=user type=turn Never book me into anything that departs or arrive\n", + " [14987669...] [d1323f4d...] role=agent type=turn Will do — no overnight bookings without your expli\n", + " [42ce68be...] [9b9cb3d0...] role=agent type=turn Got it. I'll always select an aisle seat for your \n", + " [410b280c...] [e37d898c...] role=user type=turn Can you recommend some good restaurants in New Yor\n", + " [410b280c...] [51fcd56a...] role=agent type=turn Absolutely! NYC has incredible dining options. For\n", + " [410b280c...] [5f602bb0...] role=user type=turn I love Italian food. Are there any options that ar\n", + " [410b280c...] [67a14f36...] role=agent type=turn For budget-friendly Italian in NYC, check out L'in\n" + ] + } + ], + "source": [ + "# Delete the tool memory from Cosmos (async)\n", + "tool_mems = await memory.get_memories(user_id=\"user-002\", role=\"tool\")\n", + "print(tool_mems[0])\n", + "if tool_mems:\n", + " await memory.delete_cosmos(\n", + " tool_mems[0][\"id\"],\n", + " thread_id=tool_mems[0][\"thread_id\"],\n", + " user_id=tool_mems[0][\"user_id\"],\n", + " )\n", + " print(f\"Deleted tool memory {tool_mems[0]['id'][:8]}...\")\n", + "\n", + "# Verify\n", + "remaining = await memory.get_memories()\n", + "print(f\"\\nRemaining memories in Cosmos DB: {len(remaining)}\")\n", + "for r in remaining:\n", + " print(f\" [{r['thread_id'][:8]}...] [{r['id'][:8]}...] role={r['role']:<6} type={r['type']:<8} {r['content'][:50]}\")" + ] + }, + { + "cell_type": "markdown", + "id": "007708d5", + "metadata": {}, + "source": [ + "### 3e. Retrieve a full thread with `get_thread`\n", + "\n", + "Same parameters: `thread_id` (required), `user_id` (optional), `recent_k` (optional)." + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "id": "3ed613d3", + "metadata": { + "ExecuteTime": { + "end_time": "2026-04-07T22:07:40.340577Z", + "start_time": "2026-04-07T22:07:40.138825Z" + }, + "execution": { + "iopub.execute_input": "2026-05-04T20:25:50.014174Z", + "iopub.status.busy": "2026-05-04T20:25:50.014096Z", + "iopub.status.idle": "2026-05-04T20:25:50.246063Z", + "shell.execute_reply": "2026-05-04T20:25:50.245174Z" + } + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Using thread_id: 14987669-804b-4e38-ae6d-9299e76403c0\n", + "\n", + "All memories in thread: 11\n", + " [14987669...] [66f1525d...] role=user type=turn What's the weather like in Seattle this weekend?\n", + " [14987669...] [cc0ba15b...] role=agent type=turn This weekend Seattle will be around 55°F with partly cloudy \n", + " [14987669...] [ea7f6099...] role=agent type=turn Sure! I found round-trip flights departing Friday evening an\n", + " [14987669...] [5946bd03...] role=user type=turn Something near Pike Place Market would be great. Keep flight\n", + " [14987669...] [6f1be223...] role=agent type=turn I found a round-trip on Alaska Airlines for $275 and two hot\n", + " [14987669...] [388855db...] role=user type=turn Whenever you book a flight for me, always book an aisle seat\n", + " [14987669...] [b0ccab7e...] role=agent type=turn Got it. I'll always select an aisle seat for your bookings.\n", + " [14987669...] [2d4d2743...] role=user type=turn For trip planning, my workflow is: first check the weather f\n", + " [14987669...] [6ce24c22...] role=agent type=turn Noted — I'll follow that order: weather, then flights, then \n", + " [14987669...] [48f0d817...] role=user type=turn And never book me into anything that departs or arrives betw\n", + " [14987669...] [d1323f4d...] role=agent type=turn Will do — no overnight bookings without your explicit approv\n", + "\n", + "Most recent 2 memories:\n", + " [14987669...] [48f0d817...] role=user type=turn And never book me into anything that departs or arrives betw\n", + " [14987669...] [d1323f4d...] role=agent type=turn Will do — no overnight bookings without your explicit approv\n", + "\n", + "Thread memories for user-c1c219f9: 11\n" + ] + } + ], + "source": [ + "# Use the CURRENT seed thread (from cell 5) so we operate on the data we just wrote.\n", + "thread_id = THREAD_ID\n", + "print(f\"Using thread_id: {thread_id}\\n\")\n", + "\n", + "# Get all documents in the thread\n", + "thread_all = await memory.get_thread(thread_id=thread_id)\n", + "print(f\"All memories in thread: {len(thread_all)}\")\n", + "for m in thread_all:\n", + " print(f\" [{m['thread_id'][:8]}...] [{m['id'][:8]}...] role={m.get('role','?'):6} type={m['type']:8} {m['content'][:60]}\")\n", + "\n", + "recent = await memory.get_thread(thread_id=thread_id, recent_k=2)\n", + "print(f\"\\nMost recent 2 memories:\")\n", + "for m in recent:\n", + " print(f\" [{m['thread_id'][:8]}...] [{m['id'][:8]}...] role={m.get('role','?'):6} type={m['type']:8} {m['content'][:60]}\")\n", + "\n", + "thread_user = await memory.get_thread(thread_id=thread_id, user_id=USER_ID)\n", + "print(f\"\\nThread memories for {USER_ID}: {len(thread_user)}\")\n" + ] + }, + { + "cell_type": "markdown", + "id": "06a9f99d", + "metadata": {}, + "source": [ + "## 4. Thread Summary (in-process)\n", + "\n", + "`AsyncCosmosMemoryClient.generate_thread_summary()` runs the summarisation pipeline **in-process** — no Azure Functions required. The async client uses the AI Foundry async openai client and the async Cosmos SDK, so calls don't block the event loop.\n", + "\n", + "If a prior summary exists, the call performs an **incremental update** that preserves the metadata-tracked `source_count`.\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "637f49de", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Summarizing thread_id=14987669-804b-4e38-ae6d-9299e76403c0 user_id=user-c1c219f9\n", + "\n" + ] + }, + { + "ename": "CosmosNotConnectedError", + "evalue": "Cosmos DB is not connected. Call connect_cosmos() first.", + "output_type": "error", + "traceback": [ + "\u001b[31m---------------------------------------------------------------------------\u001b[39m", + "\u001b[31mCosmosNotConnectedError\u001b[39m Traceback (most recent call last)", + "\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[22]\u001b[39m\u001b[32m, line 5\u001b[39m\n\u001b[32m 2\u001b[39m user_id = USER_ID\n\u001b[32m 3\u001b[39m \u001b[38;5;28mprint\u001b[39m(\u001b[33mf\u001b[39m\u001b[33m\"\u001b[39m\u001b[33mSummarizing thread_id=\u001b[39m\u001b[38;5;132;01m{\u001b[39;00mthread_id\u001b[38;5;132;01m}\u001b[39;00m\u001b[33m user_id=\u001b[39m\u001b[38;5;132;01m{\u001b[39;00muser_id\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;130;01m\\n\u001b[39;00m\u001b[33m\"\u001b[39m)\n\u001b[32m----> \u001b[39m\u001b[32m5\u001b[39m summary_doc = \u001b[38;5;28;01mawait\u001b[39;00m memory.generate_thread_summary(user_id=user_id, thread_id=thread_id)\n", + "\u001b[36mFile \u001b[39m\u001b[32m~/github/AgentMemoryToolkit/agent_memory_toolkit/aio/cosmos_memory_client.py:1705\u001b[39m, in \u001b[36mAsyncCosmosMemoryClient.generate_thread_summary\u001b[39m\u001b[34m(self, user_id, thread_id, recent_k, **kwargs)\u001b[39m\n\u001b[32m 1693\u001b[39m \u001b[38;5;28;01masync\u001b[39;00m \u001b[38;5;28;01mdef\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34mgenerate_thread_summary\u001b[39m(\n\u001b[32m 1694\u001b[39m \u001b[38;5;28mself\u001b[39m,\n\u001b[32m 1695\u001b[39m user_id: \u001b[38;5;28mstr\u001b[39m,\n\u001b[32m (...)\u001b[39m\u001b[32m 1698\u001b[39m **kwargs: Any,\n\u001b[32m 1699\u001b[39m ) -> \u001b[38;5;28mdict\u001b[39m[\u001b[38;5;28mstr\u001b[39m, Any]:\n\u001b[32m 1700\u001b[39m \u001b[38;5;250m \u001b[39m\u001b[33;03m\"\"\"Generate a thread summary.\u001b[39;00m\n\u001b[32m 1701\u001b[39m \n\u001b[32m 1702\u001b[39m \u001b[33;03m Pipeline calls are dispatched to a worker thread via\u001b[39;00m\n\u001b[32m 1703\u001b[39m \u001b[33;03m :func:`asyncio.to_thread` to avoid blocking the event loop.\u001b[39;00m\n\u001b[32m 1704\u001b[39m \u001b[33;03m \"\"\"\u001b[39;00m\n\u001b[32m-> \u001b[39m\u001b[32m1705\u001b[39m \u001b[38;5;28;01mawait\u001b[39;00m \u001b[38;5;28mself\u001b[39m._require_cosmos()\n\u001b[32m 1706\u001b[39m \u001b[38;5;28mself\u001b[39m._require_pipeline()\n\u001b[32m 1707\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;01mawait\u001b[39;00m asyncio.to_thread(\u001b[38;5;28mself\u001b[39m._pipeline.generate_thread_summary, user_id, thread_id, recent_k)\n", + "\u001b[36mFile \u001b[39m\u001b[32m~/github/AgentMemoryToolkit/agent_memory_toolkit/aio/cosmos_memory_client.py:648\u001b[39m, in \u001b[36mAsyncCosmosMemoryClient._require_cosmos\u001b[39m\u001b[34m(self)\u001b[39m\n\u001b[32m 646\u001b[39m \u001b[38;5;250m\u001b[39m\u001b[33;03m\"\"\"Raise if Cosmos DB is not connected.\"\"\"\u001b[39;00m\n\u001b[32m 647\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mself\u001b[39m._container_client \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m:\n\u001b[32m--> \u001b[39m\u001b[32m648\u001b[39m \u001b[38;5;28;01mraise\u001b[39;00m CosmosNotConnectedError()\n", + "\u001b[31mCosmosNotConnectedError\u001b[39m: Cosmos DB is not connected. Call connect_cosmos() first." + ] + } + ], + "source": [ + "thread_id = THREAD_ID\n", + "user_id = USER_ID\n", + "print(f\"Summarizing thread_id={thread_id} user_id={user_id}\\n\")\n", + "\n", + "if memory._container_client is None:\n", + " await memory.connect_cosmos()\n", + "\n", + "summary_doc = await memory.generate_thread_summary(user_id=user_id, thread_id=thread_id)" + ] + }, + { + "cell_type": "code", + "execution_count": 17, + "id": "da4cba4f", + "metadata": { + "ExecuteTime": { + "end_time": "2026-04-07T22:08:13.446032Z", + "start_time": "2026-04-07T22:08:13.390800Z" + }, + "execution": { + "iopub.execute_input": "2026-05-04T20:26:03.875835Z", + "iopub.status.busy": "2026-05-04T20:26:03.875663Z", + "iopub.status.idle": "2026-05-04T20:26:03.879262Z", + "shell.execute_reply": "2026-05-04T20:26:03.878646Z" + } + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Summary document:\n" + ] + }, + { + "ename": "NameError", + "evalue": "name 'summary_doc' is not defined", + "output_type": "error", + "traceback": [ + "\u001b[31m---------------------------------------------------------------------------\u001b[39m", + "\u001b[31mNameError\u001b[39m Traceback (most recent call last)", + "\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[17]\u001b[39m\u001b[32m, line 2\u001b[39m\n\u001b[32m 1\u001b[39m \u001b[38;5;28mprint\u001b[39m(\u001b[33m\"\u001b[39m\u001b[33mSummary document:\u001b[39m\u001b[33m\"\u001b[39m)\n\u001b[32m----> \u001b[39m\u001b[32m2\u001b[39m \u001b[38;5;28mprint\u001b[39m(\u001b[33mf\u001b[39m\u001b[33m\"\u001b[39m\u001b[33m id: \u001b[39m\u001b[38;5;132;01m{\u001b[39;00m\u001b[43msummary_doc\u001b[49m[\u001b[33m'\u001b[39m\u001b[33mid\u001b[39m\u001b[33m'\u001b[39m]\u001b[38;5;132;01m}\u001b[39;00m\u001b[33m\"\u001b[39m)\n\u001b[32m 3\u001b[39m \u001b[38;5;28mprint\u001b[39m(\u001b[33mf\u001b[39m\u001b[33m\"\u001b[39m\u001b[33m content: \u001b[39m\u001b[38;5;132;01m{\u001b[39;00msummary_doc[\u001b[33m'\u001b[39m\u001b[33mcontent\u001b[39m\u001b[33m'\u001b[39m][:\u001b[32m200\u001b[39m]\u001b[38;5;132;01m}\u001b[39;00m\u001b[33m...\u001b[39m\u001b[33m\"\u001b[39m)\n\u001b[32m 4\u001b[39m \u001b[38;5;28mprint\u001b[39m(\u001b[33mf\u001b[39m\u001b[33m\"\u001b[39m\u001b[33m source_count: \u001b[39m\u001b[38;5;132;01m{\u001b[39;00msummary_doc.get(\u001b[33m'\u001b[39m\u001b[33mmetadata\u001b[39m\u001b[33m'\u001b[39m,\u001b[38;5;250m \u001b[39m{}).get(\u001b[33m'\u001b[39m\u001b[33msource_count\u001b[39m\u001b[33m'\u001b[39m)\u001b[38;5;132;01m}\u001b[39;00m\u001b[33m\"\u001b[39m)\n", + "\u001b[31mNameError\u001b[39m: name 'summary_doc' is not defined" + ] + } + ], + "source": [ + "print(\"Summary document:\")\n", + "print(f\" id: {summary_doc['id']}\")\n", + "print(f\" content: {summary_doc['content'][:200]}...\")\n", + "print(f\" source_count: {summary_doc.get('metadata', {}).get('source_count')}\")\n", + "print(f\" embedding length: {len(summary_doc.get('embedding', []))}\")\n" + ] + }, + { + "cell_type": "markdown", + "id": "3cd2e4f8", + "metadata": {}, + "source": [ + "## 5. Memory Extraction (facts + episodic + procedural)\n", + "\n", + "`extract_memories()` runs a single LLM call that produces three structured memory types:\n", + "\n", + "| Type | Description |\n", + "|--------------|--------------------------------------------------------------------------|\n", + "| `fact` | Stable, atomic facts about the user. |\n", + "| `episodic` | Discrete past events the user described. |\n", + "| `procedural` | How-to guidance the agent should follow. |\n", + "\n", + "Each derived memory is embedded and stored in Cosmos DB with auto-generated tags and a salience score.\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "e4d57e2d", + "metadata": { + "ExecuteTime": { + "end_time": "2026-04-07T22:08:23.444563Z", + "start_time": "2026-04-07T22:08:17.255145Z" + }, + "execution": { + "iopub.execute_input": "2026-05-04T20:26:03.881644Z", + "iopub.status.busy": "2026-05-04T20:26:03.881553Z", + "iopub.status.idle": "2026-05-04T20:26:11.858903Z", + "shell.execute_reply": "2026-05-04T20:26:11.857972Z" + } + }, + "outputs": [], + "source": [ + "# Extract memories from both the SEED and the pure-procedural RULES thread.\n", + "result_main = await memory.extract_memories(user_id=USER_ID, thread_id=THREAD_ID)\n", + "print(\"Seed thread extraction:\", result_main)\n", + "\n", + "result_rules = await memory.extract_memories(user_id=USER_ID, thread_id=RULES_THREAD_ID)\n", + "print(\"Rules thread extraction:\", result_rules)\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "795e8634", + "metadata": { + "ExecuteTime": { + "end_time": "2026-04-07T22:08:26.904418Z", + "start_time": "2026-04-07T22:08:26.587707Z" + }, + "execution": { + "iopub.execute_input": "2026-05-04T20:26:11.861697Z", + "iopub.status.busy": "2026-05-04T20:26:11.861551Z", + "iopub.status.idle": "2026-05-04T20:26:12.283813Z", + "shell.execute_reply": "2026-05-04T20:26:12.283042Z" + } + }, + "outputs": [], + "source": [ + "# Inspect the persisted derived memories across BOTH threads for this user.\n", + "for mt in (\"fact\", \"episodic\", \"procedural\"):\n", + " docs = await memory.get_memories(user_id=USER_ID, memory_types=[mt])\n", + " print(f\"\\n{mt.upper()}S ({len(docs)}):\")\n", + " for d in docs:\n", + " print(f\" • {d['content'][:100]} [salience={d.get('salience')}]\")\n" + ] + }, + { + "cell_type": "markdown", + "id": "3ad14e69", + "metadata": {}, + "source": [ + "## 6. User Summary (cross-thread profile)\n", + "\n", + "`generate_user_summary()` aggregates memories **across all threads** for a user and produces a structured profile (preferences, account state, behavioural patterns, …). The result is stored in Cosmos DB with `type: \"user_summary\"`.\n", + "\n", + "Retrieve the latest stored profile at any time with `get_user_summary(user_id)`.\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "cbd3806f", + "metadata": { + "ExecuteTime": { + "end_time": "2026-04-07T22:08:37.628678Z", + "start_time": "2026-04-07T22:08:29.322243Z" + }, + "execution": { + "iopub.execute_input": "2026-05-04T20:26:12.285934Z", + "iopub.status.busy": "2026-05-04T20:26:12.285802Z", + "iopub.status.idle": "2026-05-04T20:26:22.526266Z", + "shell.execute_reply": "2026-05-04T20:26:22.525613Z" + } + }, + "outputs": [], + "source": [ + "# Generate a user-level summary across all threads.\n", + "user_summary_doc = await memory.generate_user_summary(user_id=user_id)\n", + "print(\"User summary id:\", user_summary_doc[\"id\"])\n", + "print(\"\\nContent:\\n\", user_summary_doc[\"content\"][:600], \"...\")\n", + "print(\"\\nStructured profile keys:\", list(user_summary_doc.get(\"metadata\", {}).get(\"structured_summary\", {}).keys()))\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "97ddc94f", + "metadata": { + "ExecuteTime": { + "end_time": "2026-04-07T22:08:39.653532Z", + "start_time": "2026-04-07T22:08:39.229659Z" + }, + "execution": { + "iopub.execute_input": "2026-05-04T20:26:22.528078Z", + "iopub.status.busy": "2026-05-04T20:26:22.527959Z", + "iopub.status.idle": "2026-05-04T20:26:22.618478Z", + "shell.execute_reply": "2026-05-04T20:26:22.618055Z" + } + }, + "outputs": [], + "source": [ + "# Retrieve the stored user summary from Cosmos DB (async)\n", + "stored = await memory.get_user_summary(user_id=user_id)\n", + "if stored:\n", + " print(\"User Summary for\", user_id)\n", + " print(stored[\"content\"])\n", + "else:\n", + " print(\"No user summary found — run the generate_user_summary cell first.\")\n" + ] + }, + { + "cell_type": "markdown", + "id": "92e5d32b", + "metadata": {}, + "source": [ + "### 7. Vector search with `search_cosmos`\n", + "\n", + "Same as the sync version — embeds the query and runs a `VectorDistance` similarity search." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "af4afa77", + "metadata": { + "ExecuteTime": { + "end_time": "2026-04-07T22:08:46.028010Z", + "start_time": "2026-04-07T22:08:43.195430Z" + }, + "execution": { + "iopub.execute_input": "2026-05-04T20:26:22.619506Z", + "iopub.status.busy": "2026-05-04T20:26:22.619453Z", + "iopub.status.idle": "2026-05-04T20:26:24.825313Z", + "shell.execute_reply": "2026-05-04T20:26:24.824663Z" + } + }, + "outputs": [], + "source": [ + "results_search_async = await memory.search_cosmos(\n", + " search_terms=\"What did the user ask about the weather?\",\n", + " user_id=USER_ID,\n", + " top_k=3, hybrid_search= True\n", + ")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "c0471fd4", + "metadata": { + "ExecuteTime": { + "end_time": "2026-04-07T22:08:47.537201Z", + "start_time": "2026-04-07T22:08:47.500038Z" + }, + "execution": { + "iopub.execute_input": "2026-05-04T20:26:24.827496Z", + "iopub.status.busy": "2026-05-04T20:26:24.827365Z", + "iopub.status.idle": "2026-05-04T20:26:24.830446Z", + "shell.execute_reply": "2026-05-04T20:26:24.829891Z" + } + }, + "outputs": [], + "source": [ + "print(f\"Top {len(results_search_async)} results:\\n\")\n", + "for r in results_search_async:\n", + " score = r.get(\"score\", \"N/A\")\n", + " print(f\" [{r['id'][:8]}...] score={score} {r['content'][:60]}\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "bb4cc8f8", + "metadata": { + "ExecuteTime": { + "end_time": "2026-04-07T22:08:49.434405Z", + "start_time": "2026-04-07T22:08:49.164046Z" + }, + "execution": { + "iopub.execute_input": "2026-05-04T20:26:24.831979Z", + "iopub.status.busy": "2026-05-04T20:26:24.831863Z", + "iopub.status.idle": "2026-05-04T20:26:24.835490Z", + "shell.execute_reply": "2026-05-04T20:26:24.834936Z" + } + }, + "outputs": [], + "source": [ + "# Clean up async clients when done\n", + "await memory.close()\n", + "print(\"Async clients closed.\")" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "py314", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.14.0" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/Samples/Demo_function_app.ipynb b/Samples/Notebooks/Demo_function_app.ipynb similarity index 100% rename from Samples/Demo_function_app.ipynb rename to Samples/Notebooks/Demo_function_app.ipynb diff --git a/Samples/Demo_function_app_async.ipynb b/Samples/Notebooks/Demo_function_app_async.ipynb similarity index 98% rename from Samples/Demo_function_app_async.ipynb rename to Samples/Notebooks/Demo_function_app_async.ipynb index 37a2a56..38244d9 100644 --- a/Samples/Demo_function_app_async.ipynb +++ b/Samples/Notebooks/Demo_function_app_async.ipynb @@ -7,11 +7,11 @@ "source": [ "# Agent Memory Toolkit – Function App (Remote Processor) Demo (async)\n", "\n", - "Async variant of `Demo_function_app.ipynb`. Wires `AsyncDurableFunctionProcessor` to\n", + "Async variant of `Samples/Notebooks/Demo_function_app.ipynb`. Wires `AsyncDurableFunctionProcessor` to\n", "`AsyncCosmosMemoryClient` so the SDK only writes raw turns and the deployed sibling Azure Function\n", "App handles all summarisation / fact-extraction asynchronously.\n", "\n", - "See `Demo_function_app.ipynb` for the full pattern explanation." + "See `Samples/Notebooks/Demo_function_app.ipynb` for the full pattern explanation." ] }, { diff --git a/Samples/processing_fact_extraction.py b/Samples/Processing/processing_fact_extraction.py similarity index 100% rename from Samples/processing_fact_extraction.py rename to Samples/Processing/processing_fact_extraction.py diff --git a/Samples/processing_thread_summary.py b/Samples/Processing/processing_thread_summary.py similarity index 100% rename from Samples/processing_thread_summary.py rename to Samples/Processing/processing_thread_summary.py diff --git a/Samples/processing_user_profile.py b/Samples/Processing/processing_user_profile.py similarity index 100% rename from Samples/processing_user_profile.py rename to Samples/Processing/processing_user_profile.py diff --git a/Samples/quickstart_cosmos.py b/Samples/Quickstarts/quickstart_cosmos.py similarity index 100% rename from Samples/quickstart_cosmos.py rename to Samples/Quickstarts/quickstart_cosmos.py diff --git a/Samples/quickstart_local.py b/Samples/Quickstarts/quickstart_local.py similarity index 96% rename from Samples/quickstart_local.py rename to Samples/Quickstarts/quickstart_local.py index c52ab09..9d61924 100644 --- a/Samples/quickstart_local.py +++ b/Samples/Quickstarts/quickstart_local.py @@ -1,7 +1,7 @@ """Quickstart: local-only CosmosMemoryClient demo (no cloud credentials needed). Run with: - python Samples/quickstart_local.py + python Samples/Quickstarts/quickstart_local.py """ from agent_memory_toolkit import CosmosMemoryClient diff --git a/Samples/scenario_chat_memory.py b/Samples/Scenarios/scenario_chat_memory.py similarity index 100% rename from Samples/scenario_chat_memory.py rename to Samples/Scenarios/scenario_chat_memory.py diff --git a/Samples/scenario_counter_tuning.py b/Samples/Scenarios/scenario_counter_tuning.py similarity index 100% rename from Samples/scenario_counter_tuning.py rename to Samples/Scenarios/scenario_counter_tuning.py diff --git a/Samples/scenario_customer_support.py b/Samples/Scenarios/scenario_customer_support.py similarity index 100% rename from Samples/scenario_customer_support.py rename to Samples/Scenarios/scenario_customer_support.py diff --git a/Samples/scenario_memory_reconciliation.py b/Samples/Scenarios/scenario_memory_reconciliation.py similarity index 100% rename from Samples/scenario_memory_reconciliation.py rename to Samples/Scenarios/scenario_memory_reconciliation.py diff --git a/Samples/scenario_multi_agent.py b/Samples/Scenarios/scenario_multi_agent.py similarity index 100% rename from Samples/scenario_multi_agent.py rename to Samples/Scenarios/scenario_multi_agent.py diff --git a/Samples/scenario_rag_with_memory.py b/Samples/Scenarios/scenario_rag_with_memory.py similarity index 100% rename from Samples/scenario_rag_with_memory.py rename to Samples/Scenarios/scenario_rag_with_memory.py diff --git a/Samples/scenario_remote_processor.py b/Samples/Scenarios/scenario_remote_processor.py similarity index 100% rename from Samples/scenario_remote_processor.py rename to Samples/Scenarios/scenario_remote_processor.py diff --git a/Samples/scenario_remote_processor_async.py b/Samples/Scenarios/scenario_remote_processor_async.py similarity index 93% rename from Samples/scenario_remote_processor_async.py rename to Samples/Scenarios/scenario_remote_processor_async.py index 9d15302..cc6d5aa 100644 --- a/Samples/scenario_remote_processor_async.py +++ b/Samples/Scenarios/scenario_remote_processor_async.py @@ -1,10 +1,10 @@ -"""Async variant of :mod:`scenario_remote_processor`. +"""Async variant of ``Samples/Scenarios/scenario_remote_processor.py``. Wires :class:`AsyncDurableFunctionProcessor` to the :class:`AsyncCosmosMemoryClient` so the SDK only writes raw turns and the sibling Azure Function app handles summarization via the Cosmos change feed. -See ``scenario_remote_processor.py`` for the prerequisites and behavior notes. +See ``Samples/Scenarios/scenario_remote_processor.py`` for the prerequisites and behavior notes. """ from __future__ import annotations diff --git a/Samples/scenario_tagging_and_filtering.py b/Samples/Scenarios/scenario_tagging_and_filtering.py similarity index 100% rename from Samples/scenario_tagging_and_filtering.py rename to Samples/Scenarios/scenario_tagging_and_filtering.py diff --git a/agent_memory_toolkit/prompts/dedup.prompty b/agent_memory_toolkit/prompts/dedup.prompty index 27446e6..b933807 100644 --- a/agent_memory_toolkit/prompts/dedup.prompty +++ b/agent_memory_toolkit/prompts/dedup.prompty @@ -2,12 +2,11 @@ name: dedup description: Reconcile a pool of active facts — collapse duplicates and resolve semantic contradictions in one pass. model: - apiType: chat - options: + api: chat + parameters: temperature: 0.0 - additionalProperties: - response_format: - type: json_object + response_format: + type: json_object inputs: facts_text: type: string diff --git a/agent_memory_toolkit/prompts/extract_memories.prompty b/agent_memory_toolkit/prompts/extract_memories.prompty index 1a386df..5c99f60 100644 --- a/agent_memory_toolkit/prompts/extract_memories.prompty +++ b/agent_memory_toolkit/prompts/extract_memories.prompty @@ -2,12 +2,11 @@ name: extract_memories description: Extract facts, procedural rules, and episodic memories from a conversation, reconciled against existing memories. model: - apiType: chat - options: + api: chat + parameters: temperature: 0.0 - additionalProperties: - response_format: - type: json_object + response_format: + type: json_object inputs: existing_facts: type: string diff --git a/agent_memory_toolkit/prompts/summarize.prompty b/agent_memory_toolkit/prompts/summarize.prompty index 5cf449c..72d5269 100644 --- a/agent_memory_toolkit/prompts/summarize.prompty +++ b/agent_memory_toolkit/prompts/summarize.prompty @@ -2,12 +2,11 @@ name: summarize description: Produce a structured JSON summary of a single conversation thread. model: - apiType: chat - options: + api: chat + parameters: temperature: 0.2 - additionalProperties: - response_format: - type: json_object + response_format: + type: json_object inputs: transcript: type: string diff --git a/agent_memory_toolkit/prompts/summarize_update.prompty b/agent_memory_toolkit/prompts/summarize_update.prompty index 65438bf..c419708 100644 --- a/agent_memory_toolkit/prompts/summarize_update.prompty +++ b/agent_memory_toolkit/prompts/summarize_update.prompty @@ -2,12 +2,11 @@ name: summarize_update description: Update an existing JSON thread summary with new messages. model: - apiType: chat - options: + api: chat + parameters: temperature: 0.2 - additionalProperties: - response_format: - type: json_object + response_format: + type: json_object inputs: prior_summary: type: string diff --git a/agent_memory_toolkit/prompts/user_summary.prompty b/agent_memory_toolkit/prompts/user_summary.prompty index 9939d7c..b197c6c 100644 --- a/agent_memory_toolkit/prompts/user_summary.prompty +++ b/agent_memory_toolkit/prompts/user_summary.prompty @@ -2,12 +2,11 @@ name: user_summary description: Build a structured JSON user profile from one or more conversation threads. model: - apiType: chat - options: + api: chat + parameters: temperature: 0.2 - additionalProperties: - response_format: - type: json_object + response_format: + type: json_object inputs: transcript: type: string diff --git a/agent_memory_toolkit/prompts/user_summary_update.prompty b/agent_memory_toolkit/prompts/user_summary_update.prompty index 4381406..cf81eda 100644 --- a/agent_memory_toolkit/prompts/user_summary_update.prompty +++ b/agent_memory_toolkit/prompts/user_summary_update.prompty @@ -2,12 +2,11 @@ name: user_summary_update description: Update an existing JSON user profile with new conversation data. model: - apiType: chat - options: + api: chat + parameters: temperature: 0.2 - additionalProperties: - response_format: - type: json_object + response_format: + type: json_object inputs: prior_summary: type: string