fix(warp): don't send task-complete while background tasks are still running - #85
Open
neeilya wants to merge 1 commit into
Open
fix(warp): don't send task-complete while background tasks are still running#85neeilya wants to merge 1 commit into
neeilya wants to merge 1 commit into
Conversation
…running Claude Code fires `Stop` whenever the main agent's turn ends, including turns that launched background sub-agents or shells that are still running, and again each time one of them finishes and wakes the main agent. `on-stop.sh` sent a task-complete notification on every one of those, so a prompt that fans out to three sub-agents produced four banners, three of them while work was still in progress. Warp's session status also flipped to Complete and back to Working with each one. Claude Code >= 2.1.145 includes a `background_tasks` array in Stop hook input listing in-flight sub-agents, shells, monitors, workflows and teammates. Use it: if any entry has status `running`, exit without notifying; the Stop that fires once the last task completes sends the single real notification. Older Claude Code lacks the field, so nothing changes there. Only `running` counts, so an unknown status fails open toward notifying rather than going silent. Applies to both the structured and legacy Stop scripts, and adds unit tests for the helper plus a routing test for on-stop.sh. Closes warpdotdev#67 Closes warpdotdev#82
neeilya
marked this pull request as ready for review
September 6, 2026 11:57
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
on-stop.shsends the task-complete payload on every Claude CodeStopevent. ButStopfires whenever the main agent's turn ends, including:So a prompt that fans out to three sub-agents produces four "task complete" banners, three of them while work is still in progress, and Warp's session status flips to Complete and back to Working each time. Reported in #67 and #82.
Fix
Claude Code ≥ 2.1.145 includes a
background_tasksarray in Stop hook input listing in-flight sub-agents, shells, monitors, workflows and teammates (hooks reference). This is the official signal #82 asked for.scripts/has-background-work.shexposeshas_background_work "$INPUT", true when any entry hasstatus == "running".on-stop.shandlegacy/on-stop.shexit silently when it is true. The Stop that fires after the last task completes has an empty array and sends the one real notification.runningcounts, so an unfamiliar status fails open toward notifying rather than going silent.No changes to the payload schema or protocol version.
Testing
tests/test-hooks.sh: 66 passed, 0 failed. Adds unit tests for the helper (field absent, empty, running subagent, running shell, non-running entry, malformed input) and a routing test thaton-stop.shemits nothing with a running task and emits thestopterminalSequenceonce the array is empty.status: "running") and ran them through both Stop scripts: suppressed with tasks running, notification sent with the array emptied.v0.2026.09.02.08.27.stable_01with plugin 2.2.0 (unpatched): a prompt launching three background sub-agents produced four banners, matching the reproduction in Stop hook notifies on every sub-agent completion (<task-notification>re-invocations), spamming a banner per sub-agent #67.Out of scope
session_crons(scheduled wake-ups from/loop,ScheduleWakeup,CronCreate) is left alone: a session idling between cron fires is arguably done with the current task, so it still notifies.Closes #67
Closes #82