Skip to content

fix: clear writerFailures counter in resetThresholds#806

Open
0xSkybreaker wants to merge 1 commit into
XiaomiMiMo:mainfrom
0xSkybreaker:fix/issue-734-reset-thresholds-writer-failures
Open

fix: clear writerFailures counter in resetThresholds#806
0xSkybreaker wants to merge 1 commit into
XiaomiMiMo:mainfrom
0xSkybreaker:fix/issue-734-reset-thresholds-writer-failures

Conversation

@0xSkybreaker

Copy link
Copy Markdown

@

Summary

Fixes #734SessionPrune.resetThresholds(sessionID) clears crossed and maxCrossed but leaves writerFailures untouched, causing stale failure counts to carry over into a fresh checkpoint threshold cycle after discard+rebuild.

Changes

  • packages/opencode/src/session/prune.ts: Add writerFailures.delete(sessionID) to resetThresholds so all per-session checkpoint threshold state resets together
  • packages/opencode/test/session/prune.test.ts: Add targeted test that records 2 writer failures, calls resetThresholds, then verifies the next cycle has a full 3-retry budget (not just 1 remaining)

Verification

The new test exercises the exact scenario described in the issue:

  1. Record 2 checkpoint writer failures for a session (counter = 2)
  2. Call resetThresholds(sessionID)
  3. Fire 3 more times — all 3 land (counter was reset to 0, not inherited from 2)
  4. Fire once more — rejected at cap (counter = 3)

Without the fix, step 3 would only allow 1 more fire before hitting the cap.

🤖 Generated with Claude Code@

@
fix: clear writerFailures counter in resetThresholds

resetThresholds(sessionID) clears crossed and maxCrossed but
leaves writerFailures untouched. A session entering a fresh
checkpoint threshold cycle after rebuild could inherit stale
failure counts, hitting the retry cap prematurely.

Add writerFailures.delete(sessionID) so all per-session checkpoint
threshold state resets together.

Add test that records failures, calls resetThresholds, then
verifies the next cycle starts with a fresh failure count.

Closes: XiaomiMiMo#734
@
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