fix(memory): escape delimiters when building the session scope key (#6892)
This commit is contained in:
+6
-1
@@ -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)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user