Repository navigation
[Fix] Delegation continues when the parent's pending tool results cannot be saved - #2189
PierrunoYT wants to merge 1 commit into
Conversation
…sults cannot be saved A failed flush plus a failed retry save used to be non-fatal: the parent was disposed and later resumed from disk with a tool_use that had no tool_result, which providers reject with a 400. Delegation now stops before anything is disposed or created, so the parent stays open with its pending results and the delegation can be retried. A flush that already appended the results to history but could not save them now only saves again, so a retry no longer appends a second copy. Fixes Zoo-Code-Org#2188 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 16 minutes. View limit details
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. Comment |
Review statusThanks for contributing. This comment tracks the review sequence and the next action. Current step: Required CI passed. Waiting for automated review of the latest commit. If automated review does not start, a maintainer must restart it. Review-state labels are managed by this workflow; do not edit them manually. |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Related GitHub Issue
Closes: #2188
Description
A parent task can have tool results that are not yet in its API history when it starts a subtask. Delegation saves them first. If that save failed and the retry save also failed, delegation continued. The parent was disposed. Later, the parent resumed from disk. Its history ended with a
tool_usethat had notool_result. Providers reject this with a 400 error.This PR makes delegation stop in that case. The behavior is a choice. Please confirm it.
ClineProvider.delegateParentAndOpenChild): The method flushes the pending results. If the flush fails, it retries the save and flushes once more. Saving the existing history does not add results that never reached it, so the second flush is needed. If the results are still not saved, the method throws before it disposes the parent or creates a child. The parent stays open with its pending results in memory. The user can try the same delegation again.new_taskreturns this error through its normal error handling: "Could not start the subtask: the parent task's pending tool results could not be saved to disk. The parent task stays open and nothing was delegated. Check disk space and permissions, then try again."Task.flushPendingToolResultsToHistory): A flush can append the results to history and then fail to save them. A second flush used to append the same results again. The task now remembers this state. A repeat flush only saves the history. This makes the retry safe. The state resets when the next API request starts.tool_usecan still have a result that is pending, so the normalizer must leave it alone.Review points:
Test Procedure
Unit tests:
src:npx vitest run __tests__/ClineProvider.delegation.spec.ts core/task/__tests__/Task.persistence.spec.tsOther checks:
check-typespasses insrc. ESLint passes with no new suppressions. Thecore/webview,core/task,core/tools, and__tests__suites pass.Pre-Submission Checklist
Documentation Updates
🤖 Generated with Claude Code