Skip to content

docs: add scheduling tool design document#3

Merged
chinkan merged 14 commits intomainfrom
claude/rustbot-scheduling-tool-nLhrR
Feb 18, 2026
Merged

docs: add scheduling tool design document#3
chinkan merged 14 commits intomainfrom
claude/rustbot-scheduling-tool-nLhrR

Conversation

@chinkan
Copy link
Copy Markdown
Owner

@chinkan chinkan commented Feb 18, 2026

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

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
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 chinkan merged commit a6a1f40 into main Feb 18, 2026
5 checks passed
@chinkan chinkan deleted the claude/rustbot-scheduling-tool-nLhrR branch February 18, 2026 09:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants