Skip to content

fix(opencode2): resolve subagent session lineage so child work stops taking over the pane - #22444

Merged
nwparker merged 1 commit into
mainfrom
nwparker/opencode2-session-lineage
Sep 24, 2026
Merged

nwparker merged 1 commit into
mainfrom
nwparker/opencode2-session-lineage

Conversation

@nwparker

@nwparker nwparker commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​244 $\color{#cf222e}{\Huge{\mathbf{−}}}$​5 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​239
Prod 7 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​117 $\color{#cf222e}{\Huge{\mathbf{−}}}$​15 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​102

ELI5

When an OpenCode agent delegates work to a subagent, and that subagent asks a question, Orca is supposed to keep the question attached to the subagent and just show the pane as busy. Instead Orca treated the subagent as if it were your main session, so the pane lit up with "needs your input" — while the agent you were talking to correctly told you it had no question. Nothing could clear it except switching Orca tabs.

The reason is small: Orca asks OpenCode "who is this session's parent?", and for OpenCode 2 it was never able to read the answer.

What Changed

src/main/opencode2/status-plugin-setup-source.ts builds the session client that Orca's shared lineage code uses. OpenCode 2's ctx.session.get returns the session record directly, but lookupSessionList only accepts a result when result?.data?.id === sessionID. The session.list fallback doesn't exist on OpenCode 2 either, so there was no second chance:

  • ctx.session.get({ sessionID }, { signal }) → the record directly, keys ["id","projectID","agent","model","cost","tokens","time","location"]
  • ctx.session.get({ path: { id } }, { signal }) → throws Missing key at ["sessionID"]
  • ctx.session.list → undefined

So resolveRootSessionID returned null for every OpenCode 2 session and childState was permanently null.

The shim now envelopes the direct result:

get: async (input, options) => {
  const result = await ctx.session.get(input, options);
  return result && typeof result.id === "string" ? { data: result } : result;
},

Keyed on typeof result.id === "string" rather than "has no .data", so an already-enveloped result passes straight through — an envelope has no top-level id. The wrapper keeps arity 2 so lookupSessionList still tries the [{sessionID}, {signal}] call shape first. The shared lineage module is untouched.

Also in this PR: opencode2 was missing from the double-Escape list, so a single Escape on an opencode2 pane inferred an interrupt — and Escape is exactly how you dismiss OpenCode 2's Subagents dock. The same list was duplicated in the renderer gate (requiresDoubleEscapeForAgent), so fixing only the server would have silently removed double-Escape interrupts for opencode2. Both call sites now share one requiresDoubleEscapeInterrupt in src/shared/agent-interrupt-intent.ts, next to the existing isNavigationEscapeIntent.

Why

Investigating #22371. With childState === null, canFailOpen is true for attention events, so a subagent's permission.asked / question.asked fell through to the attention branch in status-plugin-lifecycle-source.ts:81-102 and pinned an un-evictable blocker keyed to the child's own session id. The entire "child work rolls up to the pane but stays non-authoritative" design was bypassed for OpenCode 2.

It also could not un-stick itself. clearQuestionForToolPart is already dead for OpenCode 2 (it never emits message.part.updated, and its form metadata.tool carries id, not callID), so only an exact idle for that child session could retire the blocker.

Why the shim rather than the lineage module: OpenCode 1 drives the same module through server() with the raw SDK client, and that client already returns enveloped results. Normalising at the one place the shapes differ keeps a single lineage implementation instead of forking a parallel OpenCode 2 path.

Why no relay or remote-wire change: the reporter confirmed this reproduces on a local machine as well as a Remote Orca Server workspace, so the cause is common to both hosts. Fixing the plugin's own client shim covers local, SSH, and remote at once with no protocol change and nothing to capability-negotiate.

Linked Issue

Refs #22371 — but see Visual Proof: this is no longer claimed as the fix for that report.

Visual Proof

Attempted, and it does not support a user-visible claim. Reporting that rather than dropping it.

I drove both builds in the real app: OpenCode 2 in a scratch dir, a subagent delegated a task and called its question tool, captured at the moment the question was outstanding.

BEFORE (17ffbf3b318) AFTER (abaa5e0f382)
Pane state while question outstanding waiting waiting
Sidebar row amber needs-input indicator amber, identical
Session id the question is published under child ses_f2ff3c848… (parent set) root ses_f2ffd258a… (no parent)
After answering → done, indicator clears → done, indicator clears

The only measurable difference is the session id row — which is precisely the lineage rollup this PR fixes. The screenshots are identical to the eye, so I am not presenting them as a before/after.

This corrects the causal story I originally wrote for #22371. A subagent's question surfacing on the pane is correct behaviour — handleLifecycleEvent deliberately "show[s] the blocker on the root turn while retaining its real child owner". So this fix does not, and should not, stop the indicator from appearing. What it changes is that the blocker is now attributed to the root session instead of the child's, which is what lets the normal retirement paths (an exact idle for that session, or a reply) clear it.

So the honest scope is narrower than the PR originally implied: this fixes incorrect session attribution, which is a real bug with observable evidence in the hook posts. It is not demonstrated to fix the stuck-indicator symptom in #22371. I have not reproduced that symptom in either build.

Testing

Platforms: macOS, against the shipped opencode v2.0.12.

New src/main/opencode/hook-plugin-opencode2-session-lineage.test.ts — 11 tests, run against both plugin variants. It pins the actual user-visible regression, not just the helper: a child session's question.asked must not mint a root-level blocker, and a child-raised blocker must retire when that child goes idle. Also pins one lineage lookup per child across four events, so positive caching still holds.

Verified the tests fail without the shim — 7 failures, e.g. expected [ 'ses_root', 'ses_root', 'ses_child' ] to not include 'ses_child'. The three new opencode2 Escape cases likewise fail without the list entry.

  • pnpm test src/main/opencode src/main/opencode2 — 18 files, 222 passed
  • Wider blast radius (src/main/agent-hooks, src/shared, renderer terminal-pane) — 904 files, 10171 passed
  • pnpm tc — 0; pnpm run check:code-quality:changed — 0 new findings

The plugin byte digest in hook-service.test.ts is re-pinned, expected for any change to emitted plugin source. The mimo-code digest is byte-identical, confirming OpenCode 1's path is untouched.

Not verified: that the reporter's exact frame is gone on their machine. This is Refs, not Fixes, until they confirm.

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below

AI Disclosure

Review

Agent skill upstream boundary

  • Not applicable, or this change follows docs/reference/agent-skill-sharing-upstream-boundary.md and copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

  • Backwards compatibility: the shim is OpenCode 2-only and passes enveloped results through unchanged, so a future SDK that starts enveloping needs no further change. OpenCode 1 is byte-identical.
  • SSH / remote: no wire change. Per docs/reference/remote-wire-compatibility.md nothing here alters RPC params, stream opcodes, or published content — the fix is inside the plugin that runs on the execution host, which keeps owning agent status.
  • Failure mode if lineage still fails: unchanged from today — childState stays null and behaviour degrades to the current fail-open. The fix can only improve on it.
  • Performance: one extra await and a type check per lineage lookup, and lookups are already cached per child.
  • Security, mobile, cross-platform: unaffected.

Two adjacent defects found, deliberately not fixed here

  1. Both generated plugins declare the plugin id "orca-opencode-status" and both are written into ~/.config/opencode/plugins/. OpenCode 2 keeps only one; when it keeps the v1 file, its ORCA_OPENCODE_AGENT gate returns no hooks and the pane reports nothing, silently. This blocked the harness until the v1 file was moved aside. Already addressed by open PR fix(opencode): fail-open plugin setup and distinct opencode2 plugin id #22158.
  2. Unmounting a pane can delete a genuine pending blocker. The delete in agent-status-patch.ts is gated only on ownership and on the host snapshot carrying no status for the surface — nothing inspects the entry's state. Once dispose() calls releaseRendererOwnedAgentStatusPane(), a real unresolved waiting row is dropped on exactly the same path as a stale one. This is what made the reporter's tab-switch "workaround" work, and it means a real question can vanish from the sidebar just because you looked at another tab. Filing separately.

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test pass locally

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

  • OpenCode 2 session lineage shim — getOpenCode2SetupSource() (src/main/opencode2/status-plugin-setup-source.ts:8) now re-envelopes ctx.session.get's flat record as { data: record } before the shared lineage walk consumes it. Without this, lookupSessionList (status-plugin-session-lineage-source.ts:100) discarded every lookup, resolveRootSessionID returned null, and child attention was keyed to the child session id. The typeof result.id === "string" guard leaves an already-enveloped result (and the OpenCode 1 server() path) untouched.
  • opencode2 added to the double-Escape interrupt set — new shared requiresDoubleEscapeInterrupt() (src/shared/agent-interrupt-intent.ts:55) replaces the duplicated list in the server gate (server-status-inference.ts:49) and the renderer gate (agent-interrupt-inference.ts:47), adding opencode2 so a single Escape (OC2's Subagents-dock dismiss) no longer infers an interrupt.
  • Tests — new hook-plugin-opencode2-session-lineage.test.ts runs the generated plugin against both variants and pins root attribution plus child-idle retirement; the two interrupt suites add opencode2 cases; the v1 plugin sha256 is re-pinned.

Verification

I ran the touched suites: the four changed test files pass (100 tests), and the full src/main/opencode + src/main/opencode2 dirs pass (18 files). I also confirmed the new tests are real regression guards rather than theatre — reverting the shim reproduces 7 failures in the lineage suite, and removing opencode2 from the set reproduces 3 failures across the interrupt suites. The generated plugin uses client solely for ancestry lookup, so the re-envelope has no other consumer.

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@coderabbitai

coderabbitai Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

📝 Walkthrough

Walkthrough

The changes adapt OpenCode 2 session lookup results for lineage resolution and add tests and reproduction captures for session-lineage behavior. They also add a shared double-Escape guard for OpenCode, OpenCode 2, and Copilot, then use it in renderer and server inference checks. Server-inferred interrupt and answered-question payloads no longer include mainAgent.

Priority: ➖ Normal

Merge Risk: 🟡 Moderate · up to d11f6

Inferred status updates can lose main-agent state, and the lineage tests may miss regressions. Preserve that state and make the assertions wait for the relevant events before merging.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 22.22% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 9 functions across 8 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the primary change: fixing OpenCode 2 subagent session lineage. It is concise and related to the changeset.
Description check ✅ Passed The description is detailed and covers the required explanation, changes, rationale, issue reference, testing, compatibility, and checklist items. It explains that the visual symptom was not verified,…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 391b15bd-d6b2-41a8-b801-a1e7639d63b6

📥 Commits

Reviewing files that changed from the base of the PR and between 51c3434 and abaa5e0.

📒 Files selected for processing (11)
  • docs/bug-reproductions/opencode2-session-lineage/README.md
  • docs/bug-reproductions/opencode2-session-lineage/hook-posts-after.jsonl
  • docs/bug-reproductions/opencode2-session-lineage/hook-posts-before.jsonl
  • src/main/agent-hooks/server-interrupt-inference-guards.test.ts
  • src/main/agent-hooks/server/server-status-inference.ts
  • src/main/opencode/hook-plugin-opencode2-session-lineage.test.ts
  • src/main/opencode/hook-service.test.ts
  • src/main/opencode2/status-plugin-setup-source.ts
  • src/renderer/src/components/terminal-pane/agent-interrupt-inference.test.ts
  • src/renderer/src/components/terminal-pane/agent-interrupt-inference.ts
  • src/shared/agent-interrupt-intent.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 5 remain after this review.

}
}
})
return { posts, lookups, cleanup }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🔎 Supported by static analysis

