Skip to content

[Bug]: OpenCode agents do not resume after restart when an awaited background shell is cancelled #44788

Done

Description

@jamesx0416

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

Steps to reproduce

  1. Enable Continue threads after server update (continueThreadsAfterServerUpdate: true) with T3-managed OpenCode.
  2. Ask the agent to run a long Cargo build with the native shell tool (background: true), register the shell ID using t3_background_wait, and end its turn without polling. Verify the wait tool returns the ID in matched.
  3. While the build is still running and the agent's turn has completed, kill the T3 server with SIGKILL, then restart with the same data directory.
  4. Observe whether a new agent turn starts without sending a message.

For a deterministic build, use a dependency-free Rust project with a build.rs containing fn main() { std::thread::sleep(std::time::Duration::from_secs(150)); } and run cargo build --offline --release.

Expected behavior

The interrupted awaited build is recorded as cancelled and the agent automatically receives a cancellation notification in a new turn. Intentionally detached shells should not wake a settled agent.

Actual behavior

The shell is cancelled and the continuation effect is scheduled and marked successful, but the agent stays idle. The shell appears in both turn items and the pending task roster. Recovery records the turn item first and deduplicates the roster entry, losing awaited: true in the cancellation record. The continuation handler then rejects it.

Related to closed #32829, but this failure occurs after explicit wait registration; shell tracking and cancellation work.

Impact

Major degradation or frequent failure

Version or commit

T3 Code 0.1.14-nightly.20261128.5372; also reproduced in a regression test on main at a7acbf5746825954e2b4f1e890fc12b80ec56fce.

Environment

Linux ARM64 (Debian), T3-managed OpenCode 2.4.2, opencode/hy4-flash-free.

Logs or stack traces

Observed state (summarized):

Before crash: run 1 completed; Cargo shell running; explicit wait matched; roster awaited=true.
After restart: shell cancelled; cancellation record omits awaited; continuation effect succeeded; run 2 never created.

Workaround

Send a new message manually to resume the agent.

Proposed fix: #44771.

Activity

  1. added
    vouch:trusted
    on Nov 28, 2026
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

    vouch:trusted

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions