You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[FEATURE]: /schedule — run recurring background tasks (cron-like routines) #41906
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 and amnesia
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.
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.
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:
Activity
yanxingyu17 commentedon 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:
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:
serve,web, a separate daemon mode, or an opt-in experimental process?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.
danibauti94 commentedon 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 commentedon Oct 28, 2026
Thanks for the detailed request, @afonsoft! You're asking for a
/schedulecommand 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:
experimental.schedulesflag is on./schedulecommand, agent tools to create, list, pause, resume and delete schedules, and an experimental API./loopcommand that repeats a prompt at a fixed interval.You can follow those PRs to see how this develops.