🏁 Script executed:

sed -n '65,225p' src/main/opencode/hook-plugin-opencode2-session-lineage.test.ts
rg -n 'subscribe|session.get|handleLifecycleEvent' src/main/opencode2/status-plugin-setup-source.ts src/main/opencode/hook-service.ts src/main/opencode/status-plugin-session-lineage-source.ts

Repository: stablyai/orca

Length of output: 7030


🏁 Script executed:

set -e
printf '%s\n' '--- setup source ---'
cat -n src/main/opencode2/status-plugin-setup-source.ts
printf '%s\n' '--- generated/source event wiring ---'
sed -n '1,180p' src/main/opencode/status-plugin-session-lineage-source.ts
printf '%s\n' '--- test setup and assertions ---'
sed -n '1,150p' src/main/opencode/hook-plugin-opencode2-session-lineage.test.ts
printf '%s\n' '--- setup callers and generated plugin source builders ---'
rg -n -C 4 'getOpenCode2PluginSource|getOpenCodePluginSource|status-plugin-setup|event\.subscribe|for await|session\.execution\.started|form\.created|setup\s*:' src/main/opencode src/main/opencode2

Repository: stablyai/orca

Length of output: 42553


🏁 Script executed:

set -e
printf '%s\n' '--- factory setup and shared handler ---'
sed -n '1,120p' src/main/opencode/status-plugin-factory-source.ts
sed -n '220,305p' src/main/opencode/status-plugin-factory-source.ts
rg -n -C 8 'async function OrcaOpenCodeStatusPlugin|function OrcaOpenCodeStatusPlugin|hook_event_name|SessionBusy|AskUserQuestion|fetch\\(' src/main/opencode src/main/opencode2
printf '%s\n' '--- completion and fixture synchronization search ---'
rg -n -C 3 'consum|completion|done|eventsConsumed|event.*promise|runSetupBridge' src/main/opencode/hook-plugin-opencode2-session-lineage.test.ts src/main/opencode

Repository: stablyai/orca

Length of output: 10471


🏁 Script executed:

set -e
printf '%s\n' '--- plugin source selections ---'
rg -n -C 10 'function getOpenCodePluginSource|function getOpenCode2PluginSource|getStatusPluginFactorySource\\(' src/main/opencode/hook-service.ts
printf '%s\n' '--- lifecycle handler and post queue ---'
sed -n '120,245p' src/main/opencode/status-plugin-factory-source.ts
printf '%s\n' '--- synchronization symbols in target test ---'
rg -n -C 4 'runSetupBridge|event\\.subscribe|vi\\.waitFor|cleanup|Promise' src/main/opencode/hook-plugin-opencode2-session-lineage.test.ts

Repository: stablyai/orca

Length of output: 342


🏁 Script executed:

set -e
printf '%s\n' '--- plugin source selections ---'
grep -n -F -C 10 'getOpenCodePluginSource' src/main/opencode/hook-service.ts
grep -n -F -C 10 'getOpenCode2PluginSource' src/main/opencode/hook-service.ts
printf '%s\n' '--- lifecycle handler and post queue ---'
sed -n '120,245p' src/main/opencode/status-plugin-factory-source.ts
printf '%s\n' '--- synchronization symbols in target test ---'
grep -n -F -C 4 'runSetupBridge' src/main/opencode/hook-plugin-opencode2-session-lineage.test.ts
grep -n -F -C 4 'vi.waitFor' src/main/opencode/hook-plugin-opencode2-session-lineage.test.ts

