Skip to content

feat(cron): mirror deliveries into chat sessions - #40211

Closed
ammichael wants to merge 1 commit into
NousResearch:mainfrom
ammichael:fix/cron-delivery-session-mirror-local
Closed

feat(cron): mirror deliveries into chat sessions#40211
ammichael wants to merge 1 commit into
NousResearch:mainfrom
ammichael:fix/cron-delivery-session-mirror-local

Conversation

@ammichael

Copy link
Copy Markdown

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:

  • default remains false, preserving current behavior for noisy cron jobs;
  • cron.mirror_to_session: true enables it globally;
  • individual jobs can override with mirror_to_session: true/false;
  • failed deliveries and local-only jobs are not mirrored;
  • mirroring failures are non-fatal and only logged at debug level.

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.py
  • git diff --check

Copilot AI review requested due to automatic review settings June 6, 2026 00:49

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_session default 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.

Comment thread cron/scheduler.py
Comment on lines +843 to +855
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)
Comment thread cron/scheduler.py
Comment on lines +890 to +902
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)
Comment thread cron/scheduler.py
Comment on lines +843 to +855
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)
Comment thread cron/scheduler.py
Comment on lines +890 to +902
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)
Comment thread cron/scheduler.py
Comment on lines +709 to +714
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 tonydwb left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@alt-glitch alt-glitch added type/feature New feature or request P3 Low — cosmetic, nice to have comp/cron Cron scheduler and job management labels Jun 6, 2026
@teknium1

Copy link
Copy Markdown
Contributor

Thanks for the focused cron-session mirroring proposal. This is already implemented on current main with stronger safety handling, so this automated hermes-sweeper review is closing it as superseded.

  • 1b181724fae7799cf45dec3aca03ac44063175e7 added opt-in cron delivery mirroring, global cron.mirror_delivery, and per-job attach_to_session.
  • cron/scheduler.py:584 resolves the default-off global/per-job gate; cron/scheduler.py:1470 through cron/scheduler.py:1969 mirrors only after a successful delivery.
  • c06ceb3232f2df301077db891c4b416f3326efa8 restricts mirroring to the origin conversation, avoiding fan-out and unrelated-chat transcript contamination.
  • b177d4ee4891aeb3bf8a908f6e5def846a55c180 made cron mirrors labelled user turns (cron/scheduler.py:684) to preserve strict role alternation; coverage is in tests/cron/test_scheduler.py:4165.
  • The implementation is included by tag v2026.7.1.

@teknium1 teknium1 closed this Jul 14, 2026
@teknium1 teknium1 added the sweeper:implemented-on-main Sweeper: behavior already present on current main label Jul 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/cron Cron scheduler and job management P3 Low — cosmetic, nice to have sweeper:implemented-on-main Sweeper: behavior already present on current main type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants