Repository navigation
Have each leaf command record its own duration, and read Leaf's share from it - #3403
Conversation
… removing its home 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]>
… from it Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
A reply by reference records into its own page, not every page its delivery carries; gathering the record can't fail the command; overlapping commands and delivery count once; the journey reads its claimant's commands. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…ge's record apart, and count a working reply's commands from its boundary Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
leaf-agent
left a comment
There was a problem hiding this comment.
leaf_commands_s includes Leaf work from the turn already running when a new comment arrives. For example, with the comment admitted at 1 s, a command running from 2–4 s, pickup at 5.2 s, and the answer at 12.5 s, leaf_commands_ms reports 2,000 ms for that command. The reply breakdown correctly excludes it as busy. This overstates the new per-input metric, especially for working inputs, and makes it disagree with leafCommandsMs for the same reply. Bound the summary to the point where the harness took the comment, or label and report it as admission-to-answer command time rather than Leaf's share of the reply.
…t's commands from where the harness took it A refused or unchanged page init writes nothing to the page, as before; a working harness's commands for its other work stay out of the input's leaf_commands_s. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
leaf-agent
left a comment
There was a problem hiding this comment.
leaf_commands_s now starts at the opened pickup, but the agent can run Leaf commands after the harness takes an input and before it records that pickup. reply_breakdown accounts for this when the agent reads and acknowledges a delivery itself. With admission at 1 s, the harness taking it at 5 s, a Leaf command from 7–8 s, pickup at 9.2 s, and an answer at 12.5 s, I get leaf_commands_s: 0 while leafCommandsMs: 1000 for the same reply. The new metric therefore omits Leaf work on this input. It needs the same take boundary as the reply breakdown; for harnesses without that boundary in their records, the summary should say what its pickup-based measurement covers.
…cript gives one 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]>
Leaf's share of an agent's reply was read from the harness transcript: any tool call whose text named
leafcounted whole. That was an upper bound, because a shell command that runsleafamong slower work counted entirely, and Codex and Pi pages got nothing. Now everyleafcommand records its own duration in the page it acted on, andleaf-dev response-timesandleaf-dev journeyread Leaf's share from those records. The transcript classifier is deleted.The record
interaction_log.record_commandappends oneleaf_commandobservation toobservations.jsonlas a command exits. It holdscommand(its words, such asresponse reply),started,durationMs,sessionandcontext.PAGEargument (cli.resolve_dir), an answer reference's page (delivery.response_address), or every page a delivery it reads or acknowledges carries. Each notes its page withacting_on.page init, which creates or re-vendors a page, records nothing, so a refused or unchanged init still writes nothing to the page.bin/leaf's uv, when this process's parent runspython -m leafwith the same arguments. Otherwise, as for Codex's MCP tool or the sandbox bridge, it runs from the process's own start. On a scratch page,page checkrecorded 208.8 ms where/usr/bin/timeread 220 ms.leaf waitwatching a session's pages, records nothing. One that names a page and then waits, such asleaf wait --ack, records its own work when it starts waiting. Harness hooks don't pass through the CLI, and their time shows as delivery in the pickup receipts.Reading it
reply_phases.reply_breakdowntakes the session's command records. Leaf's share is the time covered by delivery or a command, each moment counted once. A command counts when it started after the comment's admission (or, for a working harness, after the boundary where the harness took the comment) and before the reply, clipped at the reply's admission.response-timesgives every answered inputleaf_commands_son any harness: the answering session's commands from the transcript's take boundary where available, otherwise from its opened pickup or admission, to its answer. Without a transcript, that fallback can miss commands run before the agent acknowledges a pointer it read itself. It also adds aleaf_commandssummary row. The journey reads its claimant's records. One validation journey per harness recorded every command, including Codex's MCP-tool calls.Tests
page interactionsused to leave the diagnostics file byte-identical; it now leaves every existing record unchanged and appends its own. The Codex stream test removes the file setup now creates before making the path a directory.Review
An independent Codex review ran over two rounds and found eight issues. All are fixed here: metadata collection could fail a command; overlapping commands counted twice; a reply by reference recorded into every page of its delivery;
leaf wait --ackcounted its wait; one unwritable page suppressed other pages' records; commands outside tool phases reduced other tool time; and the journey didn't filter by session.