Repository navigation
Run the working-line fork at low effort, as the turn-end check's runs - #5776
Merged
Merged
Conversation
The fork that writes the agent's working line on a held thread message now names `low` (`forks.EFFORT`), whatever the session's effort, and its `fork_reply` note records the effort Claude Code reports it sent. Leaf holds the thread's messages from the session until the line is posted, so the fork's time delays the session's answer. On the line-only prompt (#5552), low wrote lines as good as xhigh's: 35 of 40 recorded thread messages passed a blind judge at each effort, with low preferred 19 to 16, and the fork-reply eval passed 35 of 35 at each. Neither effort thought on the recorded messages; on the eval xhigh thought over 5 of 35 lines and low over none, for 0.85x the time (0.75-0.95). The forks.py header now records this in place of the 2026-11-04 measurement, which was taken when the fork still chose between answering and handing over.
Each case's purpose and the file's header still described the fork that chose between answering and handing over, which #5552 removed. They now say what the working line must do in each case. No case's checks change.
…back runFork in hooks/claude-code.ts reads the resent request, times the fork, makes it at Leaf's effort and copies its answer or failure, usage and reported effort, for both the clerk and the working-line fork. A clerk fork that throws now reaches Leaf as a failure, noted in each page's diagnostics with its reason as a refused fork's was, rather than only the debug log. fork_eval.fork reads the effort the arm's Leaf names for every fork; a base that names none now fails rather than running that arm at medium, an effort no live fork takes.
…'s usage and time $.model.fork takes a ModelEffort, so a string effort fails to type-check against the declarations Claude Code generates (TS2322); hooks/tsconfig.json doesn't include claude-code.ts, so no gate saw it. The clerk and working-line tests now also check that each fork's note carries its usage and time, which runFork hands Leaf for both forks; each check fails with its field dropped from runFork.
max-sixty
marked this pull request as ready for review
November 9, 2026 12:21
leaf-agent
approved these changes
Nov 9, 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.
The fork that writes the agent's working line on a held thread message now thinks at
low(forks.EFFORT), whatever the session's effort. Leaf holds the thread's messages from the session until that line is posted, so the fork's time sits on the path to the session's answer. #5440 left this fork at the session's effort because low changed its choices between answering and handing over. Since #5552 the fork writes only the line and makes no such choice, and on that prompt low writes lines as good as xhigh's.What changed
src/leaf/forks.py:EFFORT = "low", whichasksends with the prompt, as the clerk's question carriesclerk.EFFORT. The header records the measurements below in place of the 2026-11-04 one, whose premise Show the agent's working line from a fork at once, and read On it from the fork's start #5552 removed. The two forks keep separate constants because each effort was chosen on its own fork's work (the clerk's on asks and stale passages, this one on the line), and either may change without the other.hooks/claude-code.ts: both forks now go through one helper,runFork, which makes the fork at the effort Leaf names and hands back its answer or failure, usage, time, the effort Claude Code reports it sent, and the resent request. The clerk's andforkReply's copies of that bookkeeping are gone. One behavior changes: a clerk fork that throws now reaches Leaf as a failure, noted in each page's diagnostics with its reason (asforkReply's already was), and the debug log saysthe clerk's fork gave no answer (…)rather thanthe clerk wrote nothing: ….fork_replynote now carrieseffort, the effort the fork was sent at. Itsrequest.effortstays the session's.tests/process/test_interact_claude_code_module.py: the working-line test checks that the fork is asked atforks.EFFORTand that its note gives that effort rather than the session's. The first check fails witheffortdropped from the module's call. The failed-clerk-fork test now expects the new debug line and a diagnostics note for each refused fork. The clerk and working-line tests also check that each fork's note carries its usage and time, whichrunForknow hands Leaf for both forks, and whichjourney.fork_summaryandresponse-timesread; each check fails with its field dropped fromrunFork.runForkdeclares its effort as Claude Code'sModelEffort.pnpm run check:hooksdoesn't reachclaude-code.ts(hooks/tsconfig.jsonincludes onlypi.tsandwatch.ts, since Claude Code's declarations are generated when it loads the plugin and aren't in npm), so I type-checked it against the declarations Claude Code 2.1.319 generated:mainand this head pass, and the previous head's string effort failed with TS2322.dev/leaf_dev/fork_eval.py: the replay reads the effort the arm's Leaf names for every fork (asked["effort"]). The medium it took for a fork that named none is gone, with its header sentence, so a--baseolder than this PR fails on reply cases rather than running that arm at an effort no live fork takes.notes/fork-replies.md: prose that said this fork runs at the session's effort.evals/fork-reply/case.yaml: each case'spurpose, and the file's header, still described the fork that chose between answering and handing over; they now say what the working line must do in each case. No case's checks change.Measurements
Opus 5.5 on Claude Code 2.1.319, 2026-11-09. Ratios are low over xhigh, paired on the same message, as geometric means with 95% bootstrap intervals.
Recorded thread messages. These are the 40 messages of
notes/fork-replies.md("How well the fork judges"), from 30 sessions, idle and mid-turn; their transcripts and page copies are still on this machine. Each was replayed from its session's transcript cut where the message arrived, with today'sreply_promptbuilt over the thread and running tool call the original replay recorded. Each ran once at low and once at xhigh, in a seeded random order, withclaude -p --resume --effort E --max-turns 1on the session's model and 1M window, tools refused, in a fresh home.The fork-reply eval at low and at xhigh.
uv run leaf-dev eval 'fork-reply*' --harness claude-code --base 4092d17dd --repeat 5 -j 4. The head arm is this branch, at low; the base arm,4092d17dd, is this branch withEFFORT = "xhigh". A base atmainwould have compared low with the medium the replay takes for a fork that names no effort.Live forks at the session's effort. Since #5552 this machine's pages hold five working lines written on the current prompt at xhigh, with 25–71 output tokens in 1.0–4.4 s.
The live path.
uv run leaf-dev journey claude-code --forkspassed on this branch before and afterrunFork, with the journey's session at its default, medium. On the later head, Claude Code's debug log shows all seven forks (three working lines, four turn-end checks) sent at low (effort low asked, low sent), and each fork's note giveseffort: "low"besiderequest.effort: "medium". The working-line forks took 627–661 ms for 15–26 output tokens, reading 59–95k tokens from the session's cache and writing none.Load averages ran 2.4–4.5 during the eval and 3.6–10.5 during the replay, so compare the ratios rather than the seconds.
What this buys
On real messages neither effort thinks, so low and xhigh take the same time there. Low removes the occasional line xhigh stops to think over, which took up to 3.5 s on the eval where a line took a median 1 s, and the line's time no longer depends on the effort the session runs at.
Not verified
max.claude -prather than resending the session's own request through$.model.fork, so its runs don't share the session's cache: each read at most 35k tokens from the cache and wrote the rest of the context. The paired ratios share that cost; the absolute times don't match a live fork's..tmp/effort/and leave with it.