Skip to content

session.status event should include parentID to distinguish subagent sessions #30043

Closed

Description

@aqeelat

Problem

When opencode spawns a subagent (via the Task tool), the subagent runs as a child session with its own lifecycle. When the subagent completes, it emits a session.status idle event that is structurally identical to the one emitted when the main session completes:

{"id":"evt_xxx","type":"session.status","properties":{"sessionID":"ses_child123","status":{"type":"idle"}}}

Consumers watching the SSE event stream (e.g. the Warp terminal plugin @warp-dot-dev/opencode-warp) see this idle event and mark the tab as "done", even though the main agent session is still running.

The parentID field exists on the session model (session.info.parentID) and is populated when subagents are created in tool/task.ts, but it is not included in the session.status event — only in session.created and session.updated.

Proposed Fix

Add an optional parentID field to the session.status event schema so consumers can immediately distinguish subagent idle events from main session idle events, without needing to track session.created events separately.

Patch

packages/opencode/src/session/status.ts:

 export const Event = {
   Status: BusEvent.define(
     "session.status",
     Schema.Struct({
       sessionID: SessionID,
       status: Info,
+      parentID: Schema.optional(SessionID),
     }),
   ),
   // deprecated
   Idle: BusEvent.define(
     "session.idle",
     Schema.Struct({
       sessionID: SessionID,
     }),
   ),
 }

Then in SessionStatus.set, the parentID needs to be resolved and passed through. The session info (including parentID) can be fetched from the Session service at publish time, or passed as an additional parameter.

This is backward compatible — the field is optional and existing consumers that ignore it will continue to work.

Consumer Guidance

After this ships, consumers watching for session completion should filter:

// Only react to main session completion
if (event.type === "session.status" && event.properties.status.type === "idle") {
  if (event.properties.parentID) return // subagent — ignore
  // main session is done
}

Activity

  1. nexxeln commented on May 31, 2026

    @nexxeln
    Contributor

    we'll think about this
    for now you can fetch the session and see if it has a parent

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