fix(task): mark interrupted tool calls as errors in persisted history - #1323
Conversation
When a task is interrupted while an assistant turn's tool calls (e.g. attempt_completion) are unanswered, resumeTaskFromHistory synthesizes tool_result blocks to keep the API conversation valid. Those synthetic blocks lacked is_error: true, so the persisted api_conversation_history.json ends with a success-looking completion while the task list records the task as interrupted - any consumer inferring completion from history is fooled. Set is_error: true on both synthetic tool_result sites (assistant-last and missing-results cases), matching the existing error tool_result pattern used for new_task truncation. Adds two regression tests covering both code paths.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 4 included reviews per hour; 1 remains after this review. 📝 WalkthroughWalkthroughTask resumption now marks synthetic ChangesTask resumption
Estimated code review effort: 2 (Simple) | ~15 minutes Merge Risk: ⚪ Minimal · up to This localized change marks synthesized interrupted tool results as errors and includes regression coverage; no actionable merge-blocking risk remains after normal checks and review. Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Related GitHub Issue
Closes #1283
Description
When a task is interrupted while an assistant turn's tool calls (e.g. an unconfirmed
attempt_completion) are still unanswered,resumeTaskFromHistorysynthesizestool_resultblocks so the persisted API conversation stays valid. Those synthetic blocks did not carryis_error: true, so the persistedapi_conversation_history.jsonended with a success-looking completion while the task list recorded the task as interrupted — and the parent stayed delegated. Any consumer that infers completion from the history (imports, tooling, future delegation logic) was fooled into thinking the task finished.This fix sets
is_error: trueon the two synthetic tool_result sites inTask.resumeTaskFromHistory:tool_usein the final assistant turn,tool_useblocks the final user turn did not answer.This matches the existing error tool_result pattern already used for
new_tasktruncation in the same file, so the task-list status and the persisted conversation now agree.Test Procedure
Added two regression tests in
src/core/task/__tests__/Task.persistence.spec.ts(describe: "resumeTaskFromHistory interrupted tool calls"). Both spy oninitiateTaskLoopto stop the flow right before the agentic loop, feed a persisted history that ends mid-tool-call withinitialStatus: "interrupted", and assert the synthetictool_resultblocks passed to the loop carryis_error: truewith the correcttool_use_id(the second test also asserts a pre-existing partial result is preserved untouched).No manual testing required: the change only alters metadata on persisted history and is fully covered by unit tests. No UI changes, so no visual snapshot needed.
Pre-Submission Checklist
Get in Touch
easonLiangWorldedtech
Summary by CodeRabbit
Bug Fixes
Tests