feat(cron): mirror deliveries into chat sessions - #40211
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds an opt-in “session mirroring” feature for cron deliveries so that successfully delivered cron outputs can (optionally) be appended into the target gateway session transcript, with documentation and tests covering default/override behavior.
Changes:
- Document cron “Session mirroring” behavior and configuration (
cron.mirror_to_session+ per-job override). - Add
cron.mirror_to_sessiondefault to the CLI-managed config template. - Implement mirroring in cron delivery flow and expand scheduler tests for default/global/job override cases.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| website/docs/user-guide/features/cron.md | Documents the new session mirroring behavior and configuration knobs. |
| hermes_cli/config.py | Adds cron.mirror_to_session default setting to generated config. |
| cron/scheduler.py | Implements optional mirroring into gateway session transcript after successful delivery. |
| tests/cron/test_scheduler.py | Adds/updates tests verifying default off, global enable, and per-job override. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if mirror_to_session_enabled: | ||
| try: | ||
| from gateway.mirror import mirror_to_session | ||
|
|
||
| mirror_to_session( | ||
| platform_name, | ||
| chat_id, | ||
| content, | ||
| source_label="cron", | ||
| thread_id=thread_id, | ||
| ) | ||
| except Exception as e: | ||
| logger.debug("Job '%s': cron delivery mirror failed: %s", job["id"], e) |
| if mirror_to_session_enabled: | ||
| try: | ||
| from gateway.mirror import mirror_to_session | ||
|
|
||
| mirror_to_session( | ||
| platform_name, | ||
| chat_id, | ||
| content, | ||
| source_label="cron", | ||
| thread_id=thread_id, | ||
| ) | ||
| except Exception as e: | ||
| logger.debug("Job '%s': cron delivery mirror failed: %s", job["id"], e) |
| if mirror_to_session_enabled: | ||
| try: | ||
| from gateway.mirror import mirror_to_session | ||
|
|
||
| mirror_to_session( | ||
| platform_name, | ||
| chat_id, | ||
| content, | ||
| source_label="cron", | ||
| thread_id=thread_id, | ||
| ) | ||
| except Exception as e: | ||
| logger.debug("Job '%s': cron delivery mirror failed: %s", job["id"], e) |
| if mirror_to_session_enabled: | ||
| try: | ||
| from gateway.mirror import mirror_to_session | ||
|
|
||
| mirror_to_session( | ||
| platform_name, | ||
| chat_id, | ||
| content, | ||
| source_label="cron", | ||
| thread_id=thread_id, | ||
| ) | ||
| except Exception as e: | ||
| logger.debug("Job '%s': cron delivery mirror failed: %s", job["id"], e) |
| mirror_to_session_enabled = False | ||
| try: | ||
| user_cfg = load_config() | ||
| wrap_response = user_cfg.get("cron", {}).get("wrap_response", True) | ||
| cron_cfg = user_cfg.get("cron", {}) if isinstance(user_cfg, dict) else {} | ||
| wrap_response = cron_cfg.get("wrap_response", True) | ||
| mirror_to_session_enabled = bool(cron_cfg.get("mirror_to_session", False)) |
tonydwb
left a comment
There was a problem hiding this comment.
Reasonable feature addition: optional session mirroring for cron deliveries. Includes tests covering default-off, global-on, and per-job override. Note: an existing COMMENTED review is present from copilot-pull-request-reviewer — this is not a formal decision, so I am adding evidence rather than overwriting it.
|
Thanks for the focused cron-session mirroring proposal. This is already implemented on current
|
Summary
Adds opt-in mirroring for successfully delivered cron responses into the target gateway session transcript, so follow-up replies in the same chat can refer to the cron message without requiring manual
session_search.This is related to existing proposals such as #34631, #21441, #10650, and #37073. This version keeps the behavior conservative:
false, preserving current behavior for noisy cron jobs;cron.mirror_to_session: trueenables it globally;mirror_to_session: true/false;Why
Cron jobs run in isolated
cron_*sessions, then deliver their final text via the gateway adapter. The human sees the cron message in WhatsApp/Telegram/etc., but the next normal gateway turn does not have that delivered message in its chat transcript. That makes Hermes look like it forgot a message it just sent.Tests
python -m pytest tests/cron/test_scheduler.py -q -o 'addopts='python -m py_compile cron/scheduler.py hermes_cli/config.pygit diff --check