Skip to content

subagent: completion event fires at first idle, no event at real finish #62296

Closed as duplicate

Description

@peppekerstens

Summary

A subagent completion notification is emitted when the child session first goes idle, not when the child's work ends. When a child waits on a background shell, the parent receives state="completed" while the child still works. The real finish sends no second event, so the parent stays idle until the user types.

Environment

  • opencode version: 2.2.5
  • OS: Linux 7.0.0-38-generic x86_64 (Ubuntu)
  • Terminal: TERM=xterm-256color, COLORTERM=truecolor (opencode TUI)
  • Shell: /bin/bash
  • Install/channel: latest
  • Active plugins: caveman, asd-ste100

Reproduction

  1. Spawn a background subagent (background: true). Its task starts a long background shell job, then ends its turn and waits for the job.
  2. The child goes idle while the shell job runs.
  3. In the parent, observe the synthetic subagent event: metadata.state = "completed", while the child's last text says the work continues.
  4. The shell job ends. The child wakes on the shell completion event and writes the final report.
  5. Observe that no second subagent event reaches the parent.

Expected Behavior

  • state="completed" only when the child session has no pending work.
  • An event (or a state update) when the child finally ends.

Actual Behavior

  • The parent gets state="completed" at the child's first idle.
  • No event arrives at the real finish.
  • The parent idles indefinitely. Only a user message resumes the session.

Measured on one session (ses_e6328c204ffe0bFi0yELaa7OnI, 24 subagents): 4 early notifications. Gap between the notification and the real last message: 226 s, 483 s, 2057 s, 5851 s.

Additional Context

Worked example, child ses_e508d5162ffeX4osMnA0F9exEU:

  • 07:06:24 child idle. Parent event: state="completed", body "Checks 1, 3, 4 done. Check 2 (M5 gate) still running in background. Waiting for its completion notification..."
  • 07:06:26 the background shell completes. The child resumes.
  • 07:08:14 the child writes the final report.
  • 07:10:11 the child idles again. No event to the parent.
  • The parent stayed idle until the user typed at 07:17:38 and again at 07:19:35.

The second reported symptom (parent says a subagent is done, or says it is still running) has the same root cause: one event claims completed while its body says the child is still working.

Suggested fix: emit the subagent event on the child's terminal state, when no background job is pending. Alternatively send repeated state updates per child instead of one deduplicated event.

Workaround: no subagents. Run the work on the main thread and use background shell jobs.

Activity

  1. opencodejr commented on Nov 6, 2026

    @opencodejr
    Contributor

    Thanks for the detailed report and the timings. I think this is a duplicate of #48826: a subagent with a pending background shell is reported to the parent as completed when it first goes idle, and its real final answer after the shell wakes it never reaches the parent.

    Possible duplicates and related items, ordered from most to least likely:

    Your measurements (the 4 early notifications and the gaps up to 5851 s) would be useful context on #48826.

    The bot will close this issue as a duplicate in 1 day unless you reply explaining how your problem is different.

  2. opencodejr commented on Nov 7, 2026

    @opencodejr
    Contributor

    Closing this as a duplicate of #48826. We waited a day and there was no reply saying how this differs. That issue covers the same bug: a subagent with a pending background shell is reported as completed at its first idle, and its real final answer never reaches the parent. Please follow #48826 for updates. The open PRs #61833 and #57418 address it. Your timing measurements would still be useful context there. If your problem turns out to be different, reply here and we can 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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions