mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-08 03:01:47 +00:00
feat(session): add guild_id/parent_chat_id/message_id to SessionSource
Groundwork for injecting raw platform identifiers into the agent's system prompt. Currently only `thread_id` is exposed as a raw ID — callers in a Discord thread had to guess `channel_id == thread_id` (which happens to work because threads are channels in Discord's REST API) and had no way to reference the parent channel, guild, or the triggering message. Adds three optional fields: - `guild_id` — Discord guild / Slack workspace / Matrix server scope - `parent_chat_id` — parent channel when chat_id refers to a thread - `message_id` — ID of the triggering message (pin/reply/react) Extends `BasePlatformAdapter.build_source()` to accept + forward them and teaches `to_dict`/`from_dict` to serialize them. Behaviourally a no-op: nothing reads the fields yet and they default to None.
This commit is contained in:
parent
ff9b0528a2
commit
0eb85906b0
2 changed files with 19 additions and 1 deletions
|
|
@ -2440,6 +2440,9 @@ class BasePlatformAdapter(ABC):
|
||||||
user_id_alt: Optional[str] = None,
|
user_id_alt: Optional[str] = None,
|
||||||
chat_id_alt: Optional[str] = None,
|
chat_id_alt: Optional[str] = None,
|
||||||
is_bot: bool = False,
|
is_bot: bool = False,
|
||||||
|
guild_id: Optional[str] = None,
|
||||||
|
parent_chat_id: Optional[str] = None,
|
||||||
|
message_id: Optional[str] = None,
|
||||||
) -> SessionSource:
|
) -> SessionSource:
|
||||||
"""Helper to build a SessionSource for this platform."""
|
"""Helper to build a SessionSource for this platform."""
|
||||||
# Normalize empty topic to None
|
# Normalize empty topic to None
|
||||||
|
|
@ -2457,6 +2460,9 @@ class BasePlatformAdapter(ABC):
|
||||||
user_id_alt=user_id_alt,
|
user_id_alt=user_id_alt,
|
||||||
chat_id_alt=chat_id_alt,
|
chat_id_alt=chat_id_alt,
|
||||||
is_bot=is_bot,
|
is_bot=is_bot,
|
||||||
|
guild_id=str(guild_id) if guild_id else None,
|
||||||
|
parent_chat_id=str(parent_chat_id) if parent_chat_id else None,
|
||||||
|
message_id=str(message_id) if message_id else None,
|
||||||
)
|
)
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
|
|
|
||||||
|
|
@ -83,6 +83,9 @@ class SessionSource:
|
||||||
user_id_alt: Optional[str] = None # Platform-specific stable alt ID (Signal UUID, Feishu union_id)
|
user_id_alt: Optional[str] = None # Platform-specific stable alt ID (Signal UUID, Feishu union_id)
|
||||||
chat_id_alt: Optional[str] = None # Signal group internal ID
|
chat_id_alt: Optional[str] = None # Signal group internal ID
|
||||||
is_bot: bool = False # True when the message author is a bot/webhook (Discord)
|
is_bot: bool = False # True when the message author is a bot/webhook (Discord)
|
||||||
|
guild_id: Optional[str] = None # Discord guild / Slack workspace / Matrix server scope
|
||||||
|
parent_chat_id: Optional[str] = None # Parent channel when chat_id refers to a thread
|
||||||
|
message_id: Optional[str] = None # ID of the triggering message (for pin/reply/react)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def description(self) -> str:
|
def description(self) -> str:
|
||||||
|
|
@ -120,6 +123,12 @@ class SessionSource:
|
||||||
d["user_id_alt"] = self.user_id_alt
|
d["user_id_alt"] = self.user_id_alt
|
||||||
if self.chat_id_alt:
|
if self.chat_id_alt:
|
||||||
d["chat_id_alt"] = self.chat_id_alt
|
d["chat_id_alt"] = self.chat_id_alt
|
||||||
|
if self.guild_id:
|
||||||
|
d["guild_id"] = self.guild_id
|
||||||
|
if self.parent_chat_id:
|
||||||
|
d["parent_chat_id"] = self.parent_chat_id
|
||||||
|
if self.message_id:
|
||||||
|
d["message_id"] = self.message_id
|
||||||
return d
|
return d
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
|
@ -135,6 +144,9 @@ class SessionSource:
|
||||||
chat_topic=data.get("chat_topic"),
|
chat_topic=data.get("chat_topic"),
|
||||||
user_id_alt=data.get("user_id_alt"),
|
user_id_alt=data.get("user_id_alt"),
|
||||||
chat_id_alt=data.get("chat_id_alt"),
|
chat_id_alt=data.get("chat_id_alt"),
|
||||||
|
guild_id=data.get("guild_id"),
|
||||||
|
parent_chat_id=data.get("parent_chat_id"),
|
||||||
|
message_id=data.get("message_id"),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue