Uh oh!
There was an error while loading. Please reload this page.
fix(server): abort OpenCode child sessions on interrupt - #7770
Conversation
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
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. Comment |
Uh oh!
There was an error while loading. Please reload this page.
ApprovabilityVerdict: Approved at Macroscope's review found this PR approvable — This is a focused OpenCode cancellation bug fix that preserves parent interruption while also cleaning up surviving child sessions. The production change is isolated to interrupt handling and is covered by targeted regression tests. Notes:
You can add or adjust custom eligibility rules. Learn more. |
juliusmarminge
commented
Sep 1, 2026
Closing because #9005 already added OpenCode child-session cancellation, including children created during the parent abort and nested descendants. Thanks for working on this! |
Summary
Closes#7769.
Why
OpenCode sub-agents use child sessions. Relying only on
session.abort(parent)leaves T3 dependent on the installed OpenCode version propagating cancellation to all children. When that propagation fails, the child provider stream remains alive and can occupy a single-slot local inference server indefinitely.Validation
vp test apps/server/src/provider/Layers/OpenCodeAdapter.test.ts(33 passed)vp run --filter t3 typecheckvp fmt --check apps/server/src/provider/Layers/OpenCodeAdapter.ts apps/server/src/provider/Layers/OpenCodeAdapter.test.tsgit diff --checkNote
Abort child OpenCode sessions on
interruptTurnabortOpenCodeSessionTreeto abort a parent session and then enumerate and abort its children concurrently via the SDK in OpenCodeAdapter.tsinterruptTurnnow calls this tree-abort utility instead of aborting only the parentonAbortandsessionChildrenByIdhooks to simulate children created during parent abortMacroscope summarized a677515.
Note
Medium Risk
Changes turn-interrupt cancellation for OpenCode, which can leave local inference slots occupied if child aborts are missed. Child enumeration errors are swallowed, so a failed
session.childrencall still only aborts the parent.Overview
User interrupt now cancels the OpenCode parent session first, then enumerates remaining child/sub-agent sessions and aborts those too. That covers older OpenCode builds that do not propagate parent abort, and still catches children spawned during the parent abort.
interruptTurnuses a newabortOpenCodeSessionTreehelper. Child listing failures become an empty list (parent abort still succeeds). Individual child aborts are ignored so one failure does not block the rest.Adds a regression test that asserts parent abort is first and that children present at abort time—including one created during parent abort—are aborted afterwards.
Reviewed by Cursor Bugbot for commit a677515. Bugbot is set up for automated code reviews on this repo. Configure here.