fix(cron): mirror delivered job replies into chat sessions - #21441
Closed
huangrichao2020 wants to merge 1 commit into
Closed
fix(cron): mirror delivered job replies into chat sessions#21441huangrichao2020 wants to merge 1 commit into
huangrichao2020 wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Mirror successfully delivered cron job replies back into the target chat session.
On a long-running gateway, a scheduled job can deliver a message into Telegram/Matrix/Slack/etc., but the next normal message in that same chat may not have that cron reply in its session transcript. In practice that makes the agent look like it forgot the cronjob it just sent.
This keeps the fix small: after a delivery succeeds, reuse
gateway.mirror.mirror_to_session()withsource_label="cron". Failed deliveries do not write fake history. Media-only deliveries get a compact transcript placeholder so the chat at least remembers that the cronjob sent an attachment.There is a larger draft in the same area (#10650). This PR is intentionally narrower and ready to review: it only covers the production footgun where delivered cron replies are invisible to follow-up chat context.
Validation
uv run --extra dev pytest tests/cron/test_scheduler.py::TestDeliverResultWrapping::test_successful_delivery_mirrors_to_target_session tests/cron/test_scheduler.py::TestDeliverResultWrapping::test_failed_delivery_does_not_mirror_to_target_session tests/cron/test_scheduler.py::TestDeliverResultWrapping::test_origin_delivery_preserves_thread_id -quv run --extra dev python -m py_compile cron/scheduler.pygit diff --check