Repository navigation
Benchmark each reply's whole time and Leaf's share, with the harness waiting and working - #3387
Conversation
…waiting and working Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…alls by the response that follows them Codex App Server records the opened pickup when the agent acknowledges the pointer its hook handed over, and reports each response's token usage after the calls it started return; Pi's turn_end does the same. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…ss note Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
A real page's reply can span the harness's idle time, and a comment admitted to an idle harness is not one it was busy before. Each harness record now marks where its turns start and end: busy needs a turn running at the admission, a pointer the agent acknowledges ends delivery at the turn that took it, and time between turns is idle rather than model time. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…nd and Leaf's share as an upper bound Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
# Conflicts: # dev/leaf_dev/commands/response_times.py
… busy turn ended Claude Code marks the input that starts a turn with turnPosition and ends the turn with a turn_duration record once its Stop hooks let it stop; a local command starts no turn, and a response's end_turn blocks don't end one. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…ction's summary Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
leaf-agent
left a comment
There was a problem hiding this comment.
The working-case split can charge another tool's runtime to Leaf. _phases ends busy at the first tool_result, but Claude Code delivers pending input at PostToolBatch, after the batch's tools finish. With two tools already running when the comment arrives, one returning at 2 s and the other at 10 s, and pickup at 10.2 s, reply_breakdown reports 1 s busy and 8.2 s delivery. That 8.2 s becomes leafMs, even though Leaf has not handed the comment over. Keep the outstanding tool IDs at admission and end busy when the batch drains or the turn ends; a parallel-tool case would protect the benchmark's central Leaf-share reading.
…eturned Claude Code hands pending input over at PostToolBatch, once the batch drains, so the boundary is where no call is out, not the first result. Re-deriving the 20 replies the note reports from their evidence gives the same numbers. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
leaf-agent
left a comment
There was a problem hiding this comment.
An interrupted earlier turn can leave a tool_use without a tool_result: claude_code_records maps interruptedMessageId to turn_end without synthesizing a result. drained() keeps that old ID in out across the next turn_start, so it misses the next batch's actual drain. In a normalized sequence with the old turn ending at 2 s, the new tool running from 4–6 s, a comment at 5 s, and pickup at 6.2 s, reply_breakdown reports 0 ms busy and 1,200 ms delivery instead of 1,000 ms busy and 200 ms delivery. This inflates the benchmark's central leafMs reading. Reset outstanding IDs when a new turn begins, and cover an interrupted prior turn in the timing case.
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…3411) The reply benchmark compared a waiting harness and a working one, but the working ask came second in the same session. It had read Leaf's references already and only added a release to the record the first ask had built. Now each journey runs one case, chosen with `leaf-dev journey TARGET --case waiting|working`. In both cases the small page change is the fresh session's first comment, so the two start from the same page and context. ## The benchmark - **Two cases on one ask.** With `--case working`, the release ask is sent while the user's own turn runs its 25 s shell command (`Terminal.work`, which each harness module implements once and reuses in its steps). The sample records its `case`. - **The `mid-turn` step asks a question again.** It checks delivery mid-turn, as before #3387. The `CASES`/`markers` machinery and the second page-change ask are deleted. - **The table.** `journey-chart --replies` groups samples by target and case. `--since ISO` reads every sample kept since that time, for a batch whose commits leave the plugin unchanged. This batch straddled a `response-times`-only commit. ## Readings Two journeys per harness and case, 18:10–18:42 PT, load average 5–19 on 18 cores, with Leaf's share read from each command's own record (#3403). Seconds: | Harness | Case | Whole reply | Leaf's share | After the boundary | Model calls | | --- | --- | --: | --: | --: | --: | | Claude Code | waiting | 12.4–13.3 | 0.7 | 12.4–13.3 | 3 | | Claude Code | working | 42.8–60.7 | 0.6–0.8 | 18.1–36.0 | 3–8 | | Codex App Server | waiting | 18.4–33.0 | 0.4–0.5 | 18.4–33.0 | 4–5 | | Codex App Server | working | 51.1–56.3 | 0.8 | 26.3–31.8 | 4–5 | | Pi | waiting | 34.1–40.0 | 1.2–1.3 | 34.1–40.0 | 8–9 | | Pi | working | 51.3–56.0 | 0.9–1.0 | 26.5–31.3 | 7–9 | Leaf's share was 0.4–1.3 s in all twelve replies. Once the harness had the comment, neither case was consistently quicker. The wait for the boundary, the user's own 24.5–24.9 s command, made the difference in the whole reply. The note (`notes/user-feedback-responsiveness.md`, "A small page change's reply") gives the per-call detail and replaces the earlier same-session table. > _This was written by Claude Code on behalf of max-sixty_ --------- Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
Benchmark a reply by its time, attributed to where it went The reply benchmark now measures the time from the user's comment to the agent's reply and attributes all of it, each moment once, instead of counting model calls. This follows Max's decision #40 on the overnight report: a count of model calls is a noisy proxy for the time the user waits, so the benchmark and the note's budgets are now in seconds. `reply_phases.reply_breakdown` splits a reply into: - Leaf's share: delivery, Leaf's commands, and now Leaf's hooks where the harness times them; - the harness's own work before each request; - the model's wait for the stream's first output and its generation, with each response's output tokens; - the agent's other tools, the harness's busy time and idle time. Each harness's record supplies a different part of this: - **Claude Code**: the journey reads its debug log. It pairs each first byte with its request by the elapsed time the log line states, so a prompt-suggestion stream running alongside isn't mistaken for the main thread's. The transcript gives each response's output tokens. - **Pi**: the first stream event and output tokens come from its RPC events. - **Codex App Server**: its hook durations and per-response token usage come from App Server notifications. App Server reports no request or stream start, so Codex's model time stays unsplit. The journey now breaks the release reply down once, after the session ends, from its whole record. The call that replied keeps its tokens, and reading Claude Code's transcript while it is still being written can no longer fail the journey on a partial line. `leaf-dev journey-chart --replies` prints a table with one column per target and case. Each part shows its mean and its share of the whole reply, and the parts add up to it. Model calls and output tokens remain only as diagnostic rows. `notes/user-feedback-responsiveness.md` now carries: - a fresh batch of 18 journeys, three per harness and case; - which parts each harness gives exactly and which are inferred or missing; - budgets in seconds: whole reply under 15 s, Leaf's share under 2 s. In waiting replies the model took 82–92% of the time, mostly generation: Claude Code generated at about 100 tokens a second, nearly all of it thinking. Leaf's hooks took 1.0–1.6 s a reply on Claude Code and Codex; nothing counted them before this change. The TODO entry asking what the reply budget counts is removed: the budget counts the whole reply. The website journey test's fake `run_journey` and its expected sample were stale against #3387 and #3403. They now take `commands` and expect `case`. > _This was written by Claude Code on behalf of max-sixty_ --------- Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
Max asked that the reply benchmark record both Leaf's share and the whole reply, and cover two cases: a comment that reaches a waiting harness and one that reaches a working harness. This change makes
leaf-dev journeyandleaf-dev response-timesreport both numbers for every reply. The whole reply is broken into its model calls. The notenotes/user-feedback-responsiveness.mdgets budgets for each number and case, a measured table on current main, and the model calls a small page change should take.The benchmark
dev/leaf_dev/reply_phases.pysplits the span from a comment's admission to its reply into phases.busyis the harness on other work before it takes the comment,deliveryruns until the comment is in the agent's context, and the rest ismodel,toolandidletime between turns.reply_breakdownsums the phases into the whole reply and Leaf's share (delivery plus tool phases that runleaf). It also groups model phases into the model calls the harness made, each with the tool calls it issued. The journey's oldturn_phasesmoved here.turnPosition,turn_durationandinterruptedMessageId. Codex givesthread/tokenUsage/updated,turn/startedandturn/completed. Pi givesturn_end,agent_startandagent_settled.journey.CASESnames them. The release ask reaches a waiting harness. Themid-turnstep now asks for the same small page change, naming a release of its own, while the harness runs the user's 25 s command. Each step requires a revision that names its release. Each sample says which comment asked for which case.uv run leaf-dev journey-chart --repliestabulates the kept samples by target and case.leaf-dev response-timesadds the breakdown for inputs that Claude Code answered, reading the transcript it finds by session id. On real pages Leaf's share is an upper bound, because a shell command that runsleafamong slower work counts whole.Readings on current main
Four Claude Code journeys and three each on Codex App Server and Pi, at this branch on main
23acce2b1. Seconds:In the working case the harness was busy with the user's command for 24.5–25.2 s first, so the working budget counts from that boundary. Leaf's share was 0.5–1.5 s in 19 of 20 replies; the exception ran
leaf page check --render. The model takes the rest. The proposed budgets are Leaf's share under 2 s in both cases, and a whole reply of Leaf's share plus two model calls. The note says which calls the replies spent beyond two: widget and registry lookups, and reference reads on a session's first comment. It also says why the two cases differ in more than the harness's state.Codex App Server ran main's delivery after the revert of #3357 (#3362) and #3368: Leaf starts a turn for an idle task, and the tool hook delivers inline to a working one. Earlier batches on #3357's queue path, before #3368 and #3372 landed, showed the two calls those changes removed.
Review
An independent Codex review ran over three rounds against real transcripts and the kept runs. It found idle gaps counted as model time, an idle harness read as busy, local commands and compaction summaries starting turns, and
end_turnblocks ending turns early. All of these are fixed and checked on the page it used. The remaining limit is on real pages: Leaf's share counts a whole shell command that runsleafamong other work. The note proposes that eachleafcommand record its own duration.