fix(anthropic-recovery): clear session state after successful summarize (fixes #2225)#2789
Merged
code-yeongyu merged 1 commit intodevfrom Mar 24, 2026
Merged
Conversation
…ze and fix timing test - Add missing clearSessionState() call after successful summarize (line 117) Without this, retry state persisted even after success, potentially causing unnecessary retries on subsequent compaction events. - Fix timing-sensitive test: adjust attempt=0 and firstAttemptTime to give proper remainingTimeMs buffer for capped delay calculation. Fixes #2225 Supersedes #2671
There was a problem hiding this comment.
1 issue found across 2 files
Confidence score: 4/5
- This PR is likely safe to merge, but there is a moderate reliability risk from a flaky test rather than production behavior.
- The most severe issue is in
src/hooks/anthropic-context-window-limit-recovery/summarize-retry-strategy.test.ts: a 100ms timeout buffer is too tight and can intermittently fail under CI timing variance. - Pay close attention to
src/hooks/anthropic-context-window-limit-recovery/summarize-retry-strategy.test.ts- increase the remaining-time buffer to reduce CI flakiness.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="src/hooks/anthropic-context-window-limit-recovery/summarize-retry-strategy.test.ts">
<violation number="1" location="src/hooks/anthropic-context-window-limit-recovery/summarize-retry-strategy.test.ts:103">
P1: This 100ms timeout window makes the test highly flaky. Increase the remaining time to provide a safe buffer for CI execution.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
| attempt: 0, | ||
| lastAttemptTime: Date.now(), | ||
| firstAttemptTime: Date.now() - 119700, | ||
| firstAttemptTime: Date.now() - 119900, |
There was a problem hiding this comment.
P1: This 100ms timeout window makes the test highly flaky. Increase the remaining time to provide a safe buffer for CI execution.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/hooks/anthropic-context-window-limit-recovery/summarize-retry-strategy.test.ts, line 103:
<comment>This 100ms timeout window makes the test highly flaky. Increase the remaining time to provide a safe buffer for CI execution.</comment>
<file context>
@@ -98,9 +98,9 @@ describe("runSummarizeRetryStrategy", () => {
+ attempt: 0,
lastAttemptTime: Date.now(),
- firstAttemptTime: Date.now() - 119700,
+ firstAttemptTime: Date.now() - 119900,
})
summarizeMock.mockRejectedValueOnce(new Error("rate limited"))
</file context>
Suggested change
| firstAttemptTime: Date.now() - 119900, | |
| firstAttemptTime: Date.now() - 118500, |
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.
Fixes the bugs found in review of PR #2671.
clearSessionState()after successful summarize — retry state persisted after successSupersedes #2671.
Summary by cubic
Clears retry session state after a successful summarize in the Anthropic context-window recovery so we don’t keep retrying. Also fixes a flaky timing test. Fixes #2225.
clearSessionState()after a successful summarize to prevent persisted retry state and unnecessary retries.attemptto 0 and adjustedfirstAttemptTime; tightened the max expected delay to ≤300ms.Written for commit 69d0b23. Summary will update on new commits.