Repository navigation
Deliver Leaf comments between tools and simplify responsiveness evals - #3169
Merged
Merged
Conversation
leaf-agent
reviewed
Oct 19, 2026
leaf-agent
left a comment
Collaborator
There was a problem hiding this comment.
The during-work evaluation has two scoring paths that can give the wrong verdict: it rejects an idle parent while a worker continues, and it can accept page content written after the observation cutoff.
leaf-agent
approved these changes
Oct 19, 2026
max-sixty
added a commit
that referenced
this pull request
Oct 20, 2026
Max reads Claude Code in focus view, which shows each turn's prompt and final message only. When a page comment arrived after a turn's last tool call, Leaf's Stop hook handed it into that turn and continued it, so the agent's reply to the comment became the turn's final message and hid the answer the user had asked for. Max's sessions of 2026-10-10 to 10-19 hold 65 Leaf Stop continuations; 56 handed in new input this way, and 59 of the 65 replaced a final message of 300 characters or more. A scripted real session on main reproduced it: a 350-word answer to a terminal question gave way to "You asked 'When could that fix land?'…". ### What changes - **Stop leaves late input to the watch** (`hook_transport.carry_turn`). Where a watch follows the turn (`Harness.watches_between_turns`: Claude Code at its terminal or fed `--input-format stream-json`, Pi with a UI), Stop hands no input over. It closes the turn, the watch wakes on the close, and the input arrives through the prompt hook of a turn of its own. The same scripted run on this branch ended the user's turn on its answer and answered the comment in the woken turn; arrival to pickup took 11 s against 13 s on main, both mostly the model writing its answer. Under plain `claude -p` or `pi --print`, where nothing watches after the run, Stop still hands input into the turn it continues. - **Pi says whether it watches.** `PiHarness.watches_between_turns` answered yes in every mode, though the extension starts its watch only with a UI; the extension now exports `LEAF_PI_WATCH`, so a print run keeps its Stop handover. - **The hooks module stops appending deliveries.** With no inline delivery at Stop in an interactive session, the module no longer runs Leaf's Stop hook itself to append one out of the terminal's sight. Its mark stands down only the background watch, and `hooks.json`'s Stop registration runs beneath it as without the module. The `leaf_delivery` output field had no other reader and goes, with the test driver's append support. - **Prose** in `session-lifetime.md`, `harness-claude-code.md`, the site's "Stop hook checks" and the module headers now says Stop hands input over only where no watch follows. ### Tests Stop-delivery receipt tests run under a new `printing` fixture (plain `--print`); new tests hold that an interactive Stop leaves input to a turn of its own, for Claude Code in process, through the hooks module, and through Pi's extension. Each fails against main's rule. The claude-code journey now requires, at every step, that no Stop hook continued a turn with input. It passed in full without the hooks module; with it, every step through `escape` passed and `woken` failed on an expectation #3169 left stale (it waits for a mid-turn pickup the module no longer makes), which this PR doesn't touch. ### Left open Stop still continues a turn once for an update picked up and unanswered, or for a page it could not re-vendor, which also replaces the turn's answer in focus view (9 of the 65). Waking a turn for that reminder needs a record that it reminded, or an agent that won't act is woken without end; dropping it leaves only the next prompt's reminder. TODO.md holds that as Max's decision. > _This was written by Claude Code on behalf of max-sixty_ --------- Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
max-sixty
added a commit
that referenced
this pull request
Oct 20, 2026
…scape (#3283) `uv run leaf-dev journey claude-code --hooks-module` failed its `woken` step on main with "woken: the command ended before Escape". The step waited for the hooks module to hand the comment to the running turn while its shell command still ran, and only then pressed Escape. #3169 removed that mid-turn append, so pending input now waits for the next PostToolBatch, which fires only when the command ends. In the failing run on main, the comment arrived at 23:40:13 and was picked up at 23:40:38, when the 25 s sleep finished. The module itself behaves as its header describes. The turn never read the comment, so the watch the module starts after Escape wakes for it, Claude Code drops the prompt, and the page nudges the session, whose new turn answers it. The step now requires that outcome, and no longer relies on the old append or the "Carry on" prompt that answered it. - `woken` requires that the turn has not read the comment when Escape lands. With the module, a turn after Escape must answer it without the user typing. In both modes, the comment sent afterwards must be answered too. - `after_escape` takes the stopped turn. It accepts a later turn in place of a closed one or a running watch, because the watch after Escape may already have woken that turn. - The module's suite test (`test_the_module_hands_input_to_a_running_turn_and_closes_an_interrupted_one`) now leaves an unread comment pending at Escape, the journey's case. Before, it posted the comment after the watch had started. Journey results: on main, `--hooks-module` failed at `woken` after `escape` passed. On this branch, every step passed in two runs with `--hooks-module`, where `woken` read "turn closed, no watch running, the page reads working; nudged", and in one run without it. > _This was written by Claude Code on behalf of max-sixty_ Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
max-sixty
added a commit
that referenced
this pull request
Oct 24, 2026
Cuts the guidance Leaf ships to agents — the skill, its references, package instructions, registry instruction strings and the text Leaf's code prints — to the claims an agent acts on. This is the agent half of the guidance cut; the maintainer half (groups A–E) lands separately. Each group was cut on its own branch, reviewed side by side against main, and is one commit here, merged onto current main with main's later changes kept. Each commit message lists what its group cut, what it kept and how each conflict with main was resolved. ## Groups Word counts are `wc -w` on main (`79af4eb2f`) and on this branch. **F — SKILL.md and the conversation loop** (11 files, 12,418 → 11,115, −10%). Drops what command `--help` already says, what delivered `handling` already says, mechanism no reader acts on (the surfaces table, Sent/Queued/Delivered, the desktop wake, Codex's queue check, the render check's JSON fields), duplicates and justification. Corrects SKILL.md step 1: running `page init` again with `--package` replaces the page's packages rather than adding one. **G — page authoring and layout** (5 references, 8,120 → 6,868, −15%; default registry x-instructions 1,810 → 1,533; kernel 116 → 104). Drops each file's route restatement, copies of other references and of registry entries, rules `page check` already reports, narration that asks nothing of the author, and hedges with no failure behind them. Moves the side-list tab summary rules and the tally rule from `lf-tab`/`lf-tally` into `page-layout.md`, "A workspace", which agents re-read when revising (queue-is-a-side-list went 0/2 → 2/2). **H — module references** (6 files, 14,420 → 12,871, −11%). Keeps every `widget-api.js` export's signature, return and usage rule; drops section lists, runtime mechanism, refusals the runtime already throws into a page error, restatements and maintainer-only build detail. module-authoring's route to module-reading.md now names icons (widget-interface-serves-the-task 1/4 → 4/4). **I — packages** (3 references and the 10 instructions files, 10,324 → 9,572, −7%; package registry instruction strings 1,444 → 875). Removes duplication between each package's instructions file and its registry entries, which `page instructions --use` concatenates, so the registry keeps markup and API facts and the instructions file keeps choice rules. Drops `--help` restatements, refusals a check reports, and playground's "Task-shaped recipes", whose shared rules now sit under "Stateful previews" and in the handoff check. Corrects `lf-playground-preset`: a control the preset doesn't set keeps its current value. **J — text Leaf's code hands agents** (delivered handling/answering clauses 1,490 → 1,237; every event case's delivery, per the snapshot, 9,076 → 7,317 words). Drops narration of what Leaf does by itself, restatements, justifications and the `invalid-registry` finding, which nothing produces. Moves the anchor-move rule from every reply clause to the `relocated-anchor` finding, and corrects `page check --help`: a plain check also runs the page's scripts and browser-judged widgets. A sixth commit repoints four references at conversation-loop.md's "Page availability and handoff", which main renamed from "Status and handoff" without updating them, and fixes packages.md's pre-#3593 path to `src/leaf/layer-registry.md`. ## Eval-backed passages kept - Answer a question you can already settle before revising the page (`parent-keeps-leaf-responsive/known-answer`, #3169). - The `leaf task plan` paragraph and example (`0ae092c32`, 1/5 → 4/4 on Claude Code). - The second `thread summarize` example (`thread-fold-without-summary-prose`). - Progress and failure replies publish nothing. - A bounded `<pre>` or table clips what runs past it, with the `data-bound` and `<details>` routes (#3347). - The touch route for hiding markers: the leaf's menu → Annotations → Hide annotations (`pin-takes-no-page-room`). - The route to a package's other audiences, such as a contract's `producer`. - A widget output's value must fit its contract, since nothing checks it; `wireInput`'s keys; `failSoft`'s `source`; a `start` that throws not running again. - The progress line before any other command, "even a read" (`first-command-says-what-comes`), and the reply's own check of the saved edit. - "An option the user added needs no writing in" on the markup clause (#2632). ## Checks - `pytest -n 3` over test_hooks, test_stop_guard, test_wait, test_receipts, test_thread_reading, test_interact_layer, interact_contract/, test_delivery, test_interact_product, test_interact_anchors, test_activity and test_product_page: 848 passed, 1 failed. The failure, `test_hooks.py::test_a_prompt_re_vendors_a_page_an_older_leaf_vendored_and_hands_over_its_input`, received a pointer instead of an inline delivery on a host at load average 30; it passes when run alone. - The six snapshots group J's strings reach were regenerated with `--regtest-reset` from the resolved code; `tests/process/website_server/test_app_server.py` passes with its snapshot unchanged. - `node --test tests/runtime/widget-api.test.mjs`, which requires every authoring export to be named in a module reference: 4 passed. - `leaf package check` on all eleven bundled packages: no findings. - `pre-commit run --files` over the 53 changed files: passed. - Every `file.md, "Heading"` and `file.md#anchor` pointer in the changed prose resolves on this tree, and pointers into files groups A–E change resolve on those branches. No removed heading is cited anywhere. - An independent review redid each group's merge file by file and checked every conflict by hand against main's additions and the group's reviewed diff. It found no lost claim; three reviewed cuts that main's rewordings had brought back (a `--attempt` sentence in `thread reply --help`, a second `module-state.md` pointer in `package-data.md`, and the `lf-motion` registry string repeating `instructions/author.md`) are reapplied in the last commit, with the command-help snapshot regenerated. Not run: the browser and journey tiers, and no evals were rerun after assembly; each group's evals ran on its own branch against its merge base. > _This was written by Claude Code on behalf of max-sixty_ --------- Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
max-sixty
added a commit
that referenced
this pull request
Oct 25, 2026
Records the October 2026 research on whether Leaf should start and drive the agent session itself (Claude Agent SDK, Pi, Codex App Server) rather than ride the user's harness, so it can be revisited later. Documentation only; no behavior changes. `notes/leaf-run-sessions.md` holds where a reply's time goes, a survey of how long comments wait on real pages since #3169, which controls each surface exposes to a companion (Claude Code and the desktop Codex app expose none beyond input at the tool boundary), a forked Claude Code side-lane measurement with its command, subscription terms as of 25 October, and the three options with the recommendation recorded but no option chosen. `TODO.md` gains a triggered Etc item pointing at it, and `notes/codex-integration.md`'s "Make Leaf the Codex client" links to it. > _This was written by Claude Code on behalf of max-sixty_ Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
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.
Leaf comments could wait until Claude stopped a turn, while the parent continued implementation or tests. Deliver pending input through native PostToolBatch before the next model call, using the existing envelope and receipt. Keep one mid-turn delivery owner in both watcher modes, leave parent input untouched in worker hooks, and preserve resume and refused-wake recovery.
Make the parent own the Leaf conversation and delegate substantive work. Consolidate delivery evals onto the existing LiveSession/LiveChild and response-time query; remove the second interactive runner, stream-order timing reconstruction, compaction-specific restoration, and its separate workload. The repair fixture owns correctness checking, and the shared session retains native parent and worker traces.
The new during-work case posts consecutive questions and steering while a report is repaired. It measures first feedback separately from completed thread replies, task correctness and page content. Real Claude and Codex pilots implemented the steering and served the revised page before the 90-second cutoff, but had not closed that thread. That is incomplete conversation closure, not ignored steering or failed implementation. Compaction causality and population latency improvement remain unestablished.
Workload injection accepts an idle parent waiting on its worker. Page and task evidence freeze at the observation boundary before session teardown, keeping later edits out of grading.
Validation: focused hook/process checks and the consolidated developer evaluator smoke tests; pre-commit and independent review; native Claude/Codex workload runs with retained logs and task snapshots. Developer tests remain outside product CI as main defines.