Skip to content

Parent reports completion while a native subagent is still working #65316

Open

Description

@tlerbao

Description

In the OpenCode TUI, the parent committed its changes and sent a final “done” report while a native subagent was still working. The subagent later sent its first <subagent state="completed"> report, which woke the parent and resulted in a second assistant reply without another user prompt.

In the latest case, the parent assigned one new code-fixer session a test file and a syntax check. The parent owned implementation and final integration testing. They shared the workspace, so the parent could see the test file, run the full integration suite successfully, and commit before the child reported back. The child was still trying its own database test when the parent declared the work complete. Code edits were disjoint. Syntax checks and execution of the new cases overlapped.

I expect the parent to be able to yield while a required child runs, then review its report before committing or declaring the task complete. A pending-work state or a native wait/join option would make this reliable without polling and would still allow independent parent work in parallel.

Plugins

Oh My OpenCode Slim was disabled for this occurrence. The server config declares plugins: []. Local plugin files are present for Herdr agent state, Magpie model integration, and RTK. The CLI config enables the Herdr plugin. A run with all local plugins disabled is still pending.

OpenCode version

opencode v2.3.2 (V2 CLI/TUI). Parent model route magpie/auto/gpt-6.2-sol. Configured child route magpie/group/auto-deepseek-flash#high.

Steps to reproduce

  1. Use a global AGENTS.md that delegates bounded work to native subagents, assigns non-overlapping files, and makes the parent responsible for reviewing results and final verification. My configuration defines code-fixer, designer, fast-generic, oracle, and repo-scout. The affected turn used only code-fixer in a fresh child session. My rules call for fresh sessions for independent tasks and reuse only for follow-ups to the same task.
  2. Ask the parent to finish a change. Have it delegate a regression test and syntax check to the child while implementing the production change itself. The child writes its file and continues checking it.
  3. Let the parent run integration checks after the child's file appears. In the observed turn, the parent then committed and reported completion before the native child report arrived.
  4. Leave the session open without sending another prompt. Observe the late child report and the additional parent reply. Similar premature “done” reports have occurred repeatedly in my workflow. These steps describe the observed case, and I have not established a deterministic minimal reproduction.

Related reports

My earlier Slim report documented repeated replays of previously delivered results. The latest occurrence involved one late first delivery from the native tool. I would like to understand whether OpenCode can support waiting for required child results before a parent finalizes. This may involve model behavior as well as the native tool lifecycle. OMO Slim #1940 · OpenCode #63785 · OpenCode #64073

Operating System

macOS 13.3 (Darwin 22.4.0, x86_64).

Terminal

OpenCode TUI in Herdr, TERM=xterm-256color, COLORTERM=truecolor, /bin/zsh.

Activity

  1. opencodejr commented on Nov 21, 2026

    @opencodejr
    Contributor

    Thanks for the detailed write-up, @tlerbao. You're asking for a way to make the parent wait for a required subagent's report before it commits or says the task is done, while it can still do its own independent work in the meantime. For example, a wait/join step or a "pending work" state.

    For context, here's how it currently works: in v2, subagents always run in the background. The subagent call returns right away with a sessionID, and the parent gets a <subagent> message each time the child goes idle. The tool tells the model to "Keep working on non-overlapping tasks, or briefly tell the user what you launched and end your response. Do not sleep, poll, or proactively check on the child's progress." In the code I read, I found no join step that keeps the parent from finishing while a child is still running. So whether it waits depends on the model, which fits what you saw: the parent ended its turn, then the child's report started another one. That's why I'm treating this as a feature request rather than a bug.

    Maintainers will consider it; I can't promise an outcome or a timeline. Related issues:

  2. added
    area/core
    type/feature
    version/v2
    on Nov 21, 2026
  3. shaojunying commented on Nov 21, 2026

    @shaojunying
    Contributor

    I reproduced this on dev (edacc8686a) with a scripted test model, so the timing is deterministic and does not depend on model behavior.

    Repro. The parent calls subagent, then returns "All done. I committed the change." The child blocks on a foreground shell until the test releases it. Results (5/5 runs):

    • The parent goes idle while the child job is still running.
    • At that moment, experimental.idle receives the child in background. Core knows the child is outstanding.
    • After the child finishes, its <background-result kind="subagent"> report wakes the parent. The parent makes a third model request. The session has one user message.

    Root cause. Ending the turn is the only way for the model to wait. The runtime treats "turn ended with own subagents running" the same as "task done". The parent sees that a child is running only once, in the tool result at launch (tool/plugin/subagent.ts:217). Later steps have no signal that results are still pending. When the model decides to commit or report completion, it cannot see the running child. The idle boundary already computes outstanding work (session/runner/llm.ts:182), but core only passes it to the hook.

    Proposal. This keeps the background-only model from #63382.

    1. While a session has its own running subagents, the context hook that subagent.ts already registers adds a transient reminder near the tail. The reminder lists the children and says not to commit or report completion for work that depends on them. It uses the same pattern and filter as the goal plugin (plugin/goal.ts:150-160 and :224-235). With no running children, the hook adds nothing. This also targets agents: subagent "work in background" pattern leads to hallucinated answers when no independent work exists #63785.
    2. Optional follow-up: when a turn ends with own subagents running, the terminal event carries the pending child IDs. The TUI and app can then show "waiting on N subagents" instead of a finished turn. The report-triggered turn then reads as a continuation.

    Interruption is unchanged. Escape on the parent does not cancel children. A child stopped with composer.subagent.interrupt becomes cancelled, so outstanding drops it and the reminder goes away.

    If you prefer restoring foreground calls (#64073) or a job_wait tool (#60497), part 1 still applies to background calls.

    Do you agree with part 1 as a first, small PR? If so, please assign this issue to me. I will include a regression test built on subagent-idle-e2e.test.ts.

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

    area/coreplatform/macostype/featureversion/v2

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions