fix(recovery): surgically remove unrecoverable reasoning instead of n…#47
Open
zuhairthabit wants to merge 2 commits into
Open
fix(recovery): surgically remove unrecoverable reasoning instead of n…#47zuhairthabit wants to merge 2 commits into
zuhairthabit wants to merge 2 commits into
Conversation
…uking history The `recover` strategy previously dropped all but the leading system messages and the latest user message whenever any thinking-mode tool-call assistant was missing cached reasoning_content. In long sessions this silently discarded almost the entire conversation (observed in production: 307 of 309 messages dropped), causing the model to "forget" the ongoing task. Replace the nuclear `latest_user` strategy with surgical removal: drop only the assistant message(s) whose reasoning_content cannot be restored, together with their associated tool results, while preserving all surrounding context. The assistant<->tool pairing invariant is maintained (no orphaned tool messages), so upstream requests stay valid. Also: - Only consult the recovery-notice boundary when the first repair pass finds genuine cache misses, so a stale notice no longer permanently truncates later turns. - Suppress the user-facing recovery notice for surgical removals: context is preserved, so there is no need to plant a boundary marker that could trigger truncation on subsequent turns. - Add direct regression coverage for single/multiple misses in long conversations and for the no-tool-calls case; update existing tests that encoded the old nuclear contract. Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
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.
…uking history
The
recoverstrategy previously dropped all but the leading system messages and the latest user message whenever any thinking-mode tool-call assistant was missing cached reasoning_content. In long sessions this silently discarded almost the entire conversation (observed in production: 307 of 309 messages dropped), causing the model to "forget" the ongoing task.Replace the nuclear
latest_userstrategy with surgical removal: drop only the assistant message(s) whose reasoning_content cannot be restored, together with their associated tool results, while preserving all surrounding context. The assistant<->tool pairing invariant is maintained (no orphaned tool messages), so upstream requests stay valid.Also: