fix(memory): escape delimiters when building the session scope key (#6892)

This commit is contained in:
Kartik
2026-08-11 23:23:55 +05:30
committed by GitHub
parent 35a125585e
commit 71f2ebefa3
7 changed files with 313 additions and 4 deletions
+6 -1
View File
@@ -404,13 +404,18 @@ def _build_filters_and_metadata(
return base_metadata_template, effective_query_filters
def _escape_scope_value(val: Any) -> str:
"""Escape the structural delimiters of the session scope key."""
return str(val).replace("%", "%25").replace("&", "%26").replace("=", "%3D")
def _build_session_scope(filters):
"""Build deterministic session scope string from entity IDs."""
parts = []
for key in sorted(["user_id", "agent_id", "run_id"]):
val = filters.get(key)
if val:
parts.append(f"{key}={val}")
parts.append(f"{key}={_escape_scope_value(val)}")
return "&".join(parts)