GeezerVison is showing github.com — [FEATURE]: /schedule — run recurring background tasks (cron-like routines) · Issue #41906 · anomalyco/opencode
[FEATURE]: /schedule — run recurring background tasks (cron-like routines) #41906DescriptionRequested feature
Add a /schedule slash command (inspired by Claude Code's /schedule) to run recurring, background, non-interactive tasks on a timer — e.g. periodic CI/CD sweeps, lint/typecheck runs, or repo reviews.
Why
Today opencode has an internal BackgroundJob service (packages/core/src/background-job.ts, packages/opencode/src/background/job.ts) used for things like session compaction and summary pruning, but there is no user-facing way to schedule a recurring job from the TUI and no cron-like cadence. Automations currently require external orchestrators (n8n, scripts).
Proposed behavior
/schedule every 5m <task> or /schedule cron '*/5 * * * *' <task> registers a recurring background routine.
- Jobs appear in a scheduler list (pause/resume/cancel), run detached from the active session, and surface results via the existing notifications/background job UI.
- Reuse/extend
BackgroundJob.Service (packages/opencode/src/background/job.ts) with a persistence + scheduling layer so jobs survive across sessions.
Benefits
- In-terminal recurring automation without external tooling.
- Consistent with the existing background job infrastructure.
Reacted by Mehdi Memar, Paolo D'Elia, HanlinW, amnesia and Keios Reacted by Keios Activityyanxingyu17 commented on Sep 8, 2026 We have been prototyping this use case locally and would like to discuss the design before opening a PR.
Our prototype currently supports:
- persistent local SQLite-backed automations for once, interval, and five-field cron schedules;
- timezone-aware scheduling, restart recovery, missed-run policies, retries/backoff, stale-run recovery, and run history;
- an isolated Agent execution path;
- a direct, explicitly allowlisted command path for lightweight deterministic jobs, which does not create a Session;
- CLI management for create/list/show/run/pause/resume/history/remove.
We validated the prototype with Core automation tests, OpenCode executor/CLI tests, typechecks, migration checks, a Linux x64 build, and a real two-minute command-mode run. The command-mode run produced two Feishu messages 120.683 seconds apart and created no Sessions.
Before proposing an upstream implementation, we would appreciate guidance on a few architectural questions:
- Should this extend the existing BackgroundJob.Service rather than introduce a separate scheduler service?
- Should scheduling be owned by
serve, web, a separate daemon mode, or an opt-in experimental process?
- What ownership/fencing semantics are expected when multiple server processes share the local database?
- Would a local persistent scheduler belong in core, or should the first implementation live as an official plugin/companion service?
We have also reviewed the related scheduling discussions and PRs (#41907, #18001, and #44191). We are happy to adapt the prototype to the preferred direction rather than submit a large, pre-decided PR. Reacted by Keios Reacted by Keios danibauti94 commented on Oct 7, 2026 Thanks for proposing this. I would like to add a Web UI / Tasks experience to the scope, similar to Codex Tasks or Claude Code scheduled tasks, so schedules are manageable without relying on the TUI.
For a self-hosted setup, it would be especially useful if tasks could be created and managed in the Web UI (prompt, agent, workspace, and schedule), then executed server-side by an existing OpenCode Serve instance. The browser could be closed and the task would continue to run as long as that server is available; schedules and run history should survive restarts.
A useful first-class task lifecycle would include one-shot, interval, and cron schedules; Run now, pause, resume, and delete actions; per-run status, timestamps, output/logs, and failure details; and notifications when a run completes or fails. Each run should reuse the selected workspace's existing OpenCode configuration, agents, MCP servers, skills, and plugins, rather than requiring a separate integration or external orchestrator.
This would make the existing scheduling/background-job proposal useful for ongoing homelab maintenance, such as periodically checking and updating self-hosted documentation. The TUI can remain a management surface too, but a Web UI is important for users primarily running OpenCode through Serve. opencodejr commented on Oct 28, 2026 Thanks for the detailed request, @afonsoft! You're asking for a /schedule command that runs prompts again and again in the background, on an interval or a cron expression, with schedules that persist and can be paused, resumed or cancelled.
Maintainers will consider it. Some related work is already in progress:
- feat(core): scheduled tasks storage and time triggers (experimental) #59401 (merged): stores schedules (once, at a set time, every N minutes, or on a cron) and wakes a session to fire them. It only runs when the experimental
experimental.schedules flag is on.
- feat(core): schedule prompts from agents, /schedule and the experimental API #59457 (open): builds on feat(core): scheduled tasks storage and time triggers (experimental) #59401 and adds a
/schedule command, agent tools to create, list, pause, resume and delete schedules, and an experimental API.
- feat(core): add agent-callable session schedules #52103 (open): an earlier prototype of schedules the agent can create in a session.
- feat(core): add /loop command #54416 (open): a
/loop command that repeats a prompt at a fixed interval.
- Proposal: background subagents, monitors, cron, worktree isolation #49842: a broader proposal that includes cron and background monitors.
You can follow those PRs to see how this develops.
Reacted by Keios Reacted by Keios neriousy commented on Nov 12, 2026 Thanks for the suggestion. This isn't something we plan to build, so closing to keep the tracker focused.
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|