Skip to content

Run the working-line fork at low effort, as the turn-end check's runs - #5776

Merged
max-sixty merged 5 commits into
mainfrom
agent-a3e7a7b84061aa4c0
Nov 9, 2026
Merged

max-sixty merged 5 commits into
mainfrom
agent-a3e7a7b84061aa4c0

Conversation

@max-sixty

@max-sixty max-sixty commented Nov 9, 2026 •

Copy link
Copy Markdown
Owner

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", which ask sends with the prompt, as the clerk's question carries clerk.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 and forkReply'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 (as forkReply's already was), and the debug log says the clerk's fork gave no answer (…) rather than the clerk wrote nothing: ….
  • Diagnostics: a fork_reply note now carries effort, the effort the fork was sent at. Its request.effort stays the session's.
  • tests/process/test_interact_claude_code_module.py: the working-line test checks that the fork is asked at forks.EFFORT and that its note gives that effort rather than the session's. The first check fails with effort dropped 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, which runFork now hands Leaf for both forks, and which journey.fork_summary and response-times read; each check fails with its field dropped from runFork.
  • Types: runFork declares its effort as Claude Code's ModelEffort. pnpm run check:hooks doesn't reach claude-code.ts (hooks/tsconfig.json includes only pi.ts and watch.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: main and 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 --base older 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's purpose, 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's reply_prompt built 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, with claude -p --resume --effort E --max-turns 1 on the session's model and 1M window, tools refused, in a fresh home.

low xhigh
Lines passing a blind judge 35 of 40 35 of 40
Lines the judge preferred 19 16 (5 ties)
Median output tokens 25.5 24
Runs with any thinking 0 0
Median generation time 0.28 s 0.31 s
  • Output 1.03× (0.97–1.10), generation time (first to last streamed event) 0.93× (0.83–1.05), time to the reply's end 1.07× (0.98–1.16); n = 40.
  • The judge, Opus 5.5 shown the two lines as A and B in a seeded order, read each pair beside the user's message, the running tool call and what the session did next: its own working line where it posted one (31 of 40), its first steps and its reply. Each effort failed three lines the other passed. Low's named the user's skill "this sweep", called the session's "seats" "labels", and gave away part of an answer; xhigh's gave away the fix, left out the user's question, and garbled the user's words. Both failed the same two, by promising page edits the session didn't make.

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 with EFFORT = "xhigh". A base at main would have compared low with the medium the replay takes for a fork that names no effort.

  • 35 of 35 passed in each arm.
  • xhigh thought over 5 of its 35 lines (54–219 thinking tokens, 1.3–3.5 s); low over none.
  • Output 0.81× (0.63–1.01), the fork's time 0.85× (0.75–0.95), wall time 0.90× (0.84–0.96); n = 35. Median output 24 tokens at low and 22 at xhigh, median time 0.93 s and 0.99 s.

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 --forks passed on this branch before and after runFork, 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 gives effort: "low" beside request.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

  • A session above xhigh, at max.
  • The replay resumes a transcript copy under claude -p rather 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.
  • Each replayed message ran once per effort and was judged once.
  • The replay and judge scripts sit in this branch's worktree under .tmp/effort/ and leave with it.

This was written by Claude Code on behalf of max-sixty

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
max-sixty marked this pull request as ready for review November 9, 2026 12:21
@max-sixty
max-sixty merged commit 4e00c77 into main Nov 9, 2026
6 checks passed
@max-sixty
max-sixty deleted the agent-a3e7a7b84061aa4c0 branch November 9, 2026 12:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants