Merge branch 'main' of github.com:NousResearch/hermes-agent into feat/ink-refactor
This commit is contained in:
@@ -486,9 +486,14 @@ def _parse_session_key(session_key: str) -> "dict | None":
|
||||
"""Parse a session key into its component parts.
|
||||
|
||||
Session keys follow the format
|
||||
``agent:main:{platform}:{chat_type}:{chat_id}[:{thread_id}[:{user_id}]]``.
|
||||
``agent:main:{platform}:{chat_type}:{chat_id}[:{extra}...]``.
|
||||
Returns a dict with ``platform``, ``chat_type``, ``chat_id``, and
|
||||
optionally ``thread_id`` keys, or None if the key doesn't match.
|
||||
|
||||
The 6th element is only returned as ``thread_id`` for chat types where
|
||||
it is unambiguous (``dm`` and ``thread``). For group/channel sessions
|
||||
the suffix may be a user_id (per-user isolation) rather than a
|
||||
thread_id, so we leave ``thread_id`` out to avoid mis-routing.
|
||||
"""
|
||||
parts = session_key.split(":")
|
||||
if len(parts) >= 5 and parts[0] == "agent" and parts[1] == "main":
|
||||
@@ -497,7 +502,7 @@ def _parse_session_key(session_key: str) -> "dict | None":
|
||||
"chat_type": parts[3],
|
||||
"chat_id": parts[4],
|
||||
}
|
||||
if len(parts) > 5:
|
||||
if len(parts) > 5 and parts[3] in ("dm", "thread"):
|
||||
result["thread_id"] = parts[5]
|
||||
return result
|
||||
return None
|
||||
|
||||
Reference in New Issue
Block a user