|
2 | 2 | "cells": [
|
3 | 3 | {
|
4 | 4 | "cell_type": "code",
|
5 |
| - "execution_count": 3, |
| 5 | + "execution_count": 1, |
6 | 6 | "metadata": {
|
7 | 7 | "ExecuteTime": {
|
8 | 8 | "end_time": "2025-09-27T19:47:26.324483Z",
|
|
17 | 17 | },
|
18 | 18 | {
|
19 | 19 | "cell_type": "code",
|
20 |
| - "execution_count": 4, |
| 20 | + "execution_count": null, |
21 | 21 | "metadata": {
|
22 | 22 | "ExecuteTime": {
|
23 | 23 | "end_time": "2025-09-27T19:47:26.904721Z",
|
|
30 | 30 | "output_type": "stream",
|
31 | 31 | "text": [
|
32 | 32 | "\n",
|
33 |
| - "========================= CONTROL PLANE DEMO =========================\n", |
34 |
| - "🔍 DEBUG: Starting control plane operations...\n", |
35 |
| - "🔍 DEBUG: Short-term memory created successfully\n" |
| 33 | + "========================= CONTROL PLANE DEMO =========================\n" |
| 34 | + ] |
| 35 | + }, |
| 36 | + { |
| 37 | + "name": "stderr", |
| 38 | + "output_type": "stream", |
| 39 | + "text": [ |
| 40 | + "✅ MemoryManager initialized for region: None\n" |
| 41 | + ] |
| 42 | + }, |
| 43 | + { |
| 44 | + "name": "stdout", |
| 45 | + "output_type": "stream", |
| 46 | + "text": [ |
| 47 | + "🔍 DEBUG: Starting control plane operations...\n" |
| 48 | + ] |
| 49 | + }, |
| 50 | + { |
| 51 | + "name": "stderr", |
| 52 | + "output_type": "stream", |
| 53 | + "text": [ |
| 54 | + "Memory already exists. Using existing memory ID: DemoLongTermMemory1-AJRz1XDfS6\n", |
| 55 | + "🔎 Retrieving memory resource with ID: DemoLongTermMemory1-AJRz1XDfS6...\n", |
| 56 | + " ✅ Found memory: DemoLongTermMemory1-AJRz1XDfS6\n" |
| 57 | + ] |
| 58 | + }, |
| 59 | + { |
| 60 | + "name": "stdout", |
| 61 | + "output_type": "stream", |
| 62 | + "text": [ |
| 63 | + "🔍 DEBUG: long-term memory created successfully\n" |
36 | 64 | ]
|
37 | 65 | },
|
38 | 66 | {
|
|
41 | 69 | "{'arn': 'arn:aws:bedrock-agentcore:us-east-1:328307993871:memory/DemoLongTermMemory1-AJRz1XDfS6', 'id': 'DemoLongTermMemory1-AJRz1XDfS6', 'name': 'DemoLongTermMemory1', 'description': 'A temporary memory for short-lived conversations.', 'eventExpiryDuration': 90, 'status': 'ACTIVE', 'createdAt': datetime.datetime(2025, 9, 27, 15, 35, 20, 523000, tzinfo=tzlocal()), 'updatedAt': datetime.datetime(2025, 9, 27, 15, 44, 51, 65000, tzinfo=tzlocal()), 'strategies': [{'strategyId': 'SemanticStrategy-AYF3Xl8OoD', 'name': 'SemanticStrategy', 'description': 'A strategy for semantic understanding.', 'type': 'SEMANTIC', 'namespaces': ['support/user/{actorId}/{sessionId}'], 'createdAt': datetime.datetime(2025, 9, 27, 15, 35, 20, 523000, tzinfo=tzlocal()), 'updatedAt': datetime.datetime(2025, 9, 27, 15, 35, 20, 754000, tzinfo=tzlocal()), 'status': 'ACTIVE'}, {'strategyId': 'SummaryStrategy-o93FeU6Zdd', 'name': 'SummaryStrategy', 'description': 'A strategy for summarizing the conversation.', 'type': 'SUMMARIZATION', 'namespaces': ['support/user/{actorId}/{sessionId}'], 'createdAt': datetime.datetime(2025, 9, 27, 15, 44, 51, 175000, tzinfo=tzlocal()), 'updatedAt': datetime.datetime(2025, 9, 27, 15, 44, 51, 175000, tzinfo=tzlocal()), 'status': 'ACTIVE'}]}"
|
42 | 70 | ]
|
43 | 71 | },
|
44 |
| - "execution_count": 4, |
| 72 | + "execution_count": 2, |
45 | 73 | "metadata": {},
|
46 | 74 | "output_type": "execute_result"
|
47 | 75 | }
|
|
64 | 92 | " )\n",
|
65 | 93 | " ],\n",
|
66 | 94 | ")\n",
|
67 |
| - "print(\"🔍 DEBUG: Short-term memory created successfully\")\n", |
| 95 | + "print(\"🔍 DEBUG: long-term memory created successfully\")\n", |
68 | 96 | "memory1"
|
69 | 97 | ]
|
70 | 98 | },
|
71 | 99 | {
|
72 | 100 | "cell_type": "code",
|
73 |
| - "execution_count": 5, |
| 101 | + "execution_count": null, |
74 | 102 | "metadata": {
|
75 | 103 | "ExecuteTime": {
|
76 | 104 | "end_time": "2025-09-27T19:47:27.197308Z",
|
77 | 105 | "start_time": "2025-09-27T19:47:26.910254Z"
|
78 | 106 | }
|
79 | 107 | },
|
80 | 108 | "outputs": [
|
| 109 | + { |
| 110 | + "name": "stderr", |
| 111 | + "output_type": "stream", |
| 112 | + "text": [ |
| 113 | + "Memory already exists. Using existing memory ID: DemoLongTermMemory2-O63lir7uK6\n", |
| 114 | + "🔎 Retrieving memory resource with ID: DemoLongTermMemory2-O63lir7uK6...\n", |
| 115 | + " ✅ Found memory: DemoLongTermMemory2-O63lir7uK6\n" |
| 116 | + ] |
| 117 | + }, |
81 | 118 | {
|
82 | 119 | "name": "stdout",
|
83 | 120 | "output_type": "stream",
|
84 | 121 | "text": [
|
85 |
| - "🔍 DEBUG: Short-term memory created successfully\n" |
| 122 | + "🔍 DEBUG: Long-term memory created successfully\n" |
86 | 123 | ]
|
87 | 124 | },
|
88 | 125 | {
|
|
91 | 128 | "{'arn': 'arn:aws:bedrock-agentcore:us-east-1:328307993871:memory/DemoLongTermMemory2-O63lir7uK6', 'id': 'DemoLongTermMemory2-O63lir7uK6', 'name': 'DemoLongTermMemory2', 'description': 'A temporary memory for short-lived conversations.', 'eventExpiryDuration': 90, 'status': 'ACTIVE', 'createdAt': datetime.datetime(2025, 9, 27, 15, 38, 14, 362000, tzinfo=tzlocal()), 'updatedAt': datetime.datetime(2025, 9, 27, 15, 41, 9, 247000, tzinfo=tzlocal()), 'strategies': [{'strategyId': 'SummaryStrategy-j4HeHK8XCR', 'name': 'SummaryStrategy', 'description': 'A strategy for summarizing the conversation.', 'type': 'SUMMARIZATION', 'namespaces': ['support/user/{actorId}/{sessionId}'], 'createdAt': datetime.datetime(2025, 9, 27, 15, 41, 8, 278000, tzinfo=tzlocal()), 'updatedAt': datetime.datetime(2025, 9, 27, 15, 41, 8, 278000, tzinfo=tzlocal()), 'status': 'ACTIVE'}]}"
|
92 | 129 | ]
|
93 | 130 | },
|
94 |
| - "execution_count": 5, |
| 131 | + "execution_count": 3, |
95 | 132 | "metadata": {},
|
96 | 133 | "output_type": "execute_result"
|
97 | 134 | }
|
|
100 | 137 | "# Memory creation using strategies without data classes\n",
|
101 | 138 | "memory2: Memory = manager.get_or_create_memory(\n",
|
102 | 139 | " name=\"DemoLongTermMemory2\",\n",
|
103 |
| - " description=\"A temporary memory for short-lived conversations.\",\n", |
| 140 | + " description=\"A temporary memory for long-lived conversations.\",\n", |
104 | 141 | " strategies=[\n",
|
105 | 142 | " {\n",
|
106 | 143 | " \"semanticMemoryStrategy\": {\n",
|
|
111 | 148 | " }\n",
|
112 | 149 | " ],\n",
|
113 | 150 | ")\n",
|
114 |
| - "print(\"🔍 DEBUG: Short-term memory created successfully\")\n", |
| 151 | + "print(\"🔍 DEBUG: Long-term memory created successfully\")\n", |
115 | 152 | "memory2"
|
116 | 153 | ]
|
117 | 154 | },
|
118 | 155 | {
|
119 | 156 | "cell_type": "code",
|
120 |
| - "execution_count": 17, |
| 157 | + "execution_count": null, |
121 | 158 | "metadata": {},
|
122 | 159 | "outputs": [
|
| 160 | + { |
| 161 | + "name": "stderr", |
| 162 | + "output_type": "stream", |
| 163 | + "text": [ |
| 164 | + "Memory already exists. Using existing memory ID: DemoLongTermMemory3-mP3Knz4YTX\n", |
| 165 | + "🔎 Retrieving memory resource with ID: DemoLongTermMemory3-mP3Knz4YTX...\n", |
| 166 | + " ✅ Found memory: DemoLongTermMemory3-mP3Knz4YTX\n" |
| 167 | + ] |
| 168 | + }, |
123 | 169 | {
|
124 | 170 | "name": "stdout",
|
125 | 171 | "output_type": "stream",
|
126 | 172 | "text": [
|
127 |
| - "🔍 DEBUG: Short-term memory created successfully\n" |
| 173 | + "🔍 DEBUG: Long-term memory created successfully\n" |
128 | 174 | ]
|
129 | 175 | },
|
130 | 176 | {
|
131 | 177 | "data": {
|
132 | 178 | "text/plain": [
|
133 |
| - "{'arn': 'arn:aws:bedrock-agentcore:us-east-1:328307993871:memory/DemoLongTermMemory3-mP3Knz4YTX', 'id': 'DemoLongTermMemory3-mP3Knz4YTX', 'name': 'DemoLongTermMemory3', 'description': 'A temporary memory for short-lived conversations.', 'eventExpiryDuration': 90, 'status': 'CREATING', 'createdAt': datetime.datetime(2025, 9, 29, 12, 8, 26, 264000, tzinfo=tzlocal()), 'updatedAt': datetime.datetime(2025, 9, 29, 12, 8, 26, 264000, tzinfo=tzlocal()), 'strategies': [{'strategyId': 'UserPreferenceStrategy-PMYICVDWE5', 'name': 'UserPreferenceStrategy', 'description': 'A strategy for user preference.', 'type': 'USER_PREFERENCE', 'namespaces': ['/strategies/{memoryStrategyId}/actors/{actorId}'], 'createdAt': datetime.datetime(2025, 9, 29, 12, 8, 26, 264000, tzinfo=tzlocal()), 'updatedAt': datetime.datetime(2025, 9, 29, 12, 8, 26, 264000, tzinfo=tzlocal()), 'status': 'CREATING'}]}" |
| 179 | + "{'arn': 'arn:aws:bedrock-agentcore:us-east-1:328307993871:memory/DemoLongTermMemory3-mP3Knz4YTX', 'id': 'DemoLongTermMemory3-mP3Knz4YTX', 'name': 'DemoLongTermMemory3', 'description': 'A temporary memory for short-lived conversations.', 'eventExpiryDuration': 90, 'status': 'ACTIVE', 'createdAt': datetime.datetime(2025, 9, 29, 12, 8, 26, 264000, tzinfo=tzlocal()), 'updatedAt': datetime.datetime(2025, 9, 29, 12, 8, 26, 484000, tzinfo=tzlocal()), 'strategies': [{'strategyId': 'UserPreferenceStrategy-PMYICVDWE5', 'name': 'UserPreferenceStrategy', 'description': 'A strategy for user preference.', 'type': 'USER_PREFERENCE', 'namespaces': ['/strategies/{memoryStrategyId}/actors/{actorId}'], 'createdAt': datetime.datetime(2025, 9, 29, 12, 8, 26, 264000, tzinfo=tzlocal()), 'updatedAt': datetime.datetime(2025, 9, 29, 12, 8, 26, 484000, tzinfo=tzlocal()), 'status': 'ACTIVE'}]}" |
134 | 180 | ]
|
135 | 181 | },
|
136 |
| - "execution_count": 17, |
| 182 | + "execution_count": 4, |
137 | 183 | "metadata": {},
|
138 | 184 | "output_type": "execute_result"
|
139 | 185 | }
|
|
142 | 188 | "# Memory creation using strategies without data classes\n",
|
143 | 189 | "from bedrock_agentcore_starter_toolkit.operations.memory.models.strategies.user_preference import UserPreferenceStrategy\n",
|
144 | 190 | "\n",
|
145 |
| - "\n", |
146 | 191 | "memory3: Memory = manager.get_or_create_memory(\n",
|
147 | 192 | " name=\"DemoLongTermMemory3\",\n",
|
148 |
| - " description=\"A temporary memory for short-lived conversations.\",\n", |
| 193 | + " description=\"A temporary memory for long-lived conversations.\",\n", |
149 | 194 | " strategies=[\n",
|
150 | 195 | " UserPreferenceStrategy(\n",
|
151 | 196 | " name=\"UserPreferenceStrategy\",\n",
|
152 | 197 | " description=\"A strategy for user preference.\",\n",
|
153 | 198 | " )\n",
|
154 | 199 | " ],\n",
|
155 | 200 | ")\n",
|
156 |
| - "print(\"🔍 DEBUG: Short-term memory created successfully\")\n", |
| 201 | + "print(\"🔍 DEBUG: Long-term memory created successfully\")\n", |
157 | 202 | "memory3"
|
158 | 203 | ]
|
159 | 204 | },
|
|
168 | 213 | "[{'strategyId': 'UserPreferenceStrategy-PMYICVDWE5', 'name': 'UserPreferenceStrategy', 'description': 'A strategy for user preference.', 'type': 'USER_PREFERENCE', 'namespaces': ['/strategies/{memoryStrategyId}/actors/{actorId}'], 'createdAt': datetime.datetime(2025, 9, 29, 12, 8, 26, 264000, tzinfo=tzlocal()), 'updatedAt': datetime.datetime(2025, 9, 29, 12, 8, 26, 484000, tzinfo=tzlocal()), 'status': 'ACTIVE'}]"
|
169 | 214 | ]
|
170 | 215 | },
|
171 |
| - "execution_count": 18, |
| 216 | + "execution_count": 5, |
172 | 217 | "metadata": {},
|
173 | 218 | "output_type": "execute_result"
|
174 | 219 | }
|
|
180 | 225 | },
|
181 | 226 | {
|
182 | 227 | "cell_type": "code",
|
183 |
| - "execution_count": 6, |
| 228 | + "execution_count": null, |
184 | 229 | "metadata": {
|
185 | 230 | "ExecuteTime": {
|
186 | 231 | "end_time": "2025-09-27T19:47:27.306295Z",
|
|
194 | 239 | "text": [
|
195 | 240 | "🔍 DEBUG: Memory found : {'arn': 'arn:aws:bedrock-agentcore:us-east-1:328307993871:memory/DemoLongTermMemory1-AJRz1XDfS6', 'id': 'DemoLongTermMemory1-AJRz1XDfS6', 'status': 'ACTIVE', 'createdAt': datetime.datetime(2025, 9, 27, 15, 35, 20, 523000, tzinfo=tzlocal()), 'updatedAt': datetime.datetime(2025, 9, 27, 15, 44, 51, 65000, tzinfo=tzlocal()), 'memoryId': 'DemoLongTermMemory1-AJRz1XDfS6'}\n",
|
196 | 241 | "🔍 DEBUG: Memory found : {'arn': 'arn:aws:bedrock-agentcore:us-east-1:328307993871:memory/DemoLongTermMemory2-O63lir7uK6', 'id': 'DemoLongTermMemory2-O63lir7uK6', 'status': 'ACTIVE', 'createdAt': datetime.datetime(2025, 9, 27, 15, 38, 14, 362000, tzinfo=tzlocal()), 'updatedAt': datetime.datetime(2025, 9, 27, 15, 41, 9, 247000, tzinfo=tzlocal()), 'memoryId': 'DemoLongTermMemory2-O63lir7uK6'}\n",
|
| 242 | + "🔍 DEBUG: Memory found : {'arn': 'arn:aws:bedrock-agentcore:us-east-1:328307993871:memory/DemoLongTermMemory3-mP3Knz4YTX', 'id': 'DemoLongTermMemory3-mP3Knz4YTX', 'status': 'ACTIVE', 'createdAt': datetime.datetime(2025, 9, 29, 12, 8, 26, 264000, tzinfo=tzlocal()), 'updatedAt': datetime.datetime(2025, 9, 29, 12, 8, 26, 484000, tzinfo=tzlocal()), 'memoryId': 'DemoLongTermMemory3-mP3Knz4YTX'}\n", |
197 | 243 | "🔍 DEBUG: Memory found : {'arn': 'arn:aws:bedrock-agentcore:us-east-1:328307993871:memory/TypedMemory-BMWCYo4kT8', 'id': 'TypedMemory-BMWCYo4kT8', 'status': 'ACTIVE', 'createdAt': datetime.datetime(2025, 9, 27, 16, 25, 2, 264000, tzinfo=tzlocal()), 'updatedAt': datetime.datetime(2025, 9, 27, 16, 25, 3, 666000, tzinfo=tzlocal()), 'memoryId': 'TypedMemory-BMWCYo4kT8'}\n"
|
198 | 244 | ]
|
199 | 245 | }
|
|
206 | 252 | },
|
207 | 253 | {
|
208 | 254 | "cell_type": "code",
|
209 |
| - "execution_count": 7, |
| 255 | + "execution_count": null, |
210 | 256 | "metadata": {
|
211 | 257 | "ExecuteTime": {
|
212 | 258 | "end_time": "2025-09-27T19:47:27.462204Z",
|
|
234 | 280 | },
|
235 | 281 | {
|
236 | 282 | "cell_type": "code",
|
237 |
| - "execution_count": 8, |
| 283 | + "execution_count": null, |
238 | 284 | "metadata": {
|
239 | 285 | "ExecuteTime": {
|
240 | 286 | "end_time": "2025-09-27T19:47:27.468260Z",
|
|
267 | 313 | },
|
268 | 314 | {
|
269 | 315 | "cell_type": "code",
|
270 |
| - "execution_count": 9, |
| 316 | + "execution_count": null, |
271 | 317 | "metadata": {
|
272 | 318 | "ExecuteTime": {
|
273 | 319 | "end_time": "2025-09-27T19:47:27.477723Z",
|
|
293 | 339 | },
|
294 | 340 | {
|
295 | 341 | "cell_type": "code",
|
296 |
| - "execution_count": 10, |
| 342 | + "execution_count": null, |
297 | 343 | "metadata": {
|
298 | 344 | "ExecuteTime": {
|
299 | 345 | "end_time": "2025-09-27T19:47:27.636202Z",
|
300 | 346 | "start_time": "2025-09-27T19:47:27.486734Z"
|
301 | 347 | }
|
302 | 348 | },
|
303 |
| - "outputs": [], |
| 349 | + "outputs": [ |
| 350 | + { |
| 351 | + "name": "stderr", |
| 352 | + "output_type": "stream", |
| 353 | + "text": [ |
| 354 | + "🔎 Retrieving memory resource with ID: DemoLongTermMemory1-AJRz1XDfS6...\n", |
| 355 | + " ✅ Found memory: DemoLongTermMemory1-AJRz1XDfS6\n" |
| 356 | + ] |
| 357 | + } |
| 358 | + ], |
304 | 359 | "source": [
|
305 | 360 | "# Fetch the memory again to see the updated strategies\n",
|
306 | 361 | "get_response = manager.get_memory(memory_id=memory1.id)"
|
307 | 362 | ]
|
308 | 363 | },
|
309 | 364 | {
|
310 | 365 | "cell_type": "code",
|
311 |
| - "execution_count": 11, |
| 366 | + "execution_count": null, |
312 | 367 | "metadata": {
|
313 | 368 | "ExecuteTime": {
|
314 | 369 | "end_time": "2025-09-27T19:47:27.644091Z",
|
|
333 | 388 | },
|
334 | 389 | {
|
335 | 390 | "cell_type": "code",
|
336 |
| - "execution_count": 12, |
| 391 | + "execution_count": null, |
337 | 392 | "metadata": {
|
338 | 393 | "ExecuteTime": {
|
339 | 394 | "end_time": "2025-09-27T19:47:27.813467Z",
|
|
359 | 414 | },
|
360 | 415 | {
|
361 | 416 | "cell_type": "code",
|
362 |
| - "execution_count": 13, |
| 417 | + "execution_count": null, |
363 | 418 | "metadata": {
|
364 | 419 | "ExecuteTime": {
|
365 | 420 | "end_time": "2025-09-27T19:47:27.923072Z",
|
|
371 | 426 | "name": "stdout",
|
372 | 427 | "output_type": "stream",
|
373 | 428 | "text": [
|
| 429 | + "ACTIVE\n", |
374 | 430 | "ACTIVE\n",
|
375 | 431 | "ACTIVE\n",
|
376 | 432 | "ACTIVE\n"
|
|
384 | 440 | },
|
385 | 441 | {
|
386 | 442 | "cell_type": "code",
|
387 |
| - "execution_count": 14, |
| 443 | + "execution_count": null, |
388 | 444 | "metadata": {
|
389 | 445 | "ExecuteTime": {
|
390 | 446 | "end_time": "2025-09-27T19:47:28.097043Z",
|
|
409 | 465 | },
|
410 | 466 | {
|
411 | 467 | "cell_type": "code",
|
412 |
| - "execution_count": 15, |
| 468 | + "execution_count": null, |
413 | 469 | "metadata": {
|
414 | 470 | "ExecuteTime": {
|
415 | 471 | "end_time": "2025-09-27T19:47:28.106744Z",
|
|
428 | 484 | },
|
429 | 485 | {
|
430 | 486 | "cell_type": "code",
|
431 |
| - "execution_count": 16, |
| 487 | + "execution_count": null, |
432 | 488 | "metadata": {
|
433 | 489 | "ExecuteTime": {
|
434 | 490 | "end_time": "2025-09-27T19:47:28.514982Z",
|
435 | 491 | "start_time": "2025-09-27T19:47:28.113961Z"
|
436 | 492 | }
|
437 | 493 | },
|
438 | 494 | "outputs": [
|
| 495 | + { |
| 496 | + "name": "stderr", |
| 497 | + "output_type": "stream", |
| 498 | + "text": [ |
| 499 | + "🔎 Retrieving memory resource with ID: DemoLongTermMemory1-AJRz1XDfS6...\n", |
| 500 | + " ✅ Found memory: DemoLongTermMemory1-AJRz1XDfS6\n", |
| 501 | + "🔎 Retrieving memory resource with ID: DemoLongTermMemory2-O63lir7uK6...\n", |
| 502 | + " ✅ Found memory: DemoLongTermMemory2-O63lir7uK6\n", |
| 503 | + "🔎 Retrieving memory resource with ID: DemoLongTermMemory3-mP3Knz4YTX...\n" |
| 504 | + ] |
| 505 | + }, |
439 | 506 | {
|
440 | 507 | "name": "stdout",
|
441 | 508 | "output_type": "stream",
|
442 | 509 | "text": [
|
443 | 510 | "🔍 DEBUG: Memory found with status: ACTIVE\n",
|
| 511 | + "🔍 DEBUG: Memory found with status: ACTIVE\n" |
| 512 | + ] |
| 513 | + }, |
| 514 | + { |
| 515 | + "name": "stderr", |
| 516 | + "output_type": "stream", |
| 517 | + "text": [ |
| 518 | + " ✅ Found memory: DemoLongTermMemory3-mP3Knz4YTX\n", |
| 519 | + "🔎 Retrieving memory resource with ID: TypedMemory-BMWCYo4kT8...\n", |
| 520 | + " ✅ Found memory: TypedMemory-BMWCYo4kT8\n" |
| 521 | + ] |
| 522 | + }, |
| 523 | + { |
| 524 | + "name": "stdout", |
| 525 | + "output_type": "stream", |
| 526 | + "text": [ |
444 | 527 | "🔍 DEBUG: Memory found with status: ACTIVE\n",
|
445 | 528 | "🔍 DEBUG: Memory found with status: ACTIVE\n"
|
446 | 529 | ]
|
|
0 commit comments