Repository navigation
fix: stop agentic sessions from silently never saving (#147) - #148
Merged
Merged
Conversation
added 2 commits
July 25, 2026 16:16
save-position is only reached on a successful save, but the cooldown marker is written before every gate. Both early exits after extraction therefore left the read cursor untouched while the throttle advanced — so the next run re-extracted the identical span and exited identically, once per cooldown window, for the life of the session. One asymmetry, two user-visible failures. 0 exchanges: nothing to summarize, so advance the position. Nothing is lost and the loop breaks. Few human turns but many exchanges: this is what every agentic session looks like, and it never cleared min_human_messages, so the plugin's core function silently never ran — the complaint at the heart of #125. A span of at least thresholds.min_exchanges_without_human (default 30, 0 disables) now saves regardless of the human count. Work is not only measured in human turns. The under-threshold skip deliberately still does NOT advance the cursor: those exchanges are real content, just not enough of it yet, and keeping the cursor lets them be summarized together with the turns that follow. Re-read cost is bounded by the save cooldown. Tests drive the real script against a stubbed pipeline.shell, so the gates are exercised without a Haiku call. Both new behaviours fail on main. Co-Authored-By: Max <noreply>
… failures Review of !148 found two defects. 1. The 0-exchange position advance ran unconditionally, so `--dry` wrote last-save.json — a dry run must never move the cursor. #147 says so in as many words, and the previous code was implicitly safe because no save-position call existed on that path at all. Guarded. 2. The PR claimed to close #147 while leaving its most-cited case untouched: a failing Haiku call never advanced the position, so the same span was re-extracted and failed identically forever, and no later span could ever be saved. That is @VictorVvdl's month-long repro. Advancing on the first failure would silently drop memory for a transient error, so instead consecutive failures against the same (session, position) are counted; past thresholds.max_summary_failures (default 3, 0 retries forever) the span is dropped with a WARNING naming the threshold, and everything after it can still be recorded. Losing one span is bad; losing every future span is worse. A successful save clears the count — and so does a SKIP, which a new test caught: SKIP advances the position, so leaving a stale count there would trip the give-up threshold early on the next single failure. Also hardened MIN_HUMAN/MIN_EXCHANGES against a non-numeric config value, which under set -e would abort the script and turn a typo into "memory just stopped". Co-Authored-By: Max <noreply>
This was referenced Jul 25, 2026
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.
Closes #147, and finishes what v0.8.5 left open on #125.
The asymmetry
save-positionis only reached on a successful save (save-session.sh:211), but the cooldown marker is written before every gate (:131). So both early exits after extraction advanced the throttle and left the read cursor where it was — and the next run re-extracted the identical span and exited identically. Once per cooldown window. For the life of the session.One asymmetry, two failures users actually hit:
0 exchanges → now advances the position. There is nothing to summarize in an empty span, so nothing is lost and the loop breaks.
Many exchanges, few human turns → this is the shape of every agentic session, and it never cleared
min_human_messages, so the plugin's core function silently never ran. That is the complaint at the heart of #125, and v0.8.5 did not touch it. A span of at leastthresholds.min_exchanges_without_human(default 30,0disables) now saves regardless of the human count — work is not only measured in human turns.What deliberately did not change
The under-threshold skip still does not advance the cursor. My own acceptance criteria in #147 said "advance the position regardless of gate outcome" — that turned out to be wrong. Those exchanges are real content, just not enough of it yet; advancing would drop them from every future extract. Keeping the cursor lets them be summarized together with the turns that follow, and the re-read cost is bounded by the save cooldown.
Tests
tests/test_save_session_gates.pydrives the real script against a stubbedpipeline.shell, so the gates are exercised without a Haiku call: empty span advances, under-threshold skip does not advance, agentic span saves, the fallback threshold is configurable and can be disabled with0, and the ordinary path is untouched. The two new behaviours fail onmain.521 passed locally.
Post-review additions
An adversarial review after opening found two defects, both fixed here:
--dryadvanced the position. The 0-exchange advance ran unconditionally, so a dry run wrotelast-save.json— #147 explicitly requires it must not, and the old code was implicitly safe because nosave-positioncall existed on that path at all. Guarded, with a test.The claim to close #147 was inaccurate. A failing Haiku call still never advanced the position — @VictorVvdl's month-long repro, and the issue's most-cited scenario. Advancing on the first failure would silently drop memory for a transient error, so consecutive failures against the same
(session, position)are counted instead: pastthresholds.max_summary_failures(default 3,0retries forever) the span is dropped with a WARNING naming the threshold, and everything after it can still be saved. Losing one span is bad; losing every future span is worse.Writing that test surfaced a third thing: a SKIP advances the position, so it must clear the failure count too — otherwise a stale count sits there and the next single failure trips the give-up threshold early.
Also hardened
MIN_HUMAN/MIN_EXCHANGESagainst a non-numeric config value, which underset -ewould abort the script and turn a config typo into "memory just stopped".526 passed, 12/12 CI green.