Repository: stablyai/orca

Length of output: 15033


Await the fixture event stream before lineage assertions.

setupOpenCode2Status starts consuming events asynchronously and returns before the subscription finishes. The first test can observe the root SessionBusy before the child event. The cache test can assert after the first child event, before the repeated events run. Await a fixture completion promise before these assertions. Do not use cleanup as the barrier because it aborts the subscription.

Suggested synchronization fix
@@
   async function runSetupBridge(
     events: { type: string; data: Record<string, unknown> }[]
   ): Promise<{
     posts: Post[]
     lookups: string[]
+    eventsConsumed: Promise<void>
     cleanup?: () => Promise<void>
   }> {
     const posts: Post[] = []
     const lookups: string[] = []
+    let resolveEventsConsumed!: () => void
+    const eventsConsumed = new Promise<void>((resolve) => {
+      resolveEventsConsumed = resolve
+    })
@@
         subscribe: async function* () {
           for (const event of events) {
             yield event
           }
+          resolveEventsConsumed()
         }
       }
     })
-    return { posts, lookups, cleanup }
+    return { posts, lookups, eventsConsumed, cleanup }
@@
-    const { posts, lookups, cleanup } = await runSetupBridge([
+    const { posts, lookups, eventsConsumed, cleanup } = await runSetupBridge([
@@
-    await vi.waitFor(() => {
-      expect(posts.filter((post) => post.hook_event_name === 'SessionBusy').length).toBeGreaterThan(
-        0
-      )
-    })
+    await eventsConsumed
@@
-    const { posts, lookups, cleanup } = await runSetupBridge([
+    const { posts, lookups, eventsConsumed, cleanup } = await runSetupBridge([
@@
-    await vi.waitFor(() => {
-      expect(posts.length).toBeGreaterThan(0)
-    })
+    await eventsConsumed

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 8ded1f2a-a883-4fa9-95a2-af7c21a2489f

📥 Commits

Reviewing files that changed from the base of the PR and between 473b668 and d11f6ce.

📒 Files selected for processing (3)
  • src/main/agent-hooks/server/server-status-inference.ts
  • src/main/opencode/hook-service.test.ts
  • src/main/opencode2/status-plugin-setup-source.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 7 remain after this review.

payload.mainAgent?.state === 'done'
? payload.mainAgent
: { state: 'done', outcome: 'cancellation', stateStartedAt: Date.now() }
...(payload.subagents ? { subagents: payload.subagents } : {})

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win

🔎 Supported by static analysis

🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Inspect the mainAgent contract and its consumers.
rg -n -C 5 '\bmainAgent\b|applyNormalizedStatus' src

Repository: stablyai/orca

Length of output: 42718


🏁 Script executed:

set -euo pipefail
printf '%s\n' '--- inference methods ---'
sed -n '70,190p' src/main/agent-hooks/server/server-status-inference.ts
printf '%s\n' '--- status update consumer ---'
sed -n '1,190p' src/main/agent-hooks/server/server-status-update.ts
printf '%s\n' '--- type declarations ---'
sed -n '1,120p' src/main/agent-hooks/server/server-types.ts
printf '%s\n' '--- direct mainAgent-related implementation references ---'
rg -n -C 4 'withHeldChildWaitMainAgent|continueMainAgentStatus|mainAgentStatusEqual|mainAgent\.state|payload\.mainAgent|restored\.mainAgent' src/main src/shared src/renderer/src/components/native-chat -g '*.ts' -g '*.tsx'

Repository: stablyai/orca

Length of output: 42113


🏁 Script executed:

set -euo pipefail
sed -n '85,180p' src/main/agent-hooks/server/server-status-inference.ts
rg -n -C 6 'withHeldChildWaitMainAgent|continueMainAgentStatus|mainAgentStatusEqual|mainAgent\.state|payload\.mainAgent|restored\.mainAgent' src/main src/shared src/renderer/src/components/native-chat -g '*.ts' -g '*.tsx'

Repository: stablyai/orca

Length of output: 42296


Preserve mainAgent in both inferred payloads.

applyNormalizedStatus does not restore this field from the previous row. The child-wait helper also requires next.payload.mainAgent. Without it, the fold treats the row as having no settled main-agent fact, and restart or provider restoration cannot recover that state.

Suggested fix
         interrupted: true,
+        mainAgent:
+          payload.mainAgent?.state === 'done'
+            ? payload.mainAgent
+            : { state: 'done', outcome: 'cancellation', stateStartedAt: Date.now() },
         // Why: idle children are display state; dropping them on an inferred interrupt blanks rows a later hook would restore.
         ...(payload.subagents ? { subagents: payload.subagents } : {})
@@
         prompt: payload.prompt,
         agentType: payload.agentType,
+        mainAgent: restored.mainAgent,
         ...(restored.state === 'done' && restored.interrupted ? { interrupted: true } : {}),

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

This re-based head reverts #22452's mainAgent handling in src/main/agent-hooks/server/server-status-inference.ts, and two existing tests fail as a result. Restore the two mainAgent lines from 8352752e54 before this is mergeable.

Reviewed changes

What changed since the prior pullfrog review (abaa5e0 → d11f6ce):

  • Re-based onto 8352752e54 (#22544) — one new commit d11f6ce now sits on current main (f2ac9f29b). The OpenCode 2 lineage shim, the shared double-Escape helper, and the lineage/interrupt test changes are unchanged from the previous review.
  • mainAgent accidentally dropped — the rebase reverted #22452's payload fields in both inferInterrupt and inferQuestionAnswered, so an inferred interrupt no longer records the cancelled main-agent turn.
  • Cosmetic — the shim in status-plugin-setup-source.ts collapsed to a one-liner (behavior identical) and the OpenCode 1 plugin digest was repinned.

Verified this run: pnpm test src/main/agent-hooks/server-interrupt-inference-validation.test.ts fails the two mainAgent cases; the other four PR-touched test files pass (101 tests).

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

…taking over the pane

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.
@nwparker
nwparker force-pushed the nwparker/opencode2-session-lineage branch from d11f6ce to 2f3d174 Compare September 24, 2026 02:50

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

What changed since the prior pullfrog review (d11f6ce → 2f3d174):

  • Restored #22452's mainAgent handling — inferInterrupt and inferQuestionAnswered in src/main/agent-hooks/server/server-status-inference.ts again publish the main agent's own state on an inferred interrupt and on an inferred resolved question, undoing the rebase regression the previous review flagged.
  • Nothing else changed — the range-diff against the prior head shows the OpenCode 2 lineage shim, the shared double-Escape predicate, the tests, and the plugin digests are all unchanged; the branch was re-based, so its merge-base with main is now 8352752e54.

Verification: pnpm test src/main/agent-hooks/server-interrupt-inference-validation.test.ts passes 8/8, and the four PR-touched suites pass 101/101. Both inline threads from the prior review are addressed and resolved.

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@nwparker
nwparker merged commit b0ae7d1 into main Sep 24, 2026
36 checks passed
@nwparker
nwparker deleted the nwparker/opencode2-session-lineage branch September 24, 2026 03:08
flosrn pushed a commit to flosrn/orca that referenced this pull request Sep 25, 2026
…taking over the pane (stablyai#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.

(cherry picked from commit b0ae7d1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant