fix(anthropic-recovery): clear session state after successful summarize 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
This commit is contained in:
@@ -98,9 +98,9 @@ describe("runSummarizeRetryStrategy", () => {
|
||||
}) as typeof setTimeout
|
||||
|
||||
autoCompactState.retryStateBySession.set(sessionID, {
|
||||
attempt: 1,
|
||||
attempt: 0,
|
||||
lastAttemptTime: Date.now(),
|
||||
firstAttemptTime: Date.now() - 119700,
|
||||
firstAttemptTime: Date.now() - 119900,
|
||||
})
|
||||
summarizeMock.mockRejectedValueOnce(new Error("rate limited"))
|
||||
|
||||
@@ -117,6 +117,6 @@ describe("runSummarizeRetryStrategy", () => {
|
||||
//#then
|
||||
expect(timeoutCalls.length).toBe(1)
|
||||
expect(timeoutCalls[0]!.delay).toBeGreaterThan(0)
|
||||
expect(timeoutCalls[0]!.delay).toBeLessThanOrEqual(500)
|
||||
expect(timeoutCalls[0]!.delay).toBeLessThanOrEqual(300)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -114,6 +114,7 @@ export async function runSummarizeRetryStrategy(params: {
|
||||
body: summarizeBody as never,
|
||||
query: { directory: params.directory },
|
||||
})
|
||||
clearSessionState(params.autoCompactState, params.sessionID)
|
||||
return
|
||||
} catch {
|
||||
const remainingTimeMs = SUMMARIZE_RETRY_TOTAL_TIMEOUT_MS - (Date.now() - retryState.firstAttemptTime)
|
||||
|
||||
Reference in New Issue
Block a user