Skip to content

Conversation

@hannesrudolph
Copy link
Collaborator

Summary

Fixes a bug where the else if chain in attemptApiRequest() prevented both error AND truncation events from being recorded when context condensation fails but sliding window truncation succeeds as a fallback.

Problem

When manageContext() returns both:

  • error: The error message explaining why condensation failed
  • truncationId: The ID of the truncation that happened as fallback

Only the error was shown because of the else if chain. This meant the sliding_window_truncation clineMessage was never created.

Impact

Since MessageManager.collectRemovedContextEventIds() looks for sliding_window_truncation clineMessages to find truncation IDs for cleanup:

  • Rewind couldn't find the truncation ID
  • Messages tagged with truncationParent stayed hidden forever
  • Users couldn't recover their conversation context by rewinding

Fix

Changed else if to separate if statements so both events can be recorded:

// Before (bug):
if (truncateResult.error) {
    await this.say("condense_context_error", truncateResult.error)
} else if (truncateResult.summary) {  // <-- blocks truncation when error exists
    ...
} else if (truncateResult.truncationId) {
    ...
}

// After (fix):
if (truncateResult.error) {
    await this.say("condense_context_error", truncateResult.error)
}
if (truncateResult.summary) {  // <-- independent check
    ...
} else if (truncateResult.truncationId) {
    ...
}

Testing

All 158 related tests pass:

  • 55 context-management tests ✓
  • 26 message-manager tests ✓
  • 77 condense tests ✓

…ucceeds

The else-if chain in attemptApiRequest() prevented both error AND truncation
events from being recorded when context condensation fails but sliding window
truncation succeeds as a fallback.

When manageContext() returns both 'error' (condensation failed) and
'truncationId' (truncation happened as fallback), only the error was shown
because of the else-if chain. This meant the sliding_window_truncation
clineMessage was never created, breaking rewind functionality since
MessageManager.collectRemovedContextEventIds() couldn't find the truncation ID
to clean up orphaned truncationParent tags.

Fix: Change 'else if' to separate 'if' statements so both events can be
recorded, allowing rewind to properly restore hidden messages.
@dosubot dosubot bot added size:XS This PR changes 0-9 lines, ignoring generated files. bug Something isn't working labels Jan 26, 2026
@roomote
Copy link
Contributor

roomote bot commented Jan 26, 2026

Oroocle Clock   See task on Roo Cloud

Review complete. No issues flagged.

  • No issues found

Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues.

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Jan 27, 2026
@hannesrudolph hannesrudolph merged commit bd29766 into main Jan 27, 2026
18 checks passed
@hannesrudolph hannesrudolph deleted the fix/truncation-event-recording-on-condense-failure branch January 27, 2026 00:19
@github-project-automation github-project-automation bot moved this from Triage to Done in Roo Code Roadmap Jan 27, 2026
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Jan 27, 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:XS This PR changes 0-9 lines, ignoring generated files.

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants