Bug Description
On OpenCode V2 (via the V1/V2 adapter in #9016), sessions that oh-my-openagent spawns for subagents (task, call_omo_agent, background agents) are persisted without a parent. They show up as top-level sessions in OpenCode / OpenChamber instead of nested under the session that spawned them.
The callers are fine: tools/delegate-task/sync-session-creator.ts, features/background-agent/manager.ts (startTask) and features/background-agent/spawner.ts all pass body.parentID. The link is lost in the V2 adapter: packages/omo-opencode/src/v2/session-actions.ts createSession reads body.parentID, stores it only as metadata.omoParentID and in adapter memory (state.recordParent), and calls the native api.create(...) without parentID. OMO itself does not notice, because withParent / childSessions rebuild the relation from that metadata, so only the native store and UI see orphans.
OpenCode V2 accepts parentID on plugin session.create since v2.0.22 (anomalyco/opencode#52359). When parentID is set the native host places the child at the parent's location and ignores location.
Steps to Reproduce
- Run OpenCode V2 (verified on 2.0.28) with oh-my-openagent built from Support OpenCode V1 and V2 from one plugin export #9016 (head
502a4f0fd).
- From any session, delegate with
task (category or subagent_type) or launch a background agent.
- Inspect the new session:
GET /api/session/<child id> returns no parentID, and session_v2.parent_id is NULL.
Isolated reproduction without a model: a project plugin builds the facade exactly as host.ts does (createV1PluginInput(ctx, { state: createAdapterState(...) })) and calls client.session.create({ body: { title, parentID: root.id }, query: { directory } }), the same call sync-session-creator.ts makes.
Expected Behavior
The child session is created with the native parentID, so it is nested under the spawning session in the store, the API and the UI. A child that asks for a different directory (team member worktree, task cwd) still ends up in that directory.
Actual Behavior
Isolated run against the real OpenCode 2.0.28 binary (loopback server, throwaway XDG/HOME roots):
|
facade return value |
GET /api/session/:id parentID |
session_v2.parent_id |
| child in project dir |
ses_root |
null |
NULL |
| child in another dir |
ses_root |
null |
NULL |
With the fix below, both children report the root as parent through the API and in session_v2, the other-directory child is stored with the requested directory, and both still report the parent after a cold server restart. The root stays parentless.
Doctor Output
Not applicable: the defect is a dropped field at the adapter/native boundary and reproduces in an isolated server with no providers configured.
Error Logs
No error is raised; the link is silently dropped. The visible symptom is that OpenCode and OpenChamber list every delegated session as a separate top-level conversation.
Configuration
Default. No OMO configuration is involved in the create path.
Additional Context
Fix (2 files, +61/-9), built on top of the #9016 head so it can be cherry-picked into that PR:
mradwankhalil@7513b4c
(branch mradwankhalil:fix/v2-native-parent-linkage-on-9016)
session-actions.ts: pass parentID to the native create. Because the native host ignores location for children, a child whose requested directory differs from where the host placed it is moved there with session.move right after creation. The metadata.omoParentID and adapter-state bookkeeping are kept.
host.test.ts: the existing "create remembers parentID" owner test now asserts the native create receives parentID (it only checked the metadata before, which is why this slipped through); a new case covers the different-directory child (parentID + move, returned record reports the requested directory).
Verification on the #9016 head: host.test.ts 15 pass / 0 fail (the two changed assertions fail on the unfixed code with Expected: "ses_parent", Received: undefined), tsgo --noEmit -p packages/omo-opencode/tsconfig.json clean.
No PR is opened against dev because src/v2 only exists on #9016. Happy to open one against whichever branch the maintainers prefer.
Operating System
Windows 11
OpenCode Version
2.0.28