opencode icon indicating copy to clipboard operation
opencode copied to clipboard

ACP: an automation's run in an idle session never reaches the ACP client

Open roidayan1 opened this issue 6 days ago • 2 comments

OpenCode 2.4.2, opencode acp.

A prompt automation whose to is the creating session (the default) fires on schedule, and the session's own server runs its turn: run_count rises, last_outcome is fired and last_output is Prompted ses_…. But the ACP client receives no session/update for that turn, neither while it runs nor with the next prompt.

From the source: ACP forwards a session's events only through a prompt turn's own subscription (packages/cli/src/acp/turn.ts, the turn's client.event.subscribe(), live, with no replay), kept past the prompt's response only while background work is pending (followBackground). The session-level subscription in packages/cli/src/acp/sessions.ts forwards model and agent selection alone. So a turn the server starts by itself in an idle session has no subscription to reach the client.

Repro:

  1. Over ACP: initialize, session/new, then prompt "Create an automation that runs every 1 minute whose prompt is: Reply with the single word PULSE."
  2. Leave the session idle for 3 minutes. No session/update arrives.
  3. opencode api experimental.automation.list --param sessionID=<id> shows run_count rising.

Expected: the run's turn reaches the client as session/updates, as the turns that background subagents' reports wake already do. For example, a message subscription per attached session, or a notification that a turn began outside a prompt. Without it, a client that keeps its own transcript can't show an automation's runs.

roidayan1 avatar Nov 26 '26 11:11 roidayan1

Thanks for the detailed report and the source walkthrough.

In short, you're asking for opencode acp to send session/updates for turns the server starts by itself in an idle session, like a prompt automation's scheduled run, so ACP clients that keep their own transcript can show them.

I'm treating this as a feature request rather than a bug. The ACP docs describe updates as tied to a running prompt ("While a prompt runs, OpenCode sends updates…", "After the prompt ends, OpenCode stops sending child session updates"). The code in packages/cli/src/acp/turn.ts only keeps following a session after the response while children or background shells are still running, so that the turns they wake reach the client. A turn with no prompt behind it, like an automation run, isn't covered yet, and covering it needs a new way to deliver events, along the lines you suggest.

Related issues, closest first:

  • #55760: the parent's turn woken by a background subagent report sent no updates after the prompt ended (fixed)
  • #64119: the same for a background shell, fixed by #64262

Both fixes keep an existing prompt's subscription open longer, so neither applies when no prompt is running. I didn't find an open issue or pull request for this case. Maintainers will consider the request.

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

Another real-world report of this, plus a confirming repro on 2.4.2.

Environment: OpenCode 2.4.2 (latest channel), macOS 26.7.3 (arm64). The ACP client is the Orca desktop app (1.4.274) in chat mode, which runs opencode acp once per chat. The model sits behind a custom Anthropic-compatible proxy, which doesn't matter here.

What happened: A long-running session had a prompt automation (every: "45 minutes", to = the creating session). Overnight it fired on schedule 13 times, from 04:33 to 16:19 UTC. Each run stored its user message (metadata.automation.run = 1…8 etc., late: false), and the assistant replied and went idle within 10–60 s. None of those turns reached the chat view while they ran.

Orca's own journal makes it clear when the turns arrived:

Automation runs (UTC) Appeared in client What happened then
04:33 05:13:48 user sent a prompt, client re-attached (session/load)
06:21, 07:11 … 12:26 (9 runs) 12:59:23 (all in one batch) user sent a prompt, client re-attached
13:19, 14:04, 14:49 15:12:16 (one batch) user sent a prompt, client re-attached
15:34 16:14:52 user sent a prompt, client re-attached
16:19 never (still missing) client was already attached, 3 later prompts didn't bring it in

The client wrote nothing to its journal between 12:59:43 and 15:12:14, although it was attached until 13:30 and the 13:19 run happened in that window. So turns appear only when session/load replays them on re-attach. A run that fires while the client stays attached is never delivered, and later prompts don't backfill it, because session/resume and session/prompt don't replay.

Minimal repro (2.4.2, plain ACP over stdio, no Orca): initialize, session/new, then a prompt asking the model to call tools.automation.create with trigger {type:"at", at:"in 1 minute"} and a prompt action. The prompt response arrived after about 6 s, with 9 session/updates during the prompt. The automation fired 60 s later: run_count went to 1, last_outcome was fired, and the session stored the automation user message plus an assistant reply. Over the following 150 s, 0 session/update notifications reached the client.

From the user's side this looks like lost work: scheduled check-ins run on time, but an ACP client can't show them until it reloads the session. Even a minimal notification such as "a turn started outside a prompt" (or a session_info_update hint) would let clients call session/load and catch up.

jordan-melendez avatar Nov 29 '26 16:11 jordan-melendez