Skip to content

fix(task): cancel subagent on any abnormal tool exit#12

Merged
CreatorGhost merged 1 commit into
devfrom
subagent-abnormal-exit
Jul 12, 2026
Merged

fix(task): cancel subagent on any abnormal tool exit#12
CreatorGhost merged 1 commit into
devfrom
subagent-abnormal-exit

Conversation

@CreatorGhost

@CreatorGhost CreatorGhost commented Jul 11, 2026

Copy link
Copy Markdown
Owner

Port of upstream anomalyco/opencode#36358.

The task tool's release handler now cancels the child subagent session on ANY abnormal exit (Exit.isFailure) instead of only interrupts — previously Effect.orDie-converted tool errors left orphaned subagent sessions running after the parent moved on.

No overlap with our local runtime subagent model selection changes (different region of task.ts; verified by diff inspection).

Verified: bun test test/tool/task.test.ts (25 pass) and bun typecheck from packages/opencode.

Summary by CodeRabbit

  • Bug Fixes
    • Improved cleanup of background tasks when an operation fails.
    • Prevents lingering task sessions after tool errors, including failures that previously bypassed cleanup.

@coderabbitai

coderabbitai Bot commented Jul 11, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 8598684b-4ff6-4864-b660-c737b1d9c939

📥 Commits

Reviewing files that changed from the base of the PR and between f862420 and 2474be4.

📒 Files selected for processing (1)
  • packages/opencode/src/tool/task.ts

📝 Walkthrough

Walkthrough

Changes

Task cleanup

Layer / File(s) Summary
Failure-exit cancellation
packages/opencode/src/tool/task.ts
TaskTool now cancels subagent or background jobs for any failure exit, including defects, instead of only interrupted exits. Comments explain the cleanup behavior.

Estimated code review effort: 1 (Trivial) | ~5 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately states the main change: canceling subagents on abnormal task exits.
Description check ✅ Passed The description covers the issue, fix, rationale, and verification, though it omits the template's type and checklist sections.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch subagent-abnormal-exit

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install failed. For unrecoverable errors, disable the tool in CodeRabbit configuration.


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.

@CreatorGhost CreatorGhost force-pushed the subagent-abnormal-exit branch from eb1ba2f to 2474be4 Compare July 12, 2026 06:57
@CreatorGhost

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 12, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@CreatorGhost

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 12, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@CreatorGhost CreatorGhost merged commit 26d5937 into dev Jul 12, 2026
4 of 7 checks passed
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