Repository navigation
Carry Claude Code's page input by hook, and benchmark render checks and in-tab latency - #1265
Merged
Merged
Conversation
…lls the user meanwhile The eval stopped at the first reply, so the render check and handoff that take most of a turn went unmeasured, as did the page's own account of the comment. Each comment now reads when the agent was woken, its last reply before the turn ended, the turn's length split into tool time and the rest with the slowest call, and, from /api/state sampled every 0.25 s, how the comment's workflow and the banner moved, how long after the delivery Picked up and the work claim were shown against the budgets in notes/user-feedback-responsiveness.md, and how long the banner disagreed with the agent. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
# Conflicts: # scripts/eval_claude_delivery.py
…re replying Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
`scripts/bench_render_check.py [BASE_REF]` builds a plugin arm at BASE_REF and at HEAD (eval_harness.build_arm), prepares triage-board, data-explorer and the render corpus with each arm's own launcher, and runs each arm's `bin/leaf version check --render` three times, alternating arms. It reports wall time and a phase breakdown from each arm's fastest run: startup, markup validation, the plain check's page-code run, server and driver start, browser launch, each render pass (viewport x scheme), the once-per-version width sweep, a confirming attempt, browser close and teardown; the passes split by stage; and CPU seconds for the leaf process and for the driver and browser. Phases come from outside the check, so any ref can be measured unchanged: `scripts/bench-render-check/sitecustomize.py` loads through the child's PYTHONPATH and records per-call spans of named functions with sys.monitoring, disabling every other code object on first sight. The check has no machine-readable output to carry its own timings, and a base ref could not emit timings added now. `eval_harness.run_leaf` takes `input` so `prepare_page` can seed a page's data through it. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
notes/user-feedback-responsiveness.md sets latency objectives for an open page and nothing measured them: verify_site.py profiles cold startup only. scripts/bench_page_latency.py [BASE_REF] builds the base and HEAD plugin arms with eval_harness, serves examples/triage-board.html and the corpus from each arm's own launcher, and in headless Chrome times five transitions RUNS times per arm, the arms taking turns: - a passage comment and a board move, from the input event's timestamp to the painted result and to the painted "Sent" receipt; - `leaf thread reply` and `leaf status working`, from the first modification stamp of the file the command writes to the painted change; - a saved index.html plus `leaf version stamp`, to the presented revision, with whether the runtime patched in place or reloaded. An init script samples each frame after its paint (animation frame, then a posted task), so a result counts at the frame that paints it rather than at its DOM mutation. Requests and bytes per transition come from the runtime's traffic ledger for quiet and from resource timing. No runtime change: it reads data-lf-presented, lf-revision, data-lf-traffic, and lfReadiness, which the runtime already paints. eval_harness.run_leaf takes stdin so prepare_page can run through it. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
… listening Tests that drove Claude Code's printed-envelope loop now take input the way the prompt hook does; tests of the wait carrier's own print-and-ack behavior run under a bare shell or a Codex loop, whose waits still print. `docs/how-it-works.html` shows the hook route and the claim-first answer, `record-demo.py` takes input the way its harness declares, `leaf status idle` names the claimant harness's remedy for unread input, and the delivery line no longer repeats the hook's own "no watcher" reason. The banner reads listening while the claimant's turn is open, since that turn takes new input before it ends: a wait that exits to wake the session left the page reading "away" for the seconds until the Stop hook ran. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…hes the turn A review of the hook carrier found that it trusted the harness rather than the session: under Claude Code with hooks disabled, launched without the plugin, or reading another state home, `leaf wait` woke the session to an empty turn, looping. Each Leaf hook now marks its session (`sessions/<id>.hooks`, removed at SessionEnd), and a wait only wakes a session so marked; otherwise it prints the envelope for its reader to confirm, as before. The hook now composes its whole context before confirming anything, confirms page by page (a page whose receipt is refused keeps its input pending), and prints right after. A delivery that would pass Claude Code's 10,000-character context limit, where Claude Code substitutes a preview, goes as a pointer the model reads and confirms itself. The moves a hook hands over are no longer also listed as unpicked or unanswered in the same message, and a repeated Stop is held open only by the user's input, not by reports or page errors. An open turn reads listening only for a session whose hooks take its input, and only within the working grace of when it opened (`turn_opened`, now on the claim), so a Codex session or an interrupted turn reads away. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
… hands, and hold hook context to bytes A second review of the hook carrier found that a page deleted between capture and receipt raised after earlier pages were confirmed, so nothing printed; it is now handled like a refused receipt. A page refused that way now says in the composed context that its new owner takes its input, so two sessions do not both answer it. The redundant post-receipt turn opening is gone, since the prompt hook opens the turn and a Stop runs inside one. Claude Code's context limit was measured with ASCII only, so the check counts UTF-8 bytes, the strictest reading. The demo asks `hooks_carry` rather than reading the wait's output shape. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
leaf-agent
reviewed
Sep 27, 2026
leaf-agent
left a comment
Collaborator
There was a problem hiding this comment.
A fresh hook-backed turn can still show Away when a prior working declaration has gone stale. in_turn is true, but the status["state"] == "working" branch returns Away before the new listening fallback. Reopening a turn without rewriting that old status reaches this path, so the banner contradicts the turn's ability to take input. Carry the fresh-turn evidence through that branch too.
A claimant whose open turn takes input counted as listening only in the last activity branch, so a stale `working` declaration or stale subject work read the page away while the turn could still take a comment. One `taking_input` reading now answers "is anyone there" for all three branches: the old work reads stalled, as it does under a wait's lease. Also applies prettier's wrap to docs/how-it-works.html. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
# Conflicts: # tests/test_render_export.py
# Conflicts: # skills/leaf/references/conversation-loop.md
max-sixty
added a commit
that referenced
this pull request
Sep 27, 2026
…gh the product in tests (#1276) Tests stop restating four rules the product owns, and read the product's answer instead. **Sideways overflow.** About 40 assertions computed "does the page scroll sideways" themselves: eleven from `document.body`, which stopped being the scroller in 7336a14, and the rest from `document.documentElement`. They now call `root_overflow(page)`, a new harness helper over the render gate's `rootOverflow` probe. The body reading reports overflow on a page that narrows `body` while the window scrolls nothing (`test_the_render_gate_measures_sideways_room_at_the_root_scrollport` already plants that case). Under the root reading, every assertion still passes, so none was green only because of the body reading. `test_a_comment_inside_a_scrolling_table_leaves_the_page_its_own_width` collected a `sideways` reading and never asserted it. It now asserts the page stays its own width at both scroll positions, which is what its docstring promises. **Runtime modules.** Eleven tests imported `/runtime/…` by bare path, or spelled out the entry-relative lookup inline. A served page runs its runtime from its revision path, so a bare import loads a second module instance, and `import('/runtime/widget-api.js') === <the page's module>` is false. Every page-side import now goes through the harness's `window.__lfRuntimeImport`. This moves one test's subject: the live-specimen tests in `test_render_controls.py` now mount through the page's own `specimen.js` rather than a copy. `test_site.py` keeps its own resolution only where the page's address is the subject. **Stored drafts.** `STORED_DRAFT_TEXT`, `STORED_DRAFT_SETTLED` and about a dozen inline sites spelled the storage key as `'lf-draft:' + ctx`, without the page scope that `storage.js` prefixes on a page served under a path. `drafts.js` now exports `whereDraft(ctx)`, the draft store's `where()` for that key, and its own storage listener derives its prefix from it instead of rebuilding `PAGE_SCOPE + DRAFT`. The harness reads the key through `draft_key(page, ctx)` and offers `stored_draft_text`, `stored_draft_settled` and `until_draft_settled`. The storage faults in `test_render_drafts.py` have to run ahead of the runtime's listener, which at the window means being added first. They stay init scripts and compare against a `window.lfDraftKey` that the test sets from `draft_key` once the page loads. **Event log.** `render_cases_interaction.sent_events` and eight inline parsers split `events.jsonl` with `splitlines()`, which also splits at a U+2028 inside a comment. The product reader, `event_log.read_events`, stopped doing that for exactly this reason. Its callers now use it, and `sent_events` is gone. `tests/AGENTS.md` names the four doors next to the rule that already asked tests to consume the product's answer. Left for a follow-up PR, because #1265 edits the same files: `scripts/record-demo.py` and `scripts/eval_claude_delivery.py` still parse the log with `splitlines()`. Checked with `npm run test:runtime` and each touched test: the 35 overflow tests, the whole `test_render_drafts.py`, and the import and log sites (134 passed; the one xfail is the strict, pre-existing `test_a_specimen_holds_a_wide_exhibit_inside_the_column`). The storage-fault tests failed while their fault ran after the runtime's listener, which shows that ordering carries the test. > _This was written by Claude Code on behalf of max-sixty_ 🤖 Generated with [Claude Code](https://claude.com/claude-code)
An open turn whose hooks carry input reads the page listening only until the working grace after it opened, but no deadline named that boundary: with the status already quiet, next_transition_at was null and a browser kept showing Listening after a turn no Stop closed. The eligibility of the open turn is now read once, and both the deadline and the listening reading consume it. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
leaf-agent
approved these changes
Sep 27, 2026
max-sixty
added a commit
that referenced
this pull request
Sep 27, 2026
…event_log in scripts (#1289) Which environment variables make a process a host session is now stated once, in `host.py`, and the three places that kept their own list read it instead. `host.py` already listed each harness's `session_variables`. Each harness now also declares `identity_variables`: its session variables plus the ones its `lifetime` reads, which for Claude Code are `CLAUDE_PID` and `CLAUDE_JOB_DIR`. `IDENTITY_VARIABLES` collects every harness's set and `LEAF_AGENT`, now named `AGENT_VARIABLE`, the display name any harness takes. It replaces `SESSION_VARIABLES`, whose only readers were the scrubbers below. - `tests/conftest.py` builds `sessionless` and `isolated_session` from `IDENTITY_VARIABLES`, and `CLAUDE_IDENTITY` from `ClaudeCodeHarness.identity_variables`. `CODEX_IDENTITY` is gone, since its two remaining uses meant the whole set. A new host variable now reaches the suite's isolation without a second edit. - `scripts/site.py` also scrubs `CLAUDE_PID`, `CLAUDE_JOB_DIR` and `LEAF_AGENT` from the build's environment, so the builder's display name can no longer sign a published version note. - `scripts/eval_harness.py` also scrubs `LEAF_AGENT`, so an eval child no longer speaks as its launcher's named worker. Its `CLAUDE*` prefix rule stays: it covers settings, such as the effort level, that no host reads. This also finishes the event-log half of #1276, which waited on #1265 because both touch the same scripts. `scripts/record-demo.py` and `scripts/eval_claude_delivery.py` now read `events.jsonl` through `event_log.read_events` rather than `splitlines()`, which splits a comment at U+2028, and so does one more test that read the file raw (`test_each_carrier_hands_the_agent_what_the_snapshot_shows`). Two raw reads stay where the file's bytes are the subject: a snapshot of the stored line, and a check that `seq` is never stored. `TODO.md` gains one entry for what #1285 left: prefix selectors in `test_render_controls.py` and `test_render_threads.py` still spell a suggestion's contribution key. Checked with `test_interact_{session,contract,anchors,product,server}.py` (781 passed), and by importing all four scripts and confirming `eval_harness.environment()` drops every identity variable. > _This was written by Claude Code on behalf of max-sixty_ 🤖 Generated with [Claude Code](https://claude.com/claude-code)
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.
Claude Code now takes page input through Leaf's hooks instead of spending model steps on it. Before, a comment reached the model as a background
leaf waitfinishing: the model had tocatthe wait's output file and rearm withleaf wait --ackbefore it could name its work, which put Picked up 5–8 s behind delivery and the work status 8–14 s behind. Now Leaf's UserPromptSubmit hook (which fires on every turn a task notification opens, idle or mid-turn) and its Stop hook put the whole delivery into the turn's context and confirm it, andleaf waitonly wakes the session.Measured with paired real Claude Code sessions (
scripts/eval_claude_delivery.py, 6 comments per arm):cat+leaf wait --ackDelivery (
hooks.py,session.py,host.py)composefreezes ahookdelivery (new carrier indelivery.py), builds the whole message, then confirms each batch withreceive_one. A page that changed hands in between is refused and the message says so. Nothing is confirmed that the model might not see.sessions/<id>.hooks;Harness.hooks_carry()requires Claude Code and that mark. A session launched without the hooks still gets the envelope printed, so it can't loop on empty wake-ups. SessionEnd removes the mark.additionalContextover 10,000 characters for a preview and a path, so a delivery that large goes as a pointer (acknowledgeset) that the model reads and confirms. The limit is held to UTF-8 bytes since the unit is unmeasured.stop_hook_active) is held open only by user-authored input.leaf wait --ackremains for hosts whose wait prints the delivery (Codex task loop, bare shell).Reply and banner
answeringclause inregistry.jsonis claim-first:leaf status … working --on <thread>, then the work, then oneleaf thread reply --for. No provisional "will do" reply, so a comment goes Sent → Picked up → Working → answered without flicking back.listeningrather thanaway, only when its hooks carry input and the turn opened withinWORKING_GRACE(activity.py,presence.py; claims now carryturn_opened).Benchmarks
scripts/bench_render_check.py: timesleaf version check --render, base against head, with a per-phase profile viasys.monitoring. About 2 s of the ~7 s triage check is 100 ms polling; four page loads are most of the rest.scripts/bench_page_latency.py: in-tab responsiveness in Chrome, base against head, with requests and bytes. Triage-board meets every target innotes/user-feedback-responsiveness.md; the corpus page misses on comment paint (~220 ms), board move (111–155 ms) and revision swap (2.7–2.9 s).scripts/eval_claude_delivery.pyscores either protocol, reporting route (notification / prompt hook / stop hook), receipt time, and what ran before the claim.Guidance and tests
host-claude-code.md,event-batches.md,conversation-loop.md,session-lifetime.mdanddocs/how-it-works.htmldescribe the hook carrier. New tests at the hook boundary cover Stop handover, repeated Stop, a page that changed hands, oversized input, the evidence gate, and the open-turn rule; the rest of the suite is ported to the new wait output. Most of the diff's size is regenerated regtest snapshots (~920 lines) and the two benchmark scripts (~1100).🤖 Generated with Claude Code