Skip to content

Session object has no field identifying fork origin (parentID only distinguishes subagent children) #53777

Description

@Rahulsharma0810

What happened

Plugins that watch forked sessions (built with the event/session.get plugin hooks) can't tell a forked session apart from a fresh one, because the Session object returned by client.session.get/client.session.messages has no field identifying its fork origin.

Currently Session exposes: id, parentID, title, summary, share, version, time, revert.

  • parentID identifies a subagent child session.
  • A forked session (via /fork, OpenChamber's fork action, or session.fork in the API) has parentID: null, identical to a brand-new top-level session. There is no forkID/sourceSessionID/equivalent field to distinguish the two.

Why this matters

A plugin that needs to treat forks differently from fresh sessions (e.g. not re-running first-message logic, or reporting results back to the session a fork came from) has no reliable way to detect that a session is a fork, or which session it was forked from.

Related prior art

This was flagged as part of #4317 ("fork-aware conversations", proposing parentConversationId/forkID), which was auto-closed as stale (NOT_PLANNED, closed by the 60-day inactivity bot) rather than resolved or rejected on its merits. Its own closing comment invites opening a new issue if still relevant — this is narrower in scope than that issue: just the missing fork-origin field on Session, not the full compaction/provider-cache-key proposal.

Suggested fix

Add an optional field to Session (e.g. fork?: { sessionID: string } or forkedFrom?: string) set when a session is created via fork, so plugins and the SDK consumer can reliably detect and trace fork lineage without guessing from parentID absence.

Environment

  • opencode v2.0.24
  • Observed while migrating a local plugin (reporting subagent/fork results back to a parent session) from the v1 to v2 plugin API.

Activity

  1. opencode-agent commented on Oct 7, 2026

    @opencode-agent
    Contributor

    Thanks for the detailed write-up!

    OpenCode v2 should already have this. On v2 (including v2.0.24), the Session info returned by session.get and session.list has an optional fork field. It is set when a session is created by forking:

    fork?: {
      sessionID: string // the session it was forked from
      boundary: { type: "before" | "through"; messageID: string }
    }

    So session.fork?.sessionID tells you whether a session is a fork and which session it came from. parentID is still only for subagent children. Plugins can also listen for the session.forked event, which includes the new sessionID, the source session as parentID, and the boundary.

    The fields you list (summary, share, version, …) are from the v1 Session type. Your plugin may still be using v1 SDK/plugin types, or calling a v1-style client.

    Could you check whether fork shows up when you read a forked session through the v2 plugin client (@opencode/plugin)? If it's still missing, please share:

    • which package/client and method you call (e.g. the client.session.get from the v2 plugin context, or @opencode-ai/sdk)
    • the raw JSON you get back for a session created with /fork or session.fork

    You can reply here or edit the issue. If you edit it, please also leave a comment saying you've updated it, so we know you're done.

    Related issues, ordered by likelihood of relevance:

  2. opencode-agent commented on Oct 10, 2026

    @opencode-agent
    Contributor

    Closing this for now. We haven't heard back on whether the existing fork field covers your use case.

    On v2 (including v2.0.24), the Session info returned by session.get and session.list has an optional fork: { sessionID, boundary } field. It is set when a session is created by forking, so session.fork?.sessionID tells you whether a session is a fork and which session it came from. Plugins can also listen for the session.forked event. The fields you listed (summary, share, version) are from the v1 Session type, so your plugin may still be using v1 types or the v1 SDK.

    If fork is still missing when you read a forked session through the v2 plugin client, please reopen this or open a new issue. Include the client and method you call and the raw JSON response, and we'll look into it.

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

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions