doc-service: persist doc_context by stable session key
This commit is contained in:
@@ -105,10 +105,9 @@ class DocumentService:
|
|||||||
True if saved successfully
|
True if saved successfully
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
# Extract fallback user_id from session_id if not provided.
|
# Use stable synthetic user key per session, so context can be
|
||||||
# Format: "channel:identifier" or "channel:user_id"
|
# retrieved later using only session_id (without caller user_id).
|
||||||
parts = session_id.split(":", 1)
|
fact_user_id = f"session:{session_id}"
|
||||||
fact_user_id = user_id or (parts[1] if len(parts) > 1 else session_id)
|
|
||||||
|
|
||||||
# Save as fact in Memory Service
|
# Save as fact in Memory Service
|
||||||
fact_key = f"doc_context:{session_id}"
|
fact_key = f"doc_context:{session_id}"
|
||||||
@@ -148,8 +147,7 @@ class DocumentService:
|
|||||||
DocContext or None
|
DocContext or None
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
parts = session_id.split(":", 1)
|
user_id = f"session:{session_id}"
|
||||||
user_id = parts[1] if len(parts) > 1 else session_id
|
|
||||||
|
|
||||||
fact_key = f"doc_context:{session_id}"
|
fact_key = f"doc_context:{session_id}"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user