mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-06-09 08:21:50 +00:00
feat(hooks): expose thread_id and chat_type in agent:start/end context (#41672)
Adds thread_id and chat_type to the agent:start/end plugin hook context (via getattr with safe defaults; both are real `source` attrs already used in gateway/run.py). agent:end inherits them via **hook_ctx. Purely additive — no prompt/history mutation. Documents the full ctx dict in hooks.py. Co-authored-by: SNooZyy2 <SNooZyy2@users.noreply.github.com>
This commit is contained in:
parent
fa42ac094d
commit
e3b8b6d32c
2 changed files with 19 additions and 0 deletions
|
|
@ -17,6 +17,23 @@ Events:
|
|||
- command:* -- Any slash command executed (wildcard match)
|
||||
|
||||
Errors in hooks are caught and logged but never block the main pipeline.
|
||||
|
||||
Context dict passed to ``agent:start`` / ``agent:end`` handlers:
|
||||
platform -- source platform name (e.g. "telegram", "matrix", "slack")
|
||||
user_id -- platform user id of the sender
|
||||
chat_id -- platform chat id (group/DM identifier)
|
||||
thread_id -- Telegram forum-topic id / thread root id (string; empty
|
||||
when not in a thread / topic)
|
||||
chat_type -- "dm" | "group" | "forum" (empty if unknown)
|
||||
session_id -- Hermes session id
|
||||
message -- inbound message text (truncated to 500 chars)
|
||||
|
||||
``agent:end`` adds:
|
||||
response -- agent response text (truncated to 500 chars)
|
||||
|
||||
Handlers posting a follow-up into the same Telegram forum-topic should
|
||||
include ``message_thread_id=int(thread_id)`` when ``chat_type == "forum"``
|
||||
and ``thread_id`` is non-empty.
|
||||
"""
|
||||
|
||||
import asyncio
|
||||
|
|
|
|||
|
|
@ -9552,6 +9552,8 @@ class GatewayRunner:
|
|||
"platform": source.platform.value if source.platform else "",
|
||||
"user_id": source.user_id,
|
||||
"chat_id": source.chat_id or "",
|
||||
"thread_id": str(getattr(source, "thread_id", None)) if getattr(source, "thread_id", None) else "",
|
||||
"chat_type": getattr(source, "chat_type", "") or "",
|
||||
"session_id": session_entry.session_id,
|
||||
"message": message_text[:500],
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue