Repository navigation
Have the turn-end check name anything on a page that no longer fits the work, and wake the session for it - #6160
Conversation
…finished work The turn-end check's `stale` finding now covers a title and opening that still present finished work as the page's news while what the work moved on to, such as a question waiting on the user, stands further down. The fork names it with no edit, and the agent hears it as a finding to rewrite the page around where the work stands. A session holding margin-open-cost added each new request's results as a section at the end of the page. Its title and opening went on describing #6071, merged hours before, while the question the user now faced ("Which of these should I build?") stood last. The fork read that page at the turn end and named nothing: each of the opening's sentences still held, and `stale` asked only for passages the work had contradicted. Measured on Claude Code: - Constructed case `turn-end-check/stale-lead`: 0/5 before, 3/3 on this wording; its guardrail `stale-lead-current` and every other turn-end case held on both arms (80 runs). - The real fork at that turn end, replayed from the session's transcript: 0/2 before, named the opening in each run after. At two other turn ends whose pages had appended a new question under an old opening, it named the opening. At eight ordinary recent turn ends it named no opening (four on this wording, all eight on a draft that differed only in phrasing). - A draft that opened with "A page's opening also goes stale when the work moves on" named an opening that only lacked a newer result, in `stale-rewrite`; this wording puts the condition first and passed 21/21 on the stale cases. The new short case `opening-follows-the-work` replays the main agent's revision by exposition. The shipped instructions pass it 6/6, so it guards the rule against a cut rather than reproducing the long-session miss.
leaf-agent
left a comment
There was a problem hiding this comment.
The test check hadn't reported a result on this head when I approved, so I haven't verified it.
| other turns asked for the run or script behind a count far more often than the user | ||
| asks for material. | ||
|
|
||
| On 2026-11-16 `stale` gained a page's opening: a title and opening that still present |
There was a problem hiding this comment.
do we have archeology here?
we should not be collecting archeology anywhere is the repo
There was a problem hiding this comment.
Yes. Lines 107–118 are archeology: the dated replay counts describe how the rule was found, which AGENTS.md already sends to the commit message. They aren't the only case either. Most of the header is dated history, for example lines 7–23, 89–105 and the measurement sections from line 210 on.
The rule that keeps producing it is in AGENTS.md: "A header also records the product decisions its module embodies and the alternatives they rejected." Agents read that as permission to log each decision with its date and evidence. If you want no archeology anywhere, that sentence is what needs to change, along with a sweep of the headers it has shaped. Changes to agent instructions need your approval, so I haven't touched it here.
Given your other comment, that the rule is overfit to the title and opening, I've dismissed my approval.
| tells the agent, which can undo it. Leave `edit` null where the fix needs more | ||
| than a sentence or a choice the conversation hasn't made; the agent revises the | ||
| page. | ||
| agent decides what to add. A title and opening are stale too where they still |
There was a problem hiding this comment.
this is way way overfit on the title and opening; there shouldn't be stale info anywhere on the oage
it's more egregious at the title.and opening, but that can be implicit with good goal-level instructions
The maintainer rejected the approach as overfit to the title and opening (review 5918368338); the approval no longer covers what should merge.
…, and drop the header's dated record
Review asked for a goal-level rule rather than one aimed at the title and opening, and for no history in module headers.
`stale` now names anything on a page that no longer fits the work as it now stands, wherever it is: words the work has since changed, and finished or dropped work the page still presents as current. A title and opening that still tell finished work as news stay as one example. The clerk header's dated paragraph about this change is gone; the reasons are here.
Replayed on Claude Code, real turn ends where a page opened on finished work while the next question waited below (margin-open-cost, leaf-dev-duplication-cause, prose-beside-spine):
- this wording named the opening in 4 of 7 runs; the title-and-opening clause it replaces named it in 7 of 7;
- two wordings with no example ("material a reader arriving now no longer needs"; "work the page still presents as current, ahead of or in place of what the work moved on to") named it in 0 of 6, and the constructed stale-lead case in 0 of 4.
At eight ordinary recent turn ends it named no opening. It also names a plan step still listed as to do after the work finished it, so stale-passed-on's earlier finding now covers the plan as well as the lede. The turn-end suite passes, 39 of 40; ask-follow-up failed once on an ask's wording, as it does on main.
leaf-agent
left a comment
There was a problem hiding this comment.
The agent still receives a stale finding under the old, narrower label. clerk.py:295 ("stale": "the page saying what has since changed") introduces each finding in the hook context as "found the page saying what has since changed on {page}: …". conversation-loop.md:198 tells the main agent the same thing ("a page that still says what has since changed"). In the case this PR targets, every sentence of the opening still holds, so the label points the agent at words it won't find, when the fix is to rewrite the page around the new question. The finding's summary may make up for it, but the label is the frame the agent reads first.
Updating both to the new goal, for example "the page holding what no longer fits the work", keeps the reference, the delivered label and how-it-works.html saying the same thing. The assertion in tests/model/test_clerk.py that quotes "has since changed on " would change with the label.
…s the work The line that hands the agent a stale finding, and conversation-loop.md's account of the turn-end check, still described it as the page saying what has since changed, the narrower reading the check no longer uses. Leaf's reviewer found it.
The turn-end check's findings reached the agent only at its next prompt or tool call. After the turn that ends a stretch of work, that next step is the user's return, so a page the check found stale stayed stale until the user had read it. On margin-open-cost the check ran at 21:59 PT and the agent's next step was the user's comment at 00:51. A finding Leaf changed nothing for is now queued with `wake`, so the watch between turns starts a turn for it once the turn that left it closes, and a session no watch follows is nudged, as a fork's to-do already does. An ask Leaf wrote and a fix it made only tell, and wait for the agent's next step as before. Since Nov 10, 121 turn-end checks across 43 sessions named something only the agent could act on: 26 were heard within a minute, the median waited 5 minutes, 13 more than an hour, and 3 never. With this change each of those idle waits becomes a woken turn. The other lines Leaf queues for the agent already reach it in time: a fork's to-do wakes the session, a thread a fork hands back is an owed answer the watch wakes for, and a render reading arrives as page input, which wakes. Tests: the new clerk test fails without the wake. The Claude Code journey passes every step; its turn-end checks named nothing, so it didn't exercise the wake itself.
… turn the fork read Codex's review found two ways the clerk's nudge could start an unwanted turn: one answer naming findings on two pages sent two nudges, since a nudge's mark is per page while the woken turn hears every page's lines; and a fork that read an earlier turn could nudge after the user ended a later one with Escape. The clerk now nudges once per answer, and only while no turn has opened since the fork read the conversation. The finding's line still wakes the watch, which never wakes after Escape.
#6210) Stops agents writing history into the tree. Root `AGENTS.md` asked a module header to "record" each product decision and the alternatives it rejected, which agents read as a dated log (`src/leaf/clerk.py`'s docstring is mostly that), and `evals/README.md` asked each case's leading comment to record "where the case came from and what it measured". Now a header states each decision with its reason, whether the user made it, and any alternative a later change might reach for, with why it fails; and text in the tree, comments, tests and eval cases included, says what holds now, with dates, the request or incident, measurements and earlier versions in the commit message. How a rule came to be stays on the list of public surface traps in maintainer guidance, which `running-tend`'s review threshold reads, so review flags history written there. Scored with a temporary A/B in scratch (about 40 Opus runs, about $60): an eval case written from a session's failure carried its session id, date and pass counts in 4 of 4 runs on the old text and 0 of 4 on the new. Updating a header, neither text wrote dates on a clean header, and deleting the decision sentence outright lost a rejected alternative in 4 of 4, so the sentence stays rewritten rather than cut. On a header already holding dated history, the old text extended it in 1 of 4 runs and the new in 0 of 4. So in headers the history already there is what agents copy; #6212 removes it across the tree. Asked for by Max on #6160's review. `pre-commit` passes on both files. > _This was written by Claude Code on behalf of max-sixty_
…s that made it (#6212) Removes the history the tree had collected in module headers, comments, test docstrings and eval-case comments: dates of decisions, who asked when, the incidents and sessions behind them, replay and pass counts, PR numbers cited as provenance, and accounts of earlier versions. Each decision stays with its reason, whether the user made it, and the alternatives a later change might reach for, now stated as rejected with why they fail. The removed history stays in the commits that added it (`git log -L`). #6210 changes the two rules that produced it. Lines matching a dated-history pattern outside `notes/`, `examples/` and fixtures go from 264 to 17; the rest are page and prompt data, a page revision's "first version", and three `browser/AGENTS.md` clauses #6024 already removes. Provenance PR numbers leave code comments; one open `TODO(#4041)` stays. `src/leaf/clerk.py`'s docstring goes from 250 lines to 190. What to weigh: a figure that a constant, bound or budget is sized from stays (`DEADLINE_S`, `ROLLOUT_MS`, `FEW`), and so does a version that bounds an observation (a Playwright build, a Claude Code version). An observation of a browser or of Claude Code that carried a date now says what the code guards against ("Chromium can leave … hovered"), since dropping the date alone would have asserted a law. `notes/` keeps its dated research. Every hunk is a comment, docstring or string; no assertion changed. `packages/default/styles/sample.css` also loses a paragraph that described the suggestion as boxless, which `base.css` no longer makes it. Conflicts: open PRs that touch these 423 files, such as #6156 in `forks.py`, will resolve comment hunks when they next merge `main`. Asked for by Max on #6160's review. Six agents swept by area; an independent Codex pass per area compared old and new text claim by claim, and a second pass checked the fixes; their findings are fixed. `pre-commit` passes on every changed file, as do the tests that read them. > _This was written by Claude Code on behalf of max-sixty_
The turn-end check now catches pages that have fallen behind the work, and Leaf wakes the session so the agent can fix the page before the user returns.
What it names. The check's
stalefinding is now a goal for the whole page: anything on a page that no longer fits the work as it now stands, wherever it is. That covers words the work has since changed, and finished or dropped work the page still presents as current. A title and opening that still tell finished work as news remain one example.When the agent hears it. A finding Leaf can't act on itself is now queued with
wake. The watch between turns then starts a turn for it once the turn that left it closes, and a session no watch follows is nudged, as a fork's to-do already is. An ask Leaf wrote and a fix it made only tell the agent, as before.On margin-open-cost, the session appended each new request's results at the page's end. The title and opening kept describing #6071, merged hours earlier, while "Which of these should I build?" sat last. The check ran at 21:59 PT and named nothing. Even a finding would have reached the agent only with the user's comment at 00:51.
Measured:
ask-follow-up, whose judge splits on the same ask wording on both arms.To weigh: each woken turn spends the session's cached context; I estimate $1–2 a turn. The goal wording also doesn't catch #6158's case, true material about something since removed.
Requested by the user's
/diagnose-sessionon that page; they approved the wake. Reviewed by Codex. Checks:tests/model/test_clerk.py,tests/model/test_forks.py,tests/model/test_wait.py, the turn-end eval suite, theclaude-codejourney.