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 — feat(core): add a Code Mode tool that interrupts a session and everything under it by rekram1-node · Pull Request #65718 · anomalyco/opencode

Conversation

@rekram1-node

@rekram1-node rekram1-node commented Nov 23, 2026 •
edited by opencodejr Bot
Loading

Uh oh!

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

Copy link
Copy Markdown
Member

Issue for this PR

Closes #

Type of change

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

What does this PR do?

Adds opencode.session.interrupt, a Code Mode tool (with full_codemode on) that interrupts any session by ID and stops everything under it:

  • interrupts the session's running turn
  • cancels its background jobs: shell commands, subagents, Code Mode scripts, media generation
  • does the same for its child sessions (subagents), all the way down

Jobs are cancelled the way deleting a session cancels them, without completion notices, so nothing wakes the interrupted sessions again. They're cancelled before the interrupt, so none finishes and wakes the session in between, and again right after it, for any its last step started. A session can't interrupt itself or a session above it, since that would stop the call and the caller's own work. The tool isn't pinned, and asks no permission, like opencode.session.rename.

How did you verify your code works?

A throwaway test with a parent, child and grandchild session and jobs on the parent and grandchild: the tool cancelled both jobs and refused to interrupt the calling session or, from the grandchild, the parent. bun run check passes, and the Code Mode, OpenCode tools and session search tests pass.

Screenshots / recordings

If this is a UI change, please include a screenshot or recording.

Checklist

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

Added by the opencode bot (AI-generated).

Related: #36423, #59566

Public API: adds the opencode.session.interrupt Code Mode tool, available with full_codemode only (backwards compatible)

Sorry, something went wrong.

Uh oh!

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

All reactions
@rekram1-node
feat(core): add a Code Mode tool that interrupts a session and everyt…
6f4a6f7
…hing under it
opencodejr[bot]
opencodejr Bot reviewed Nov 23, 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 tool works as described: I ran it through Code Mode execute on a parent → child → grandchild tree with a job on each session. All the jobs were cancelled, and a session that targets itself is refused. Targeted tests and typecheck:tsc for packages/core pass. I didn't run the TUI, since nothing in it changes.

Public API: adds the opencode.session.interrupt Code Mode tool, available only with full_codemode (backwards compatible). The SDK, HTTP API and config are unchanged.

Concern: the self-interrupt guard only compares session IDs, so a subagent can still interrupt itself by targeting its parent or any session above it (inline comment).

Related: #36423, #59566

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread packages/core/src/tool/plugin/session-interrupt.ts Resolved

Uh oh!

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

Comment thread packages/core/src/tool/plugin/session-interrupt.ts Resolved

Uh oh!

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

rekram1-node added 3 commits November 22, 2026 23:33
@rekram1-node
fix(core): refuse interrupting a caller's ancestor and cancel jobs be…
578a384
…fore the interrupt
@rekram1-node
fix(core): use Effect.orElseSucceed in the session interrupt tool
7d67139
@rekram1-node
refactor(core): simplify the session interrupt tool
9656406
opencodejr[bot]
opencodejr Bot reviewed Nov 23, 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.

Both earlier points are fixed. The tool now refuses the caller and any session above it: I tried a child targeting its parent and a grandchild targeting the root, and both were refused. Jobs are now cancelled both before and after the interrupt, so nothing can wake the session in between. Called from a session outside the tree, it stopped all three sessions' jobs; I checked this with a throwaway test. typecheck:tsc and the existing session search and tool registry tests pass. Nothing new to raise.

Public API: adds the full_codemode-only opencode.session.interrupt Code Mode tool (backwards compatible); nothing else changes.

Sorry, something went wrong.

Uh oh!

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

All reactions
@rekram1-node
refactor(core): return a plain message from the session interrupt tool
4935423
@rekram1-node
rekram1-node enabled auto-merge (squash) November 23, 2026 05:49
@rekram1-node
rekram1-node merged commit b575c1f into dev Nov 23, 2026
10 checks passed

Uh oh!

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

@rekram1-node
rekram1-node deleted the session-interrupt-tool branch November 23, 2026 05:52
@BrewTestBot BrewTestBot mentioned this pull request Nov 23, 2026
opencode 2.4.0 Homebrew/homebrew-core#327368
Merged
@amrkmn amrkmn mentioned this pull request Nov 23, 2026
opencode 2.4.0 amrkmn/homebrew-tap#1251
Closed
1 task
This was referenced Nov 23, 2026
OpenCode 2.4.1: deny OpenCode's session interrupt in spawned sessions ivopogace/opencode-courier#665
Closed
OpenCode 2.4.1: courier_stop leaves a stopped session's background jobs running ivopogace/opencode-courier#666
Open
@github-actions github-actions Bot mentioned this pull request Nov 23, 2026
feat: opencode release v2.4.0 sprisa/opencode-server#95
Merged
@artild artild mentioned this pull request Nov 25, 2026
v2: subagent: no cancellation support for background subagents #36423
Open
@opencodejr opencodejr Bot mentioned this pull request Nov 25, 2026
core: interrupting a session does not stop its subagent tasks, and they resume on every service restart #66398
Open
@scottames-github-bot scottames-github-bot Bot mentioned this pull request Nov 27, 2026
chore(deps): update ⬆️ mise-packages scottames/dots#1181
Merged
1 task
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.

Uh oh!

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

1 participant

@rekram1-node
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.