Repository navigation
Catch a correction posted beside the agent's unanswered reply, and a thread message later work overtook, at each turn end - #6087
Merged
Conversation
…thread message later work overtook, at each turn end The turn-end check gains a fourth finding, `overtaken`: an open thread whose agent messages the user would misread, because later work overtook its latest message (#5804) or because the agent added a reply correcting its own unanswered one instead of editing it (#5724). The fork now also reads the agent's guidance for both (threads.md on editing an unanswered reply, authoring-revisions.md on replying once the work is done), which long sessions lose through compaction. Replayed on the real fork: it caught the pile in two of three of Max's #5724 sessions (4 of 4 runs and 1 of 1 with this wording) and missed the third (0 of 3), where main's check named it in 0 of 1 replays and 1 of 4 live forks. On 20 recent turns, paired with main, its one false finding was a thread the user had closed, which "open" then left out, and the fork took 1.06x the time (95% interval 0.91-1.19). A third trial finding, a section reporting a finding without its material (#5401), is dropped: it missed the one real case left to replay and fired on 4 of 24 other turns asking for runs or scripts behind counts. Three constructed cases protect it: overtaken-correction, overtaken-news and overtaken-question.
…he turn-end kinds in one list Review of the first version found the fork's pile findings sending the agent nowhere: of six summaries, two said to withdraw or remove the correction reply, which no command does, and four to edit the earlier reply, which leaves the correction standing. threads.md's paragraph on corrections, which the fork reads verbatim, now names the repair: `leaf thread summarize --from <earlier-reply> --through <correction> --text "<the current answer>"`. Run through the real CLI on overtaken-correction's page, that range is accepted and folds both replies under the user's question. With it, every pile summary in the reruns names summarize (3 replays, 2 eval runs). The `overtaken` bullet now names its two cases and leaves the rule to that guidance, instead of restating it. Rerun at the #5724 piles: triager-health 2 of 2, agent-launch-wait 1 of 1, package-interface 0 of 1 (it named a different overtaken thread there). overtaken-correction and overtaken-news pass 2 of 2. `FOUND` is now the one list of finding kinds; `ANSWER`'s enum and `answer_form` derive from it, so a kind can't validate and then miss its line in `_found`. `guidance()` names the reference and opening it can't find. overtaken-news's log gives r2 the words the conversation posts. The docstring carries the measured numbers of this wording and the one before it on 17 recent turns (no `overtaken` on the 15 without a replay artifact; 1.13x the time, 95% 0.94-1.34, against a base run hours earlier).
max-sixty
marked this pull request as ready for review
November 16, 2026 02:09
leaf-agent
approved these changes
Nov 16, 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.
Part of #5724. Closes #5804, whose first half #6051 landed.
Max chose to try three new turn-end findings on replays, keeping each only if replays of the turns where it should have fired catch it, a replay of ordinary recent turns stays near today's noise, and the fork takes no longer. Two of them share one property and pass as one finding. The third, from #5401, is dropped.
What changes
skills/leaf/references/turn-end-check.mdasks the fork for a fourth kind of finding,overtaken: an open thread that Leaf's thread guidance has the agent bring current. It names the two cases and leaves the rule to that guidance:leaf task endleaves the thread reading as unanswered #5804).The fork now reads two more paragraphs of the agent's own guidance (
clerk.GUIDANCE), so its summary tells the agent how to fix the thread in the words the agent's references use:threads.md: a correction to the agent's still-unanswered reply goes into that reply withleaf thread edit. Where the agent already posted the correction as a new reply, it now folds both into one current answer withleaf thread summarize <page> --from <earlier-reply> --through <correction> --text "<the current answer>". This sentence is new, and agents read it too.authoring-revisions.md: once the work a thread discusses is done, the agent replies there with the result.Of the sessions that piled replies, package-interface had lost the
threads.mdrule through compaction. agent-launch-wait first readthreads.md18 minutes after its pile, and triager-health (4 Nov) predates #5726, which added the rule. The fork reads the rule at every turn end either way.In
clerk.py,FOUNDis now the one list of kinds:ANSWER's enum andanswer_form()derive from it, so a kind can't pass validation and then miss its line in_found. The agent's line names the new kind "a thread of yours the user would misread". Leaf makes no edit for this kind; the agent edits, replies or summarizes itself.guidance()now names the reference and the opening it can't find, where it used to fail with a bare "substring not found".fork_eval.PARTSand the judge's rubric know the kind. Three constructed cases protect it:overtaken-correction,overtaken-news(a guardrail where the second reply is the result the first one promised) andovertaken-question.Evidence
I replayed the real fork: each session's transcript cut at the row the live fork read, its pages copied as they stood then, resumed once per arm with that arm's question, at the session's effort with every tool refused. Base is main at 8f24459.
Turns from #5724 sessions where the agent left a correction beside its unanswered reply, with this PR's wording:
overtakennamed itstaleovertaken)Every pile summary in this round names
leaf thread summarize: the three replays above that named the pile, and bothovertaken-correctionruns. In the first round, beforethreads.mdnamed a repair, two of six pile summaries told the agent to "withdraw" or "remove" the correction, which no command does. The other four said to edit the earlier reply, which leaves the correction standing. Run through the real CLI onovertaken-correction's page (a user question, a wrong reply and its correction posted withleaf thread reply),leaf thread summarize --from r1 --through r2 --text …exited 0 and folded both replies under the question. Two more corrections from the #5724 survey were no longer piles when the fork ran, because the agent had edited its first message within seconds (hover-places and red-suite-owners, 9 Nov).Ordinary recent turns (14–15 Nov, 10 sessions, 105k–215k context):
overtakenon 15. On n08 and n19 it named a thread whose 8:30 pm launch timer the replay itself had stopped: a resumed session hears that its background tasks stopped, which a live fork never does.unsupportedkind. 5 of each arm's older-kind items rest on the replay artifact.overtakenfired 4 times. One was a thread the user had already closed, so the finding now covers only open threads. The other three were artifacts: two about a review the replay had stopped (n05, n20) and one about the timer (n09). Wall time was 1.06× (0.91–1.19).Constructed cases (
leaf-dev eval run 'turn-end-check/overtaken*' --harness claude-code):overtaken-correction: 2 of 2 with the current text. In the paired run against main, the first wording passed 2 of 2 and main 0 of 2.overtaken-newsandovertaken-question: 2 of 2 each after fixing two flaws in the cases. One had the agent promise both reruns and run one. The other's label lacked words the fork quoted.overtaken-question.settled,settled-open,ask-follow-upandask-on-meeach passed their one run on head, so the new kind didn't take their findings.Dropped: a section without the material it rests on (#5401)
unsupportedasked for a section reporting a finding without the wording, case, command or source it rests on, where the conversation held it. #5401's own session isn't on this machine: no transcript, page or revision holds its "Today"/"Bare fact" table. The closest real case was worktrunk-feedback on 9 Nov, where "Pre-1.0 churn: two posts cite fast releases changing behavior" went on the page while a subagent's report naming the posts was in the conversation, and Max later asked "links?". The finding missed it in 1 of 1 runs. On 4 of 24 other turns it fired, each time asking for the CI run or.tmpscript behind a count or table. That is far more often than Max asks for material, which the #5401 survey put at about 15 of 1,200 comments. #5401 stays open.Calls Max may reverse
leaf task endleaves the thread reading as unanswered #5804, since both are the agent's own thread messages reading wrong. Two kinds would let the line name each.overtakencovers only open threads.leaf thread replygives no advice about a pile when the reply is posted: the The turn-end check names the package-interface pile, a correction beside the agent's own unanswered reply #5724 evidence measured that advice's precision at 13%.Checks
uv run pytest tests/model/test_clerk.py dev/tests/test_evals.py: 56 passed.pre-commiton the changed files.Not verified
turn_end_checknotes will showovertakenfindings as they fire.