feat: cron context-inject button for Telegram deliveries - #26206
ryan-prayoga wants to merge 1 commit into
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 "context inject" feature for cron job deliveries on Telegram: when enabled, the delivery message includes inline buttons that let the user push the cron output into the active session (or open a new session) so the agent can react to it.
Changes:
- New
offer_context_injectflag plumbed throughcronjobtool,create_job, and persisted on the job record. - Token-keyed in-memory
ci_storeincron/scheduler.pywith 24h TTL, populated in_deliver_resultand consumed by the Telegram callback handler. - Telegram adapter attaches an
InlineKeyboardMarkupto the last delivery chunk and handles newci:inject:*/ci:new:*callbacks;mirror_to_sessiongains aroleparameter and a newhas_active_sessionhelper.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| tools/cronjob_tools.py | Exposes offer_context_inject arg in the unified cronjob tool and its schema. |
| cron/jobs.py | Persists the new flag on the job record via create_job. |
| cron/scheduler.py | Adds the _ci_store / ci_store_pop token registry and stores the cron output on Telegram delivery. |
| gateway/mirror.py | Adds role parameter and has_active_session helper. |
| gateway/platforms/telegram.py | Builds the inline keyboard on the last chunk and handles ci:* callbacks. |
| tests/cron/test_cron_context_inject.py | Tests for store, flag plumbing, mirror role, and has_active_session. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Add offer_context_inject flag to cron jobs. When True and deliver targets Telegram, the delivery message includes two inline buttons: - 📌 Tambahkan ke sesi ini — injects cron output into the active session as a user message so the agent can respond to it - 💬 Mulai sesi baru — seeds a fresh session with the output If no active session exists, inject falls back to new-session behavior automatically. Token expires after 24 h. Changes: - cron/jobs.py: offer_context_inject field in create_job() - cron/scheduler.py: _ci_store (in-memory, TTL 24h), inject cron_context_inject_token into Telegram delivery metadata - gateway/mirror.py: has_active_session() helper, role param in mirror_to_session() - gateway/platforms/telegram.py: InlineKeyboardMarkup on last chunk, ci:inject/ci:new callback handler - tools/cronjob_tools.py: offer_context_inject in schema, signature, and handler lambda
f6c425e to
18eba79
Compare
|
Thanks for the contribution. The cron-delivery follow-up workflow is now implemented on
This is an automated hermes-sweeper review. |
Summary
Add
offer_context_injectflag to cron jobs. WhenTrueand deliver targets Telegram, the delivery message includes two inline buttons:usermessage so the agent can respond to itIf no active session exists, the inject button falls back to new-session behavior automatically. Token expires after 24 h.
Changes
cron/jobs.py—offer_context_injectfield increate_job()cron/scheduler.py—_ci_store(in-memory, TTL 24 h),ci_store_pop(), injectcron_context_inject_tokeninto Telegram delivery metadatagateway/mirror.py—has_active_session()helper,roleparam inmirror_to_session()gateway/platforms/telegram.py—InlineKeyboardMarkupon last chunk,ci:inject/ci:newcallback handlertools/cronjob_tools.py—offer_context_injectin schema, signature, and handler lambdaTesting
tests/cron/test_cron_context_inject.pycovering ci_store round-trip, TTL expiry, flag persistence, mirror role param, and has_active_session helperNotes