Skip to content

fix(session): notify parent when subagent sessions finish #35066

Closed

Description

@opencode-agent

Summary

Subagent sessions with a parent session should write a synthetic result message back into the parent when the child session finishes.

Foreground task tool calls are the exception: the parent already receives the subagent output in the tool result, so the child completion path should suppress the synthetic parent prompt while that foreground job is still owned by the task tool.

Context

Acceptance notes

  • Background subagent completion wakes the parent with a synthetic <task ...> result containing the child session id and final assistant text.
  • Reprompted/background child sessions still notify from the child session completion path.
  • Foreground subagent tool calls do not double-inject into the parent; they continue to return through the tool call result.

Activity

  1. opencode-agent commented on Jul 3, 2026

    @opencode-agent
    ContributorAuthor

    @kitlangton tagging you here for the subagent parent-notification issue. Draft PR: #35041

  2. EnigmaJazz commented on Aug 11, 2026

    @EnigmaJazz

    Occurrence: headless serve — child completion never notifies the parent

    Observed today on opencode 1.18.15/1.18.16 headless opencode serve (Linux), driving an autonomous SDD workflow through the serve HTTP API:

    • 5/5 orchestrator sessions had a foreground task tool part stuck running forever while the child sub-agent session had already finished its work (its parts show complete reads/writes, batch-flushed). The child-completion notification never reached the parent, so the parent turn never resumed.
    • The same binary/providers/network in interactive TUI sessions: 226 task parts across all sessions — 132 completed + 89 errored + 5 running — i.e. 96%+ resolve. The TUI receives the completion; the headless serve does not.
    • The stuck-parent signature appears to ride on a tool-completion envelope drop: in a controlled probe on a freshly-recycled serve, one session ran read/glob/bash — glob and bash flipped to completed with output present, the read stayed running with no output for 300s until the caller aborted. Work completes; the completion envelope selectively never lands; the turn stalls.
    • Recovery on our side works by artifact-checking the child work from disk (the work is done), but the parent session itself never completes — exactly the gap this issue addresses.

    This issue (and the draft PR #35041) would fix the class we are hitting at scale. Happy to add any of the probe details or raw part-state dumps if useful.

  3. NamedIdentity commented on Aug 27, 2026

    @NamedIdentity

    #45482 addresses this — a caller's Task call is now held until the children it started have settled, and an idle parent is woken so a late result is actually observed.

  4. neriousy commented on Oct 1, 2026

    @neriousy
    Member

    In V2, when a subagent session finishes, its result is posted to the parent session as a <subagent ...> message with the final state, and an idle parent is resumed by default so it can act on the result.

    Wired up in #34320; delivery is shared since #46054.

    Closing as completed.

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

Metadata

Metadata

Assignees

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