Repository navigation
Description
Parked: not to be started until one of the conditions under "Reopen when" holds. The owner chose Delegate on 2026-11-23 and parked it again the same day, because a host firing steers into a running turn where courier_later waits behind it (decision).
The change
OpenCode 2.3.1 turned its experimental schedules into automations (anomalyco/opencode#64160). An automation can send a prompt to any session of the project at a time, on an interval or on a cron, with text the caller chooses, and can be listed per session and deleted by id. That covers what courier_later and courier_cancel do.
Since OpenCode 2.4.0 automations are no flag (anomalyco/opencode#65296): they are on unless the config says "automations": false (Config.latest(entries, "automations") ?? true in packages/core/src/automation.ts). Since 2.4.1 the plugin API has a domain for them (anomalyco/opencode#65747): ctx.experimental.automation.create, .list and .delete, for Promise and Effect plugins.
Evidence, on OpenCode 2.3.2
Through the HTTP API (/api/experimental/automation), with the scripted model:
- With the flag off, which is the default in a release build, create is refused with 403.
- With
experimental.automations: true, a prompt to an idle session arrived 0.3 s after its due time and woke it. - The prompt text is delivered verbatim, so courier's
<courier from=… scheduled=…>envelope fits. - Any session of the project can be the target, a spawned one included, with no creating session.
- Deleting before the due time stops the delivery.
- One that fell due while the server was down was delivered after the restart.
With a real model, a local prototype (spawned sessions allowed the automation tools, the brief asking for a check-in through automation_create, a pending automation counted as waiting), one run each way of two children that wait a minute, run a command and report:
courier_later |
automations | |
|---|---|---|
| Both children waited, woke and reported | yes | yes |
| Wake after the one-minute mark | 13 s late | within 0.1 s |
| Model requests | 19 | 23 |
| Input / output tokens | 37k / 1.6k | 63k / 3.5k |
| To schedule | one tool call | a search, then automation_create inside Code Mode |
With both mechanisms registered, every session chose courier_later; automations were used only once it was hidden.
What blocks it, at OpenCode 2.4.1
Read in @opencode/[email protected] and the host's source at tag v2.4.1.
- A firing is always a steer.
admitinpackages/core/src/automation.tscallssessions.promptwithdelivery: "steer"as a literal, andAutomation.Request(packages/schema/src/automation.ts) has no field for it.courier_latersendssession.syntheticwithdelivery: "queue"(src/scheduling/later.ts), so its message waits behind a running turn. Thecodeaction can only call Code Mode tools and itssendsteers too;shellruns a command. - A plugin cannot switch a waiting item to
queue. The host hasSessionInbox.steerand.queue(packages/core/src/session/inbox.ts), but the plugin'sSessionDomain(@opencode/plugin,dist/promise/session.d.ts) exposes neither, and an item may be promoted at the next step before a plugin sees itsenqueued. - No automation events. The plugin API has
create,listanddeleteonly (dist/promise/plugin.d.ts), soisScheduledwould readlist, which filters by creating session or directory, not by target (packages/protocol/src/groups/automation.ts). - A firing is a
useritem whose only metadata isautomation(admit,packages/core/src/automation.ts). Courier's own is asyntheticitem withsource: "courier",from,scheduled,scheduledAtand a description, whichkindOfinsrc/tree/events.tsreads to tell a session's own check-in after its report from a new prompt. - Turning automations off after scheduling strands the entry. The row stays and is retried hourly (
runDue,DISABLED_RETRY), whilelistanddeletefail withAutomation.DisabledError(findVisibleandlistinpackages/core/src/automation.ts; HTTP 403 inpackages/server/src/handlers/automation.ts), so courier can neither see nor cancel it.createfails the same way, so courier's scheduler has to stay as the fallback; if it delivers the entry on time, the host delivers it again once automations are back on, and the host's loop starts with the server (packages/server/src/process.ts), before plugins load. - The API is under
experimental: "may change without compatibility guarantees" (packages/protocol/src/groups/automation.ts). - Smaller: an
attrigger must be strictly in the future (firstDue), sodelayMinutes: 0would stay on courier's path; a firedatautomation stays in the table asdone(advance); a missing target session pauses the automation (pauseWith). - The tools are
automation_createand the rest in their ownautomationnamespace, Code Mode tools (packages/core/src/tool/plugin/automation.ts);CHILD_RULESinsrc/tree/spawn.tsdeniesautomation_*.
What delegation would and would not gain
Would gain:
- Delivery after a restart without waiting for the project's first use, since the host's loop runs from server start.
- The host's deterministic message id (
msg_<automation>_<run>) and SQLite lease: no double delivery on a crash or with two servers. - The message shows in the person's automation list.
Would not gain:
- Timing:
courier_laterdelivers within about a second of its time (Deliver a courier_later message within about a second of its time #660), so the 13 s in the table above is gone. - Less code: the fallback keeps all of
src/scheduling/, and the host path adds a mapping from automation ids tolater/records, the clean-up ofdonerows and the reconciliation after automations are turned off and on.
Reopen when
- OpenCode lets a caller choose
queuefor an automation's prompt action, or @opencode/pluginsends automation events.
courier_later is the only courier message sent with queue; every other one is steered. Switching it to steer, a behaviour change of its own with a model-facing string, would also remove the difference.
Options, once reopened
- Delegate (recommended): keep
courier_laterandcourier_cancelas they are for models, and schedule through the host. No change to the tool surface. - Deprecate: keep the tools, say in their descriptions and the reference that the host does it, and remove them in a later minor release.
- Remove: drop them. A breaking change to the tool surface.
Done when (Delegate)
src/scheduling/schedules, lists and cancels through the host, andisScheduledreads the host's pending automations, soWaitsandcourier_stopbehave as now.CHILD_RULESinsrc/tree/spawn.tsandtypedTextinsrc/tree/relay.tsare revisited: what a spawned session may still not do itself, and which firings are courier's own.- The
later/storage keys (src/scheduling/,test/later.test.ts) get a migration, or a reason for none in architecture.md's Storage table. - Unit tests, the e2e
later,schedules,own-checkinandwakegroups,e2e/two-servers.sh,docs/reference.md("Scheduled messages"),docs/maintainers/architecture.md("courier_later's scheduler") anddocs/maintainers/plugin-api-notes.md("OpenCode's automations") are updated.
Activity
ivopogace commentedon Nov 23, 2026
Both conditions under "Reopen when" hold on OpenCode 2.4.1, the target of the pin PR #664:
"automations": false(Config.latest(entries, "automations") ?? trueinpackages/core/src/automation.ts).experimental.automationsand theschedulesalias are gone frompackages/schema/src/config/flag.ts.ctx.experimental.automation.create,.listand.delete, for Promise and Effect plugins.What still stands from "What blocks it", read in the source at
v2.4.1:isScheduledwould readautomation.list.delivery: "steer",metadata.automation), so it goes into a running turn wherecourier_laterwaits behind it.createthen fails withAutomation.DisabledError. A Delegate needs courier's own scheduler as the fallback for that case, orcourier_laterfails there.automation_createand the rest in their ownautomationnamespace; the pin PR movesCHILD_RULEStoautomation_*.The options are the ones in the issue body. Recommendation: Delegate, keeping courier's scheduler for hosts with automations off, so the tool surface does not change. This waits for the owner's choice here and for #664 to merge.
[-]OpenCode 2.3.2: build courier_later on OpenCode's automations[/-][+]OpenCode 2.4.1: build courier_later on OpenCode's automations[/+]ivopogace commentedon Nov 23, 2026
Decision (owner, 2026-11-23): keep courier's own scheduler. Delegate is not built; this issue is parked again.
Why
Read in
@opencode/[email protected]and the host's source atv2.4.1:admitinpackages/core/src/automation.tscallssessions.promptwithdelivery: "steer"as a literal, andAutomation.Requesthas no field for it. The host can switch a waiting item betweensteerandqueue(packages/core/src/session/inbox.ts), but the plugin'sSessionDomainexposes neither.courier_latersendssession.syntheticwithdelivery: "queue". Thecodeaction can only call Code Mode tools and itssendsteers too;shellruns a command.useritem whose only metadata isautomation. Courier's own is asyntheticitem withsource: "courier",from,scheduled,scheduledAtand a description, whichkindOfinsrc/tree/events.tsreads to tell a session's own check-in after its report from a new prompt.listanddeletefail withAutomation.DisabledError, so courier could neither see nor cancel it. If the fallback delivered it on time, the host would deliver it again once automations are back on, and the host's loop starts with the server (packages/server/src/process.ts), before plugins load.attrigger must be strictly in the future, sodelayMinutes: 0would stay on courier's path. A firedatautomation stays in the table asdone. A missing target session pauses the automation.listfilters by creating session or directory, not by target. The API is underexperimental.What delegation would gain
The timing gain measured above is gone:
courier_laterdelivers within about a second of its time (#660). Delegation would remove no code, since the fallback keeps all ofsrc/scheduling/and the host path adds the id mapping, the clean-up ofdonerows and the off/on reconciliation.Reopen when
queuefor a prompt action, orsteerandqueue.Apart from this issue:
courier_lateris the only courier message sent withqueue; every other one is steered. Switching it tosteerwould be a behaviour change of its own, with a model-facing string and a real-model run, and would make a later delegation a refactor.