Skip to content

fix(opencode): clear writer-failure counter in resetThresholds#913

Open
hzhongzhong wants to merge 1 commit into
XiaomiMiMo:mainfrom
hzhongzhong:fix/reset-thresholds-clears-writer-failures
Open

fix(opencode): clear writer-failure counter in resetThresholds#913
hzhongzhong wants to merge 1 commit into
XiaomiMiMo:mainfrom
hzhongzhong:fix/reset-thresholds-clears-writer-failures

Conversation

@hzhongzhong

Copy link
Copy Markdown

Fixes #734

Problem

SessionPrune.resetThresholds clears crossed and maxCrossed but leaves writerFailures (keyed by the same sessionID) untouched. A session that starts a fresh checkpoint threshold cycle therefore inherits the previous consecutive writer-failure count, so a later failure can reach the retry cap earlier than expected and a stale in-memory entry lingers until a success clears it or the process restarts.

Fix

Drop the writer-failure count alongside the other per-session threshold state:
writerFailures.delete(sessionID).

Verification

Added a SessionPrune.fireCheckpoints test that records two writer failures, calls resetThresholds, then drives three more failures — expecting the fresh cycle to enqueue all three before the cap (enqueueCount 5). It failed before the fix (counter carried over → stalled at 3) and passes after.
bun test test/session/prune.test.ts → 10 pass. Related checkpoint/rebuild suites green (52 pass across 7 files).

SessionPrune.resetThresholds cleared `crossed` and `maxCrossed` but left
`writerFailures` (keyed by the same sessionID) untouched. A session that
started a fresh checkpoint threshold cycle therefore inherited the previous
consecutive writer-failure count, so a later failure could hit the retry cap
earlier than expected and leave a stale in-memory entry.

Drop the writer-failure count alongside the other per-session threshold state.

Fixes XiaomiMiMo#734

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.

SessionPrune.resetThresholds leaves stale checkpoint writer failure counters

1 participant