Repository navigation
Fix #1052: retry a rejected summarizer span before giving up on it - #1092
Merged
Merged
Conversation
A reject gate ([validate] REJECTED or [summarizer] REJECTED) is a successful summarizer call that discards real work. Until now save-session.sh advanced the saved position past that span unconditionally, so a span the model refused once was never summarized -- gone for good on the first refusal. Add record_rejected_span(), the same bounded-retry shape record_summary_failure() already uses for a hard call failure, with its own separate marker/threshold (thresholds.max_rejected_retries, default 3): a rejected span is now retried next run, and only after N consecutive rejections of the same span does the position finally advance -- with the raw, unsummarized span text (not just the model's refusal) parked at tmp/dropped-span-*.md so nothing is silently lost. Updates doctor.sh's #1084 "Dropped summarizer spans" message to describe what now happens instead of claiming the span is still gone for good. Pairs every "must not fire" rejection test with the "must fire"/positive-control pair required by this repo's own CLAUDE.md (an accepted summary still advances; 0 retries forever, matching max_summary_failures' own convention). Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Explore and oss:auditor review of 103c35e found six real issues: - A comment directly above the validate-REJECTED branch still claimed "the position still advances", contradicting the bounded retry it introduces three lines below. - doctor.sh's WARN headline said "span(s) dropped by a reject gate" while counting every REJECTED log line, including ones that are retried and never actually dropped. Reworded to "rejection(s) hit a reject gate" (and the OK line to match), with the pinned tests in tests/test_doctor_dropped_summarizer_spans_1052.py updated to the same wording. - docs/configuration.md documented max_summary_failures but not its new sibling max_rejected_retries. Added the missing row. - REJECTED_MARKER was never cleared on a successful resolution path, unlike FAILURE_MARKER (cleared on SKIP and on a successful append). Added the same clears so a stale rejection count cannot survive past the span it belonged to. - test_success_clears_the_rejected_count asserted only that the position advances, not that the marker file was actually removed -- it would have passed even with the bug above present. Strengthened to assert the marker file's absence. - tests/test_marker_write_fifo_653.py's static completeness guard (_MARKERS) was not extended to cover the new REJECTED_MARKER write site, so a future unguarded write to it would go unnoticed by the test that exists specifically to catch that. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
… on final flush, cap and clamp
The rejection counter keyed its span-id on $POSITION (the transcript's
current end), which grows on every save of a live session -- the counter
never saw the same span twice, the count reset to 1 forever, and a
persistently refused span blocked every later span from being saved too.
Keyed on $SKIP_LINES (the span's actual start) instead, which does not
move across retries of the same span; applied the identical fix to
record_summary_failure's own span-id for the same reason.
A rejection on the session's final --force flush had no later save to
retry it, so it was simply lost rather than parked -- now parked
immediately when $FORCE is set. dropped-span-*.md files are capped to the
newest 20, the same retention rejected-*.md already has. 0
("retry forever") for thresholds.max_rejected_retries is clamped to the
default with a log line, since it could otherwise stall saving for the
rest of a session. doctor.sh now reports how many spans are currently
parked and where, and the give-up message also reaches hook-errors.log.
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
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.
Second half of #1052 (first half shipped in #1084 / 735e65c: doctor reports a dropped summarizer span). This half stops
scripts/save-session.shfrom unconditionally advancing the saved read-position past a span the summarizer refused --[validate] REJECTED (not an entry header)or a[summarizer] REJECTEDrefusal/clarification -- which previously dropped a span permanently on its first refusal.What changed
record_rejected_span()(mirrors the existingrecord_summary_failure()): a marker filetmp/last-rejected-spanand a new config thresholdthresholds.max_rejected_retries(default 3, 0 = retry forever -- same convention asmax_summary_failures).[ndc]rejections already use).tmp/dropped-span-<timestamp>-$$.mdand the position advances, with a WARNING logged, so one permanently-refused span cannot block all future saves.scripts/doctor.sh's dropped-span section reworded to describe retry-then-park instead of claiming permanent loss.config.example.jsonanddocs/configuration.mddocument the new threshold.REJECTED_MARKERis now explicitly cleared (rm -f) on both successful-resolution paths, matchingFAILURE_MARKER's own convention.tests/test_marker_write_fifo_653.py's static marker-write completeness guard now also coversREJECTED_MARKER.Tests
Red:
tests/test_save_session_gates.py::TestMalformedOutputNeverReachesMemory::test_malformed_output_still_advances_the_positionfailed (assert None == 904) against the old unconditional-advance behavior.Green:
python3 -m pytest tests/test_save_session_gates.py -q --no-cov-- 37 passed. NewTestRejectedSpanLoopclass covers retry, give-up, parking, infinite-retry (max_rejected_retries=0), and a positive control (an accepted summary still advances after prior rejections). Full targeted run across 9 related test files: 569 passed.Self-reviewed by two spawned reviewers (Explore, oss:auditor); 6 findings, all fixed (stale comment, misleading WARN headline, missing docs row for the new threshold, missing marker cleanup, a weak test, and the marker-write guard coverage gap named above).
Closes #1052.
🤖 Generated with Claude Code
[AI-generated]