Repository navigation
Refuse a thread summary that leaves older messages in full above it - #6049
Merged
Merged
Conversation
A summary of a long thread could fold a middle stretch and leave older messages, just after the thread's first, in full above it (#5531). `leaf thread summarize` admitted any contiguous range, and #5583 fixed only the hint's choice of range, so a range the agent picked itself still left the gap. `events.summary_gap` now states where a summary may start: every spoken turn older than it must lie in a summary, apart from the thread's opening message, which says what the thread is about. Progress a later reply completed is drawn nowhere, so it does not count; pending progress is drawn, so it does; a reaction is a mark on another message. Admission reads the summaries that will stand once the new one replaces those it overlaps, so re-summarizing a later part of an earlier summary cannot uncover its start. The refusal, `summary-gap`, names the range admission would take, from the oldest message left out through the requested end, so the agent's next attempt succeeds. The delivery's `summary_hint` keeps the same rule through the same function. It names the earliest run long enough to suggest that admission would take, and nothing when that run is too short, where it used to suggest a later run that would have left the gap. The issue's second report, a hint overlapping a summary in force, does not reproduce: runs stop at covered messages, and the new test pins a hint ending at the message before a summary in force. A hint in a delivery captured before a summary was written, or one written after a rewrite retired a summary's prose, can span where that summary stood, which is the likeliest source. Tests (tests/model/test_thread_reading.py): - `test_a_summary_leaves_no_older_discussion_in_full_above_it` fails on main, where the gap-leaving range is admitted, and passes here. It covers the opener, a reaction and completed progress above an admitted summary, a range that would replace a summary and uncover its start, and pending progress counting. - `test_a_summary_hint_names_only_a_range_admission_takes` replaces `test_summary_hint_takes_the_earliest_qualifying_run`, whose setup summarized a middle range that admission now refuses. Its short-run case fails on main, where the hint names a later run that admission refuses. - `test_a_fold_pressed_in_a_thread_s_view_stays_under_the_press` summarized a range leaving the agent's first answer above it; it now starts at that answer. The rule is stated in events.md, the threads reference ("Summarize a long discussion") and the command's help.
…mmary A summary replaces those it overlaps whole, so one that ended inside an earlier summary uncovered that summary's tail, which then stood in full above a later summary. With S1 over m1–m5 and S2 over m6–m10, summarizing m1–m3 was admitted and the thread read: opener, summary, m4, m5, S2. Refusing m2–m3 suggested m1–m3, which led to the same gap. `events.summary_gap` now returns every message the summaries in force leave in full above the last of them, rather than above one summary's start, so admission checks the whole thread as it will read once the new summary stands. Its refusal names the requested range widened over every message it would leave, and says the prose must cover the added messages. A summary that covers only completed progress is drawn nowhere, so no message stands above it. The hint asks the same question of a run with the run added to the summaries in force. Folds without prose are held to the rule too; the threads reference, events.md and the command's help say so. The threads reference keeps "Leave out messages whose wording still matters" as it was, with the rule after it. The site's "How it works" page states the rule, and no longer says completed progress folds behind "Show N progress messages", which #3534 removed. `test_a_summary_inside_an_earlier_one_leaves_no_gap_above_a_later_one` reproduces both cases from review: on the previous commit, summarizing m1–m3 is admitted, and refusing m2–m3 names no range that closes the gap. It passes here, and the summaries then cover m1–m10. A randomized check run against this commit (not added to the suite) found no counterexample. It made 140 random threads with replies, progress, reactions, user edits and undos, and 1,448 random summary attempts. Of these, 620 were refused for a gap, and every refusal's named range was admitted. No admitted summary left a message in full above a summary, judged from the served thread as the panel draws it. In the half that checked it, each of 310 refusals matched that reading of the summary refused. All 63 hints it followed were admitted.
leaf-agent
reviewed
Nov 15, 2026
leaf-agent
left a comment
Collaborator
There was a problem hiding this comment.
A gap left by a retired summary can leave a long thread with no summary_hint from then on (inline). The widened range admission names on refusal would fix it.
max-sixty
marked this pull request as ready for review
November 15, 2026 19:08
The hint could stop for good. When a rewrite retired a summary's prose, its messages stood uncovered above a later summary. If that stretch was too short to suggest, every longer run after it would leave the stretch above a summary, so the hint skipped them all, and no delivery carried a hint however long the thread grew. `events.summary_range` replaces `summary_gap`. Given the summaries that stand once a summary is written, it returns the range that summary must cover: the asked range, widened over every message left in full above the last drawn summary. Admission refuses a range this widens and names the wider one. The hint now takes the earliest run that is long enough and suggests the range `summary_range` gives for it, so in that state it names the later run widened over the short stretch, replacing the summary between them. A hint may now sit on top of a summary in force, but only to close a gap above it, and following it is admitted as admission's own refusal range is. The refusal no longer names one left message, since the range it names says which messages to add. `test_a_summary_hint_names_only_a_range_admission_takes[older-run-too-short]` now expects that widened hint and admits it; on the previous commit the digest carried no hint. The reviewer's randomized check, run against this commit and not added to the suite, found 537 gap refusals with every named range admitted, no admitted summary leaving a message above a summary, and 137 hints followed, none refused and none leaving a gap. events.md says the hint may replace a summary to close a gap, and that the rule reads the last drawn summary.
leaf-agent
approved these changes
Nov 15, 2026
max-sixty
added a commit
that referenced
this pull request
Nov 21, 2026
…a survey finds it (#6630) The refusal survey of 16 November listed `findings.py`'s codes and their hits in agent transcripts, so it missed the two summary mechanisms #6617 later removed that refused nothing: served state's `protected`, which forced a fold open, and the rule that only a summary's prose read the messages it folded. Neither prints a finding or leaves a trace in a transcript. The third, `summary-gap`, it found and kept as Max's: #5531, an issue an agent wrote in his name, described the outcome, and an agent's sweep (#6049) made that a refusal. This adds "Code that chooses for the agent" to root `AGENTS.md`'s "Regular maintenance": the shapes such code takes besides a refusal, each judged by "Leaf's role" whoever asked for it, and where the ones that print nothing show, in what the page draws set against what the agent's write declared. "What it buys" now credits an outcome the maintainer asked for rather than any request. Worth weighing: an earlier version also added a `/developing-leaf` section walking `findings.py` and the served-state schema; Max asked for it to come out. In fresh sessions running his 16 November request on the tree before #6617, that walk found `protected` once in two runs, against none in five without it, so the bullet alone may leave surveys missing such code. Max asked for this investigation and for the skill section's removal; nobody else has read it. No tests cover maintainer guidance; pre-commit passes. > _This was written by Claude Code on behalf of max-sixty_ --------- Co-authored-by: Claude Opus 5.5 <[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.
A summary of a long thread could fold a middle stretch and leave older messages, just after the thread's first, in full above it.
leaf thread summarizeadmitted any contiguous range, and #5583 fixed only how the hint picks its range, so a range the agent picked itself still left the gap.The rule. No message but the thread's opening one may stand in full above a summary.
events.summary_rangeholds the rule. Given the summaries that stand once a new summary is written, it returns the range that summary must cover: the asked range, widened over every message left in full above the last drawn summary. Admission and the hint both call it.--text '') are held to the rule too. Completed progress is already hidden (Hide ephemeral messages when their answer arrives #3534), so a fold is no longer needed to tuck it away.Admission. Admission checks the thread as it will read once the new summary stands and has replaced the summaries it overlaps. So a summary that ends inside an earlier one can't uncover that one's tail above a later summary. When
summary_rangewidens the asked range, admission refuses withsummary-gapand names the wider range. That range is always admitted, because everything it replaces lies inside it and the messages it adds were all above the last summary. For example, with summaries over m1–m5 and m6–m10, a request for m1–m3 is refused with:The hint.
summary_hinttakes the earliest run of uncovered messages that is long enough to suggest, and names the rangesummary_rangegives for it, which is the range admission takes. Before, it could suggest a later run that left the gap. Without the widening, a short stretch left above a summary would stop the hint for good: when a rewrite retires a summary's prose, its messages stand uncovered above a later summary, and every longer run after them would leave them there. Now the hint names that later run widened over the stretch, replacing the summary between them.Hints over a summary in force. The issue expected that a hint never overlaps a summary in force. A hint now does exactly that when it must close a gap above that summary; otherwise it still stops at covered messages. The issue's own report of an overlapping hint doesn't reproduce on the code it was seen on, where every run stopped at covered messages. The likeliest source is a hint computed before that summary stood: a delivery captured before the summary was written, or a summary whose prose a rewrite or a taken-back message retired. That is an inference, not something I reproduced from the reported page.
Call Max may reverse. The thread's opening message may stay outside a summary, so a summary can start at its second message. Requiring the opener to be folded too would mean changing only the
thread["id"]clause insummary_range.Prose
events.md, the threads reference ("Summarize a long discussion") and the command's--help(regtest snapshot updated) state the rule, including folds without prose.Tests
In
tests/model/test_thread_reading.py:test_a_summary_leaves_no_older_discussion_in_full_above_itfails on main, where the gap-leaving range is admitted. It covers the opener, a reaction and completed progress above an admitted summary, a range that would replace a summary and uncover its start, and pending progress counting. Each refusal's named range is then admitted.test_a_summary_inside_an_earlier_one_leaves_no_gap_above_a_later_onecovers summarizing m1–m3, and m2–m3, inside a summary over m1–m5 with another over m6–m10. On the PR's first commit, which checked only above the new summary's start, m1–m3 is admitted, and the m2–m3 refusal names a range that leaves the same gap. Here each refusal names m1–m5, and once that is admitted the summaries cover m1–m10.test_a_summary_hint_names_only_a_range_admission_takesreplacestest_summary_hint_takes_the_earliest_qualifying_run, whose setup summarized a middle range that admission now refuses. A rewrite retires a summary's prose and leaves its run above a later fold. Where that run is long enough, the hint names it. Where it is too short, the hint names the next run widened over it, which no earlier version of this PR suggested. Both hinted ranges are admitted.test_a_fold_pressed_in_a_thread_s_view_stays_under_the_press(browser) summarized a range that left the agent's first answer above it. It now starts at that answer. I read every otherthread summarizecaller in the tests: each starts at the opener or its first reply.I also ran a randomized check against the final code, without adding it to the suite. It made random threads with replies, progress, reactions, user edits and undos, and tried random summary ranges and every hint it was given:
Ran
uv run pytest tests/model/test_thread_reading.py tests/model/test_model_folds.py tests/model/interact_contract/test_layer_contract.py tests/model/test_interact_layer.py tests/model/test_product_page.py -n 4, plus the summary and hint tests intest_interact_product.py: 279 passeduv run pytest tests/browser/test_render_floating_panel.py tests/browser/threads/test_summaries.py -n 2 -k "fold_pressed_in_a_thread_s_view or keeps_completed_progress_hidden or search_and_leaf_s_travel or later_summary_replaces": 4 passedpre-commiton the changed filesNot verified
evals/. The summary cases there (thread-summary-after-topic-drift,thread-summary-preserves-needed-exchange) expect ranges starting at the opener, which the rule still admits.tests/journeys/threads/test_layout.pyand the rest of the browser summary tests didn't run. Each starts at the opener or its first reply, which I checked by reading.tests/model/test_product_page.pypasses.Closes #5531