Skip to content

[Bug]: A turn OpenCode 1.x starts on its own after a background task is never shown in the thread #36522

Closed

Description

@Mach1212

Before submitting

  • I searched existing issues and did not find a duplicate.
  • I included enough detail to reproduce or investigate the problem.

Area

apps/server (OpenCode provider, packages/provider-opencode, 1.x adapter)

Steps to reproduce

  1. Run T3 Code with OpenCode 1.19.5 and OPENCODE_EXPERIMENTAL_BACKGROUND_SUBAGENTS=true in the server's environment. The oh-my-openagent plugin's background task shows the same thing without that variable.

  2. In an OpenCode thread, send:

    Call the task tool exactly once with subagent_type "general", background true, description "Sleep and reply", and this prompt: "Run the shell command sleep 20 once, then reply with exactly CHILD_OK. Do nothing else." When the tool returns, reply with exactly PARENT_OK and end your turn. Later, when you are told that the background task completed, reply with exactly WAKE_OK and nothing else.

  3. Wait a minute.

Expected behavior

When the subagent finishes, OpenCode prompts the session with its result and the agent replies WAKE_OK. That turn shows in the thread as a run of its own, as docs/internals/adding-a-provider.md describes under "Work the provider starts on its own".

Actual behavior

The thread still ends at PARENT_OK. OpenCode has the WAKE_OK reply; T3 Code has one run and nothing after it, and shows no working state while that turn runs.

The thread a minute later: it ends at PARENT_OK

Whatever the agent does in that turn is hidden the same way: edits, commands, its final report. T3's own tools fail in it too. In a real thread on v0.1.8 the agent's calls to t3_thread_send and preview_open were refused with "The calling provider no longer owns an active thread run."

Cause: the 1.x adapter (packages/provider-opencode/src/server/adapter.ts) creates root turns only in startTurn. With no turn active, handleMessageUpdated, handlePartUpdated and handlePartDelta return early, so the turn's messages and parts are dropped. It never offers a ProviderContinuationRequest, which the OpenCode 2 and Pi adapters do for this case.

What OpenCode 1.19.5 sends on the root session for that turn, in order: message.updated for a new user message, message.part.updated with its synthetic text, session.status busy, the assistant message and its parts, session.status idle, session.idle.

Impact

Major degradation or frequent failure

Every OpenCode 1.x thread that uses background subagents: the agent's follow-up work is invisible in T3 Code.

Version or commit

First seen on v0.1.8. Reproduced live on main @ 5f95653. A unit test with the same event order still fails on main @ 2dd6cdd.

Environment

Linux x64, T3 Code server run from source (Node 26.13.0), web client in Chromium 157. OpenCode 1.19.5, model anthropic/claude-haiku-5-5.

Logs or stack traces

# T3 Code, orchestration_v2_projection_runs (ordinal | status | started | completed)
1 | completed | 2026-11-13T22:51:52.471Z | 2026-11-13T22:51:57.084Z

# OpenCode's database, the root session: 2 user messages, 3 assistant messages
user  2026-11-13 22:51:52  Call the task tool exactly once ...
user  2026-11-13 22:52:17  <task id="ses_..." state="completed"> <summary>Background task completed ...

Workaround

Send the thread any message. That starts a run T3 Code records, and the agent can report again. The hidden turn itself stays only in OpenCode.


Investigated and written with Claude Fable 5.2 in OpenCode.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions