fix: preserve thread context for cronjob deliver=origin

When a cronjob is created from within a Telegram or Slack thread,
deliver=origin was posting to the parent channel instead of the thread.

Root cause: the gateway never set HERMES_SESSION_THREAD_ID in the
session environment, so cronjob_tools.py could not capture thread_id
into the job's origin metadata — even though the scheduler already
reads origin.get('thread_id').

Fix:
- gateway/run.py: set HERMES_SESSION_THREAD_ID when thread_id is
  present on the session context, and clear it in _clear_session_env
- tools/cronjob_tools.py: read HERMES_SESSION_THREAD_ID into origin

Closes #1219
This commit is contained in:
teyrebaz33
2026-03-14 06:06:44 +03:00
committed by teknium1
parent 77bfa252b9
commit 20f381cfb6
4 changed files with 79 additions and 1 deletions

View File

@@ -72,6 +72,7 @@ def _origin_from_env() -> Optional[Dict[str, str]]:
"platform": origin_platform,
"chat_id": origin_chat_id,
"chat_name": os.getenv("HERMES_SESSION_CHAT_NAME"),
"thread_id": os.getenv("HERMES_SESSION_THREAD_ID"),
}
return None