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)