Minimal repro for an OpenCode host bug where a server plugin's provided SDK
client calls session.promptAsync through an in-process route runtime that does
not share the active session runner state. If the plugin fires promptAsync
while the current turn is still processing, OpenCode can create multiple
assistant children under the same synthetic user parent.
This was originally surfaced by AFT background bash completion reminders: AFT
logged exactly one delivery ID, one promptAsync success, and one ack, while
OpenCode persisted multiple overlapping assistant messages for the accepted
reminder user message.
- Installs a tiny server plugin with one tool:
repro_wait. - Runs OpenCode
serveagainst a local fake OpenAI Responses API server; no real API key is needed. - Creates a session through the live HTTP listener and starts the initial turn
through
/session/:id/prompt_async. - The fake model first asks OpenCode to call
repro_wait. - While that tool call is still active,
repro_waitcalls the plugin-providedinput.client.session.promptAsync(...)exactly once with a marker message. - The fake model deliberately keeps marker responses open for a few seconds so split runners can overlap.
- The script inspects
opencode.dband fails unless that marker user gets multiple terminal assistant children.
Requires opencode, node, curl, and sqlite3 on PATH:
./reproduce-runner-split.shExpected failing-host output ends with something like:
session_id user_id user_created children stops first_child last_child
...
REPRODUCED: promptAsync marker user has 2 assistant children (2 stop).
Verified locally against OpenCode 1.15.7 with:
REPRODUCED: promptAsync marker user has 4 assistant children (2 stop).
docker build -t opencode-promptasync-runner-repro .
docker run --rm opencode-promptasync-runner-reproOverride the OpenCode version under test:
docker build --build-arg OPENCODE_VERSION=1.15.7 -t opencode-promptasync-runner-repro .The synthetic marker user should get exactly one assistant continuation. The active session runner should coalesce or serialize all prompt/loop entries for a session, regardless of whether they originate from the UI/listener route or a plugin SDK client.
OpenCode's plugin input client is currently constructed with:
fetch: async (...args) => Server.Default().app.fetch(...args)That Server.Default() path uses HttpApiApp.webHandler() with a shared/global
memo map, while the live listener is built with a fresh memo map. Since
SessionRunState is in-memory inside those Effect layer graphs, plugin-origin
promptAsync can observe an idle runner even while the live turn is still
active.