Repository navigation
Let the summary fork choose what a thread's summary folds - #6401
Merged
Merged
Conversation
In Claude Code a fork writes a long thread's summary, and it folded
exactly the range `thread_context.summary_hint` picks: the earliest run
of at least four unsummarized messages, or two or more holding 2,000
characters, ending before the last two turns. So a cutoff on the
thread's length decided what the user reads in full, and every long
thread folded its opening message unless an earlier summary had left it
out.
Max decided that what a summary folds is the agent's judgment, aimed at
compressing what compresses most, and asked that this be Leaf's general
principle. Now the fork gets the hint as a suggestion and answers with
its own `from` and `through`, by the agent's guidance for what to fold,
which it quotes from `threads.md` as it already quoted the guidance for
what a summary holds. It may also answer `{"fold": false}`, and Leaf
writes nothing. Leaf takes a range that runs forward over the thread's
spoken messages and ends before the user's newest messages, which the
main session answers; admission still holds it to the rule every summary
keeps, that no message but the opening one stands in full above a
summary (#5531). A range Leaf can't take goes to the agent with the
suggested range, as a failed fork does. The diagnostics note records the
suggestion beside the range the fork chose.
This reverses the call #6318 recorded, which kept the fork to the hint
because a fork offered the range's end once dropped the range's last
question from its prose. The guidance now names that case: keep in full
the question a kept answer replies to.
- `threads.md`, "Summarize a long discussion": the range choice is a
goal paragraph, "Fold what compresses most", which the fork quotes.
The fold-without-prose example drops `--label 'Previous progress
messages'`, which under the new summary named the fold twice beside
its count, and says `--label` is optional.
- Root `AGENTS.md`, "Leaf's role": "a reasonable choice is the agent's
to make" now covers choices Leaf's code makes in the agent's place,
as a fork's: Leaf offers evidence, the instructions state the goal.
- The fork eval shows its judge the suggested and the folded range, and
its rubric asks that the range fold the settled discussion and that a
kept answer's question is kept or stated.
Tests: the summary fork's model tests cover a range the fork chose past
the suggestion's end, one whose suggestion's end no longer stands, a
fork that folds nothing, and each range Leaf refuses (into the user's
newest message, backwards, a gap); the Claude Code module test answers
with a range.
leaf-agent
approved these changes
Nov 18, 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.
In Claude Code, the fork that writes a long thread's summary folded exactly the range
summary_hintpicks, a cutoff on message count and length that ends before the last two turns and starts at the opening message unless an earlier summary left it out. Now the fork gets that range as a suggestion and answers with its ownfromandthrough, or{"fold": false}, by the agent's guidance for what to fold, whichthreads.mdnow states as a goal ("Fold what compresses most") and the fork quotes. Leaf takes a range that runs forward over spoken messages and ends before the user's newest messages; admission still applies the rule from #5531. RootAGENTS.md, "Leaf's role", extends "a reasonable choice is the agent's to make" to choices Leaf's code makes in the agent's place.Worth weighing: the
AGENTS.mdsentence is maintainer direction. The fold-without-prose example inthreads.mddrops--label 'Previous progress messages', which under #6379's summary named the fold twice, and says--labelis optional.Max asked for this. Codex reviewed it twice; its three findings are fixed.
Tests: fork model tests and the Claude Code module test pass. Evals, base → head, 3 trials each: the summary fork kept the question its kept answer replies to in 3/3 (base folded it in 3/3; both passed the summary rubric), and in a new case where the newest message asks about the earlier claims, it folded nothing in 3/3 (base folded them in 3/3). The agent's own summary cases passed 12/12 on both arms.