opencode icon indicating copy to clipboard operation
opencode copied to clipboard

[FEATURE]: change an automation's action without recreating it (keep its ID and run count)

Open pascalandr opened this issue 2 weeks ago • 2 comments

Feature hasn't been suggested before.

  • [x] I have verified this feature I'm about to request hasn't been suggested before.

Describe the enhancement you want to request

An automation's action can only be set when it is created. Automation.Interface has create/list/get/pause/resume/remove (packages/core/src/automation.ts:95-113), the HTTP API exposes only those routes (packages/protocol/src/groups/automation.ts), and action is written once, at insert (automation.ts:1060).

Use case: a plugin creates timer automations whose prompt action wakes a technical session, and it records each wake by its native identity (aut_ ID, msg_<aut>_<run>). Code actions, available since 2.3, would let it drop the model turn entirely: the program calls a plugin tool, which already receives that identity. The plugin cannot move its existing automations to a code action, though. Removing them and creating new ones changes the ID and resets run_count, and the plugin uses both to deduplicate wakes across restarts. So the old path has to stay as long as any old automation exists.

Proposal: automation.update(id, { action }) (with POST /api/experimental/automation/:automationID/update or PATCH), which:

  • keeps id, run_count, next_due_at, state and the status;
  • for a code action, re-runs AutomationCode.authorize from the owning session, as create does;
  • applies to an idle automation only. A run in progress keeps the action it started with, and settle's run_count check already rejects a stale write.

Updating name, trigger or expires the same way would be a natural extension, but the action alone covers this case.

pascalandr avatar Nov 19 '26 17:11 pascalandr

Thanks for the detailed request, @pascalandr!

To restate it: you'd like a way to change an existing automation's action, for example from a prompt action to a code action, without removing it and creating it again. That way it keeps its ID, run_count, next_due_at and state, and a new code action would be re-authorized from the owning session the same way create does it. In the code I read, the automation service has create, list, get, pause, resume and remove, but no update, so this would need a change in core and can't be done from a plugin.

Related work on automations:

  • #64160: the merged PR that added code actions
  • #60650, #60627, #60628: open PRs for automations (renaming, the TUI modal, the desktop view)

Maintainers will consider this request.

opencodejr[bot] avatar Nov 19 '26 17:11 opencodejr[bot]

Related: #65097 asks for an optional model stored on an automation, used for its run session ahead of agent.model ?? owner.model. If this update path lands, it would be the natural place to change a stored model too, so a person can switch a scheduled task to another model without recreating it and without losing its ID and run count.

Skeptomenos avatar Nov 20 '26 07:11 Skeptomenos