Skip to content

subagent: background shell continuation result is not forwarded to parent #63375

Closed as duplicate

Description

@Maic-Rittmeier

Description

A background subagent reports state="completed" to its parent after its first turn, while its background shell is still running. Shell completion correctly wakes the child and the child produces a second response, but that continuation result is not forwarded to the parent in the observed window.

This makes a delegated “wait for an event, then finish the task” workflow appear complete while its actual result remains in the child session. Reproduced once on 2.2.7 and once on 2.2.5; no claim about unbounded future delivery.

Plugins

No third-party plugins found in the reporting 2.2.5 environment; built-in shell/subagent tools used. A complete plugin inventory was not retained for the separate 2.2.7 run.

OpenCode version

2.2.7: CLI and shared server versions both verified. Also observed on 2.2.5. No upgrade/restart during either reproduction.

Steps to reproduce

  1. Ask a parent to start a general subagent with background: true and the following instructions:

    Start exactly one background shell that sleeps 15 seconds and prints
    BG_REPRO_PROCESS_DONE. Then finish your current turn with
    BG_REPRO_INITIAL_RETURN. If the shell completion notification wakes you,
    write a timestamped marker file and return BG_REPRO_RESUMED.
    Do not poll or start additional jobs.
    
  2. Let the parent receive the first subagent notification. Do not send any follow-up prompt to the child.

  3. After the shell finishes, inspect the child transcript and the parent's synthetic messages/inbox through the authenticated API.

Expected: Either keep the delegated task in a waiting state until its required continuation finishes, or distinguish the first-turn result from final task completion and deliver the later result to the parent.

Actual (2.2.7, UTC):

Time Event
19:04:26.302 Child completes BG_REPRO_INITIAL_RETURN.
19:04:32.693 Parent notification contains that initial response, state="completed".
19:04:35.319 Background shell finishes.
19:04:35.333 Shell completion input appears in child transcript.
19:04:39.385 Automatically resumed child writes its marker.
19:04:40.939 Child completes BG_REPRO_RESUMED.
19:06:22.863 Still one parent notification; no matching pending inbox item.

The resumed result was available by explicitly inspecting the child transcript. The parent did not receive it during approximately 102 seconds after the resumed response. Times are projected-message creation/completion times, not independently measured transport times.

Screenshot

No screenshot; reproduction markers and API transcript excerpts confirm both child responses and the single parent notification.

Operating System

Linux ARM64 in Docker Sandboxes. Reporting 2.2.5 environment: kernel 7.0.14, aarch64. Exact kernel/distribution not retained for the separate 2.2.7 environment.

Terminal

Reporting environment: TERM=xterm-256color; terminal app and $SHELL unavailable (unset). Reproduction used built-in tools/API, not terminal interactions.

Additional context

Release-source inspection suggests a first-turn/job-lifetime boundary:

  • subagent-job.ts at v2.2.7: start() resumes the child and snapshots a completed assistant response; notify() waits once for that job.
  • subagent-completion.ts at v2.2.7: delivery uses the settled input.output and acknowledges the notification.
  • Shell completion independently wakes the child; it does not establish a new parent observer for this autonomous continuation.

Refreshing the transcript only when sending the first notification would not solve the observed ordering: parent delivery preceded shell completion. Pending task-owned work needs to be distinguished from intentionally detached processes such as dev servers.

Related but different: #60860 concerns plugin-owned pending work and /goal; #59953 concerns SDK accounting boundaries. This report concerns native background subagent result delivery. No /goal was invoked in this reproduction.

Activity

  1. opencodejr commented on Nov 11, 2026

    @opencodejr
    Contributor

    Thanks for the detailed report and timeline. I think this is a duplicate of #48826. It describes the same problem: a background subagent whose own background shell is still running is reported to the parent as state="completed" with its first-turn reply. When the shell finishes, the child wakes and writes its real answer, but that answer never reaches the parent. That issue's author re-checked it on 2.2.7.

    #48826 was closed when #63209 was merged. With that change, a subagent reports to its parent every time it goes idle, so a child woken by its background shell sends a second report with its later answer. #63209 was merged after the 2.2.7 release, so your 2.2.7 and 2.2.5 runs are from builds without it.

    Possible duplicates and related issues, ordered by likelihood:

    I'm closing this issue now as a duplicate of #48826. If you test a release that includes #63209 and still see the problem, please add your details to that issue. If you think this is a different problem, reply here and this issue will reopen.

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions