GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(core): preserve parent interruption reason in subagents by YMoose · Pull Request #61414 · anomalyco/opencode

Conversation

@YMoose

@YMoose YMoose commented Nov 3, 2026 •
edited by opencodejr Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Issue for this PR

Fixes #61413

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

When owner teardown interrupts a parent waiting for a foreground subagent, cleanup calls the child's user-stop entry point. The parent can report shutdown while the child reports user, releases its execution claim, and projects an idle marker.

Let that cleanup identify its parent and inherit the active parent's recorded interruption reason, using the same shutdown fallback as the parent's terminal classification. Ordinary user stops still report user. No HTTP API, event schema, or database schema changes.

How did you verify your code works?

  • Added regression coverage in packages/core/test/subagent-lifetime.test.ts for both user and shutdown parent interruptions of a foreground subagent (verifying SessionEvent.Execution.Interrupted reasons, time_suspended execution claims, idle_outcome, and projected idle context messages).
  • bun run script/test.ts test/subagent-lifetime.test.ts --rerun-each 10 --randomize in packages/core: 50 passed.
  • Focused session/subagent suites (79 tests) and full @opencode/core suite (6,881 passed, 0 failed).
  • Root bun run check: passed (lint and all 35 typecheck tasks).

Visual

<svg xmlns="http://www.w3.org/2000/svg" width="240" height="72" viewBox="0 0 240 72">
  <style>
    .flow { animation: flow 2s ease-in-out infinite; }
    @keyframes flow { 50% { opacity: .3; } }
    @media (prefers-reduced-motion: reduce) { .flow { animation: none; } }
  </style>
  <g fill="none" stroke="currentColor" opacity=".6">
    <rect x="5" y="10" width="91" height="52" rx="7"/>
    <rect x="144" y="10" width="91" height="52" rx="7"/>
    <path class="flow" d="M104 36h32m-6-5 6 5-6 5"/>
  </g>
  <g fill="currentColor" font-family="sans-serif" font-size="11" text-anchor="middle">
    <text x="50" y="30">Parent</text><text x="190" y="30">Subagent</text>
    <text x="50" y="49">shutdown</text><text x="190" y="49">shutdown</text>
  </g>
</svg>

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Added by the opencode bot (AI-generated).

Related: #36349

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@YMoose
fix(core): preserve parent interruption reason in subagents
70b1374
When owner teardown interrupts a parent waiting for a foreground subagent,
cleanup calls the child's user-stop entry point. The parent can report
`shutdown` while the child reports `user`, releases its execution claim,
and projects an idle marker.

Let that cleanup identify its parent and inherit the active parent's
recorded interruption reason, using the same shutdown fallback as the
parent's terminal classification. Ordinary user stops still report `user`.
@opencodejr opencodejr Bot mentioned this pull request Nov 3, 2026
core: foreground subagent interrupted by parent shutdown is recorded as a user stop #61413
Closed
opencodejr[bot]
opencodejr Bot reviewed Nov 3, 2026
View reviewed changes

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

The fix works and is well scoped. I reproduced the bug by running the new test against the base: the shutdown case fails there because the child is recorded as a user stop. With this PR, the subagent-lifetime tests and the related coordinator, runner and owned-session suites pass (295 tests), and tsc is clean for packages/core.

I also checked that a user stop still comes through as user. The coordinator stores the parent's reason before it interrupts the parent's fiber, so the subagent's cleanup always sees it. The shutdown fallback only applies when the parent's execution was interrupted with no reason recorded, because a foreground subagent's tool fiber is only interrupted when the parent's step is. Nested subagents also inherit correctly.

Public API: unchanged apart from a new optional parentID field in the options of the internal core Session/SessionExecution interrupt method, which existing callers don't need to change for. The HTTP API, SDK, events and database schema are unchanged.

No blocking concerns.

Related: #36349

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@YMoose

YMoose commented Nov 22, 2026

Copy link
Copy Markdown
Author

Closing: superseded by the upstream subagent lifetime refactor. #63382 (always run subagents in the background), #63223 and #63392 removed the foreground subagent path this fix hooked into — children now run as background Jobs whose parent teardown no longer interrupts them at all (only an explicit caller cancel does, and the coordinator grew the equivalent interruption(key) API). The scenario this PR fixed can no longer occur.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@YMoose YMoose closed this Nov 22, 2026
@github-actions github-actions Bot mentioned this pull request Nov 23, 2026
📊 AI CLI 工具社区动态日报 2026-11-23 litang9/big_model_radar#746
Open
@YMoose
YMoose deleted the subagent-interrupt-reason branch November 23, 2026 01:11
@GeneralProtectionFault GeneralProtectionFault mentioned this pull request Nov 24, 2026
[FEATURE]:Restore Foreground Subagent Execution #64073
Open
1 task done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@opencodejr opencodejr[bot] opencodejr[bot] left review comments

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

core: foreground subagent interrupted by parent shutdown is recorded as a user stop

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@YMoose
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.