Files
orca/docs/bug-reproductions/opencode2-session-lineage/hook-posts-before.jsonl
T
Neil b0ae7d18a0 fix(opencode2): resolve subagent session lineage so child work stops taking over the pane (#22444)
OpenCode 2's plugin adapter unwraps a single-property `{ data }` success schema,
so `ctx.session.get` resolves to the bare session record. The shared lineage
lookup only accepts `result?.data?.id === sessionID`, and OpenCode 2 has no
`session.list` fallback, so `resolveRootSessionID` returned null for every
session and `childState` was permanently null.

With unknown lineage `canFailOpen` is true for attention events, so a subagent's
`permission.asked`/`question.asked` fell through and pinned an un-evictable
blocker keyed to the child's own session id — publishing a subagent as if it
were a root. Observed in hook posts: SessionBusy for a child session id whose
`session_v2` row carries a parent.

Envelope the result in the OC2 client shim so the shared lineage module works
unchanged; OpenCode 1 already receives enveloped results and is untouched.

Also adds `opencode2` to the double-Escape interrupt list, extracted into one
shared helper so the server inference and renderer gate cannot drift. A single
Escape was inferring an interrupt, and Escape is how the Subagents dock closes.

7 of 11 new lineage tests fail without the shim.
2026-09-23 20:08:01 -07:00

8 lines
1.3 KiB
JSON

{"t":1790145632961,"path":"/hook/opencode2","payload":{"hook_event_name":"SessionStart","sessionID":"ses_f33016571ffenJDTLmPcLATavv"}}
{"t":1790145632978,"path":"/hook/opencode2","payload":{"hook_event_name":"MessagePart","role":"user","text":"Use your task tool to spawn exactly one subagent. Give that subagent this instruction: run the shell command 'echo hello-from-subagent' and report its output. Do not run the command yourself; you must delegate it. When the subagent returns, reply with just its output.","messageID":"msg_0ccfe9a8f001QOK3S43JBuKODf","sessionID":"ses_f33016571ffenJDTLmPcLATavv"}}
{"t":1790145633014,"path":"/hook/opencode2","payload":{"hook_event_name":"SessionBusy","sessionID":"ses_f33016571ffenJDTLmPcLATavv"}}
{"t":1790145637796,"path":"/hook/opencode2","payload":{"hook_event_name":"SessionBusy","sessionID":"ses_f330152d1ffer9a1SCLERqCLv8"}}
{"t":1790145640105,"path":"/hook/opencode2","payload":{"hook_event_name":"SessionBusy","sessionID":"ses_f33016571ffenJDTLmPcLATavv"}}
{"t":1790145641557,"path":"/hook/opencode2","payload":{"hook_event_name":"MessagePart","role":"assistant","text":"hello-from-subagent","messageID":"msg_0ccfeb695001yjXsR63opaMap9","sessionID":"ses_f33016571ffenJDTLmPcLATavv"}}
{"t":1790145641574,"path":"/hook/opencode2","payload":{"hook_event_name":"SessionIdle","sessionID":"ses_f33016571ffenJDTLmPcLATavv"}}