Skip to content

About

Minimal OpenCode repro for plugin promptAsync split runner duplicate assistant turns

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

2 Commits

Folders and files

Repository files navigation

OpenCode plugin promptAsync runner-split reproducer

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.

What the repro does

  • Installs a tiny server plugin with one tool: repro_wait.
  • Runs OpenCode serve against 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_wait calls the plugin-provided input.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.db and fails unless that marker user gets multiple terminal assistant children.

Run locally

Requires opencode, node, curl, and sqlite3 on PATH:

./reproduce-runner-split.sh

Expected 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

docker build -t opencode-promptasync-runner-repro .
docker run --rm opencode-promptasync-runner-repro

Override the OpenCode version under test:

docker build --build-arg OPENCODE_VERSION=1.15.7 -t opencode-promptasync-runner-repro .

Expected behavior

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.

Suspected source cause

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.

About

Minimal OpenCode repro for plugin promptAsync split runner duplicate assistant turns

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages