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.
What happened
Plugins that watch forked sessions (built with the
event/session.getplugin hooks) can't tell a forked session apart from a fresh one, because theSessionobject returned byclient.session.get/client.session.messageshas no field identifying its fork origin.Currently
Sessionexposes:id, parentID, title, summary, share, version, time, revert.parentIDidentifies a subagent child session./fork, OpenChamber's fork action, orsession.forkin the API) hasparentID: null, identical to a brand-new top-level session. There is noforkID/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 onSession, not the full compaction/provider-cache-key proposal.Suggested fix
Add an optional field to
Session(e.g.fork?: { sessionID: string }orforkedFrom?: string) set when a session is created via fork, so plugins and the SDK consumer can reliably detect and trace fork lineage without guessing fromparentIDabsence.Environment