OpenCode 2.4.0 Lets AI Agents Run Themselves on Schedules and Events
OpenCode 2.4.0 lets coding agents schedule themselves or react to MCP events, running prompts, shell commands, or Code Mode scripts.
Takeaways
- OpenCode 2.4.0 adds automations that run on time, interval, cron, or pushed MCP events
- Actions can send a prompt, run a shell command, or execute a Code Mode script with MCP tool access
- Automations can target the current session, another session, or a fresh subagent
- Shell timeout behavior changed: commands now move to background instead of being killed
- Image generation tool renamed from experimental_image_generate to generate_image
- Release spans 334 commits and also adds a desktop browser, video generation, and TUI theme
OpenCode 2.4.0 adds experimental automations that run an agent at a scheduled time, on a recurring interval, from a cron expression, or when a Model Context Protocol (MCP) server pushes an event. MCP connects the agent to external tools and data sources, allowing CI systems, issue trackers, and other services to initiate work without waiting for a typed request.
A downstream upgrade diff counts 334 commits between v2.3.2 and v2.4.0. The release also introduces a built-in desktop browser, video generation, and a new terminal interface theme. Automations carry the largest workflow change because they move recurring jobs from interactive sessions into background execution.
From cron to MCP events
OpenCode has renamed its experimental schedules feature to automations while retaining the old schedules flag for compatibility. The user-facing feature uses the automations flag, while the automation endpoints remain available without either flag.
| Component | Available behavior |
|---|---|
| Triggers | One-time schedules, fixed intervals, cron expressions, and pushed MCP events |
| Actions | Send a prompt, run a Code Mode program, or execute a shell command |
| Prompt destination | The creating session, another existing session, or a new subagent |
| Management | The /automation command and automation_* agent tools |
Code Mode programs can call MCP tools, inspect external state, and exit when no action is needed. An interval-based automation could query an issue tracker, detect whether a new issue exists, and send a prompt only when there is work to process. This gate reduces unnecessary model calls and token use.
OpenCode skips an MCP event when its payload exceeds the available prompt space, while keeping the automation active for later events. Sending recurring work to a new subagent also isolates its context from the developer’s interactive session.
Where background runs fit
Scheduled and event-driven execution supports several common development workflows:
- A cron trigger can start a nightly dependency or vulnerability audit.
- A CI event delivered through MCP can launch a triage subagent after a failed build.
- An interval trigger can poll an issue tracker and act only when its state changes.
- A shell action can handle deterministic maintenance without invoking a model.
Teams already connecting OpenCode to CI systems, issue trackers, or operational tools through MCP gain the clearest path to adoption. Automations can replace a small scheduler or event-dispatch service when a time trigger or MCP event already supplies the required signal.
Custom tools need a migration check
Version 2.4.0 also changes several behaviors and identifiers that scripts, plugins, and approval settings may depend on:
| Area | Change | Migration impact |
|---|---|---|
| Shell timeouts | Commands still running when a timeout expires now continue in the background across all builds. A foreground timeout: 0 uses the default 120-second timeout. |
Review scripts that treated a timeout as process termination or used zero for an unlimited foreground run. |
| Image generation | experimental_image_generate has been renamed generate_image. |
Saved “always allow” approvals will request approval once under the new tool name. |
| Session tools | tools.opencode.session_rename and tools.opencode.session_move have moved to tools.opencode.session.rename and tools.opencode.session.move. |
Update Code Mode programs and plugins that reference the old paths. |
| OpenAI WebSockets | GPT models using the Responses API no longer resend the full conversation after free-form tool calls such as execute or patch. |
The fix reduces duplicate token transmission and associated usage costs. |
| Terminal interface | Each run of tool calls and model activity appears in one collapsible activity row. | Long sessions expose less intermediate output while preserving access to execution details. |
Payloads, budgets, and permissions
External systems deliver event triggers through an MCP server, so a raw webhook source needs an MCP adapter. Reliability depends on that server and on payloads fitting within the agent’s prompt capacity. Production deployments should monitor skipped events and keep event bodies narrowly scoped.
Recurring prompt actions consume tokens whenever execution reaches the model. A Code Mode gate can check state first, while a shell action can handle deterministic cases entirely through local tooling. Automations that invoke shell commands or MCP tools should use narrowly scoped credentials because those actions can modify repositories, infrastructure, and external services without an interactive confirmation step.