Skip to content

fix: preserve condensation summary during task resume (#11487)#11488

Merged
hannesrudolph merged 1 commit intomainfrom
fix/issue-11487-condensation-reset-on-resume
Feb 16, 2026
Merged

fix: preserve condensation summary during task resume (#11487)#11488
hannesrudolph merged 1 commit intomainfrom
fix/issue-11487-condensation-reset-on-resume

Conversation

@SannidhyaSah
Copy link
Collaborator

Related GitHub Issue

Closes: #11487

Roo Code Task Context (Optional)

No Roo Code task context for this PR

Description

When a task completes after condensation and the user sends a new message to resume, the resumeTaskFromHistory() method strips the last user message to merge it with the new user input. However, after condensation the summary IS the last user message (role: "user" with isSummary and condenseId metadata). Stripping it destroys the condensation metadata, causing all condenseParent-tagged messages to become orphaned. getEffectiveApiHistory() then correctly restores them to active status — effectively undoing the condensation and sending the full history to the API.

Fix: Added an isSummary guard as the first branch in the resume flow's message handling. When the last message is a condensation summary, the history is preserved intact and the new user message is added separately, preserving condensation state.

Test Procedure

  1. Unit tests: cd src && npx vitest run core/condense/__tests__/rewind-after-condense.spec.ts — 19 tests pass including 2 new regression tests
  2. Full condense suite: cd src && npx vitest run core/condense/__tests__/ — 122 tests pass
  3. Context management: cd src && npx vitest run core/context-management/__tests__/context-management.spec.ts — 40 tests pass
  4. Message manager: cd src && npx vitest run core/message-manager/index.spec.ts — 26 tests pass

Manual verification steps:

  1. Start a task with multiple tool calls
  2. Let the task complete (attempt_completion)
  3. Trigger "Condense Context" manually
  4. Send a new message
  5. Verify token usage stays at condensed level (not reverting to full history)

Pre-Submission Checklist

  • Issue Linked: This PR is linked to an approved GitHub Issue (see "Related GitHub Issue" above).
  • Scope: My changes are focused on the linked issue (one major feature/fix per PR).
  • Self-Review: I have performed a thorough self-review of my code.
  • Testing: New and/or updated tests have been added to cover my changes (if applicable).
  • Documentation Impact: I have considered if my changes require documentation updates (see "Documentation Updates" section below).
  • Contribution Guidelines: I have read and agree to the Contributor Guidelines.

Screenshots / Videos

No UI changes in this PR

Documentation Updates

  • No documentation updates are required.

Additional Notes

The fix is a 10-line addition that adds an isSummary check before the existing role-based message handling in resumeTaskFromHistory(). It does not change any existing behavior for non-summary messages.

Get in Touch

@SannidhyaSah

@hannesrudolph
Copy link
Collaborator

@roomote please run the review workflow on this.

@roomote
Copy link
Contributor

roomote bot commented Feb 16, 2026

Fixaroo Clock   See task

Reviewed the PR. All checks pass, no issues found.

Tests verified:

  • rewind-after-condense.spec.ts: 19/19 pass (including 2 new regression tests)
  • Full condense suite: 122/122 pass
  • context-management.spec.ts: 40/40 pass
  • message-manager/index.spec.ts: 26/26 pass
  • mergeConsecutiveApiMessages.spec.ts: 3/3 pass
  • TypeScript compilation: clean (no errors)

Review notes:

  • The isSummary guard in resumeTaskFromHistory() correctly prevents the condensation summary from being stripped during task resume
  • Consecutive user messages (summary + new message) are properly handled by the existing mergeConsecutiveApiMessages() before API calls
  • The addToApiConversationHistory() user path already handles the case where the last effective message is a user message (the summary), converting orphaned tool_results to text
  • isSummary is properly typed as boolean | undefined on ApiMessage
  • Tests appropriately verify getEffectiveApiHistory behavior for both the fixed and bug scenarios
  • No breaking changes to existing behavior for non-summary messages

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Feb 16, 2026
@hannesrudolph hannesrudolph merged commit 3e24e21 into main Feb 16, 2026
17 checks passed
@hannesrudolph hannesrudolph deleted the fix/issue-11487-condensation-reset-on-resume branch February 16, 2026 17:21
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Feb 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working lgtm This PR has been approved by a maintainer size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Condensation resets on task resume — full history sent to API (escalating costs)

2 participants