docs: add scheduling tool design document#3
Merged
Conversation
Captures approved design for LLM-first scheduling system: - SQLite-persisted tasks (one-shot + recurring) - Full agentic loop triggered at fire time - 3 new tools: schedule_task, list_scheduled_tasks, cancel_scheduled_task - Startup restore for tasks surviving bot restarts https://claude.ai/code/session_01L3BnKJ3tuWknFV2bnCocQq
11-task TDD plan covering: DB migration, ScheduledTaskStore CRUD, Scheduler API extension, Arc<Bot> threading, Agent struct changes (Arc::new_cyclic for Weak<Agent>), all 3 tool handlers, and startup restore logic. Includes exact code, test cases, and commit messages. https://claude.ai/code/session_01L3BnKJ3tuWknFV2bnCocQq
…AULT to created_at
Implements the ScheduledTaskStore CRUD layer over the scheduled_tasks table, using the shared Arc<Mutex<Connection>> from MemoryStore. Includes create, list_active_for_user, list_all_active, set_status, update_scheduler_job_id, and update_next_run_at methods, plus a private query_tasks helper to avoid double-locking. All four unit tests pass. https://claude.ai/code/session_01L3BnKJ3tuWknFV2bnCocQq
…eduler registration - Add user_id and chat_id params to execute_tool and thread them from process_message - Implement schedule_task handler: validates trigger, persists to DB, registers with scheduler - Implement list_scheduled_tasks and cancel_scheduled_task handlers - Add ScheduledJobRequest type and job_tx channel to break the Send circularity: fire closures dispatch to an mpsc channel; a background runner in main.rs calls process_message and sends replies via Telegram, avoiding the !Send future issue with McpManager - Add parse_one_shot_delay (ISO 8601 datetime -> Duration) and validate_cron_expr (6-field cron validation) as free functions - Add pub split_response_chunks helper used by both agent and main.rs background runner - Add 5 unit tests for parse_one_shot_delay and validate_cron_expr - All tests pass, clippy clean, fmt clean https://claude.ai/code/session_01L3BnKJ3tuWknFV2bnCocQq
…id failure - Add ScheduledTaskStore::get_by_id to fetch a task by its primary key - Fix cancel_scheduled_task to look up scheduler_job_id and call scheduler.remove_job() before marking DB status as cancelled, so recurring tasks stop firing after cancellation - Replace let _ = update_scheduler_job_id(...) with if let Err to log failures instead of silently swallowing them - Fix split_response_chunks to return vec![] for empty input instead of vec![""], preventing empty Telegram API messages - Replace unwrap_or(0) on chat_id parse with proper error handling that logs and continues rather than sending to chat id 0 - Skip empty chunks in the background runner send loop https://claude.ai/code/session_01L3BnKJ3tuWknFV2bnCocQq
Re-register all tasks with status='active' into the scheduler when the bot starts, so scheduled tasks survive restarts. One-shot tasks whose trigger time has passed are marked 'completed' and skipped. https://claude.ai/code/session_01L3BnKJ3tuWknFV2bnCocQq
chinkan
added a commit
that referenced
this pull request
Feb 20, 2026
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.
Captures approved design for LLM-first scheduling system:
https://claude.ai/code/session_01L3BnKJ3tuWknFV2bnCocQq