Fix: Handle background_requested pause results in Claude session manager#897
Merged
Conversation
- Filter intermediate background_requested results to prevent premature turn termination - Record usage for paused tasks but keep pause results out of the pipeline - Add regression tests for backgrounded subagent resume flow (#891)
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
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.
closes #891
Summary
Fix for issue #891: Claude turns were ending prematurely when a subagent was moved to the background. The main agent now stays paused and resumes once the background task completes.
Changes
background_requestedintermediate results. These pause results are no longer treated as terminal — usage is recorded but the results stay out of the pipeline, allowing the SDK to resume the same query viatask_notification.Details
When the Claude SDK moves a task to the background, it emits an intermediate
resultwithterminal_reason === "background_requested". The old code treated ANYresultas terminal, which firedendand tore down the session — so the latertask_notificationresumption was lost.The fix filters these pause results before passthrough to the pipeline, preventing premature turn termination while still recording context usage. The event loop continues draining until the genuinely terminal result arrives.
Test Plan
background-resume.test.tsvalidate the pause-and-resume flow