Skip to content

fix(anthropic-recovery): clear session state after successful summarize (fixes #2225)#2789

Merged
code-yeongyu merged 1 commit intodevfrom
fix/2671-clearSessionState
Mar 24, 2026
Merged

fix(anthropic-recovery): clear session state after successful summarize (fixes #2225)#2789
code-yeongyu merged 1 commit intodevfrom
fix/2671-clearSessionState

Conversation

@code-yeongyu
Copy link
Copy Markdown
Owner

@code-yeongyu code-yeongyu commented Mar 24, 2026

Fixes the bugs found in review of PR #2671.

  1. CRITICAL: Add missing clearSessionState() after successful summarize — retry state persisted after success
  2. MAJOR: Fix timing-sensitive test (attempt: 0, adjusted firstAttemptTime)

Supersedes #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.

  • Bug Fixes
    • Added clearSessionState() after a successful summarize to prevent persisted retry state and unnecessary retries.
    • Updated test: set attempt to 0 and adjusted firstAttemptTime; tightened the max expected delay to ≤300ms.

Written for commit 69d0b23. Summary will update on new commits.

…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
@code-yeongyu code-yeongyu merged commit 03dc903 into dev Mar 24, 2026
5 checks passed
@code-yeongyu code-yeongyu deleted the fix/2671-clearSessionState branch March 24, 2026 07:23
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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,
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai bot Mar 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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,
Fix with Cubic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Claude models keeps repeatedly performing compaction in a loop.

1 participant