Commit ae41958
fix: resolve working memory key via search index when user_id/namespace omitted (#239)
* fix: resolve working memory key via search index when user_id/namespace omitted (#235)
PUT /v1/working-memory/{session_id} stores user_id and namespace from
the request body into the Redis key, but GET/DELETE construct the key
from query params. When callers omit those params, a different key is
produced and the session appears missing (404).
Add an index-based fallback: when a direct key lookup returns nothing,
query the working memory search index by session_id to resolve the
actual Redis key. This preserves multi-tenant isolation (namespace +
user_id remain in keys) while making GET/DELETE work without requiring
callers to repeat scoping parameters.
Changes:
- Add _resolve_working_memory_key_via_index() helper in working_memory.py
- Use fallback in get_working_memory() and delete_working_memory()
- Return stored namespace/user_id from JSON data instead of caller params
- Add user_id/namespace params to MCP get_working_memory tool
- Add comprehensive tests covering the fix and multi-tenant isolation
* Update agent_memory_server/working_memory.py
Co-authored-by: Vishal Bala <vishal-bala@users.noreply.github.com>
* Fix linter issues
---------
Co-authored-by: Tyler Hutcherson <tyler.hutcherson@redis.com>
Co-authored-by: Vishal Bala <vishal-bala@users.noreply.github.com>
Co-authored-by: Vishal Bala <vishalbala.1994@gmail.com>1 parent 32fb411 commit ae41958
3 files changed
Lines changed: 495 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
979 | 979 | | |
980 | 980 | | |
981 | 981 | | |
| 982 | + | |
| 983 | + | |
982 | 984 | | |
983 | 985 | | |
984 | 986 | | |
985 | 987 | | |
986 | 988 | | |
987 | 989 | | |
988 | 990 | | |
| 991 | + | |
| 992 | + | |
989 | 993 | | |
990 | 994 | | |
991 | 995 | | |
992 | 996 | | |
993 | 997 | | |
994 | 998 | | |
995 | | - | |
| 999 | + | |
| 1000 | + | |
| 1001 | + | |
| 1002 | + | |
996 | 1003 | | |
997 | 1004 | | |
998 | 1005 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
356 | 356 | | |
357 | 357 | | |
358 | 358 | | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
359 | 437 | | |
360 | 438 | | |
361 | 439 | | |
| |||
418 | 496 | | |
419 | 497 | | |
420 | 498 | | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
421 | 514 | | |
422 | 515 | | |
423 | 516 | | |
| |||
467 | 560 | | |
468 | 561 | | |
469 | 562 | | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
470 | 568 | | |
471 | 569 | | |
472 | 570 | | |
473 | 571 | | |
474 | | - | |
| 572 | + | |
475 | 573 | | |
476 | 574 | | |
477 | | - | |
| 575 | + | |
478 | 576 | | |
479 | 577 | | |
480 | 578 | | |
| |||
589 | 687 | | |
590 | 688 | | |
591 | 689 | | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
592 | 700 | | |
593 | 701 | | |
594 | 702 | | |
| |||
0 commit comments