Repository navigation
Keep a turn going only for what it owes, through Claude Code's non-error channel - #1433
Merged
Merged
Conversation
…ror channel Leaf's Stop hook held turns open when nothing was owed, and every hold read "Stop hook error" in Claude Code. An audit of the obligation state machine behind it found three causes. - The hook continued a turn with `decision: block`, which Claude Code labels an error. Its Stop schema also takes `hookSpecificOutput.additionalContext`, "non-error feedback" after which the turn continues (2.1.284; a headless probe saw the turn go on and the next Stop arrive with `stop_hook_active`). The hook's output now comes from `Harness.continue_turn`: that channel for Claude Code, and a block for Codex, whose Stop output schema has nothing else. - A move the agent claimed with `leaf status … --on` still held the turn, though conversation-loop.md tells the agent to claim it, hand long work to background workers and end the turn. Agents posted holding replies, or wrote picks into the markup early, just to be let go. Work claims now record the claimant turn that wrote them, each workflow lists the standing claims over it (`claimed_by`: one naming the move, on its widget, or on the thread that holds it), and `activity.turn_obligations` drops the moves the open turn claimed since their pickup; the browser's local workflows carry the same field, so the served shape stays one. The claim does not carry into the next turn: that turn answers the move or claims it again, and its Stop line offers the second route only for a move a standing claim covers. `leaf status idle` still refuses over a claimed move. - Input that owes nothing, such as a resolve, a report or a page error, arriving as a turn ended kept the turn going to deliver it, on a repeated Stop too. The Stop hook now continues a turn only for owed input or a debt it names; other input waits for the watcher and rides along when the turn goes on anyway. The Loop tab of How it works gains a section with a state diagram of a move and a flowchart of the Stop check. session-lifetime.md, conversation-loop.md, event-batches.md and authoring-revisions.md state the new rules, the `$updates` contract names the claim's `turn`, and `leaf-dev delivery-eval` counts any Stop output as a hold. Tests: the Stop tests read the Claude Code continuation (the snapshots move from `decision`/`reason` to `hookSpecificOutput`); new tests cover a move claimed in the turn, a follow-up and a frozen-Ask move under a thread claim, a settled claim offering no re-claim, and a lone resolve at Stop. No `evals/` case bears on the conversation-loop sentence, so none was scored. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
leaf-agent
approved these changes
Sep 29, 2026
max-sixty
added a commit
that referenced
this pull request
Sep 30, 2026
…en claim a turn (#1451) Main's nightly job fails on 776 of its 2,107 tests. Two main commits caused it, and neither PR ran the nightly-marked tests. - **The shift watch (#1432).** `EXPECTED` in `tests/shift_watch.js` lists the shifts without input that the broad selection's pages make. The nightly-marked tests' pages make many more: 809 distinct moved elements, reported as teardown errors on 766 tests. Examples are `INLINE_PAGE`'s `lf-options` growing its 44px write-in row as it upgrades under authored HTML that already painted, which pushes every paragraph below it down, and `ASK_PAGE`'s Ask pushing its sections down 63px. Listing them region by region would turn `EXPECTED` into an allowlist of most of the corpus. The nightly-marked tests now skip the watch (`tests/conftest.py`, `_watches_shifts`). The broad selection still fails on any shift the list doesn't name. - **A claim without a turn (#1433).** #1433 made `turn` a required claim field, and `claim_update_sources` drops a claim that lacks it. The claim that `test_an_exact_workflow_reports_stale_work_beside_a_live_page_claim` writes by hand had no `turn`, so its thread read Sent instead of Working. The claim now names `turn-1`, the turn `record_claim` gives its session, as `set_status` would record it. This is the same line #1449 proposes. - **A status read at one stage (#1450).** `test_the_margin_groups_meanings_at_one_destination_without_moving_the_page` found the move's status by the text "Sent for". The pickup grace can run out during the journey and relabel it "Waiting for pickup", which is how [nightly run 36633195934](https://github.com/max-sixty/leaf/actions/runs/36633195934) failed. The test now finds the status by role at any stage. #1450 also found that the Ask fixture's startup shift would still fail the test at teardown; with the nightly tests off the shift watch, that no longer happens. On macOS, a full nightly run (`pytest tests --run-nightly -m nightly`) on main before this change had 56 failures and 807 errors. After it, the run had 3 failures and 1 error. Two of those failures pass when re-run serially, which points to load (the load average was 39). The third was the claim test fixed here. It and the margin test both pass now. The everyday selection passes (1,451 tests). The nightly pages' shifts are still defects under the Stability rule. Bringing the nightly tests back under the watch means fixing them, starting with the widgets that grow as they upgrade. > _This was written by Claude Code on behalf of max-sixty_ 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- 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's Stop hook held turns open when nothing was owed, and every hold read "Stop hook error" in Claude Code. An audit of the obligation state machine behind it found three causes.
decision: block, which Claude Code labels an error. Its Stop schema also takeshookSpecificOutput.additionalContext, "non-error feedback" after which the turn continues (2.1.284; a headless probe saw the turn go on and the next Stop arrive withstop_hook_active). The hook's output now comes fromHarness.continue_turn: that channel for Claude Code, and a block for Codex, whose Stop output schema has nothing else.leaf status … --onstill held the turn, though conversation-loop.md tells the agent to claim it, hand long work to background workers and end the turn. Agents posted holding replies, or wrote picks into the markup early, just to be let go. Work claims now record the claimant turn that wrote them, each workflow lists the standing claims over it (claimed_by: one naming the move, on its widget, or on the thread that holds it), andactivity.turn_obligationsdrops the moves the open turn claimed since their pickup; the browser's local workflows carry the same field, so the served shape stays one. The claim does not carry into the next turn: that turn answers the move or claims it again, and its Stop line offers the second route only for a move a standing claim covers.leaf status idlestill refuses over a claimed move.The Loop tab of How it works gains a section with a state diagram of a move and a flowchart of the Stop check. session-lifetime.md, conversation-loop.md, event-batches.md and authoring-revisions.md state the new rules, the
$updatescontract names the claim'sturn, andleaf-dev delivery-evalcounts any Stop output as a hold. TODO.md gains the next step:leaf waitstill wakes the agent for input that owes nothing, such as a resolve of a thread already answered, and should wake only for input that changes what the agent owes.Tests: the Stop tests read the Claude Code continuation (the snapshots move from
decision/reasontohookSpecificOutput); new tests cover a move claimed in the turn, a follow-up and a frozen-Ask move under a thread claim, a settled claim offering no re-claim, and a lone resolve at Stop. Noevals/case bears on the conversation-loop sentence, so none was scored.🤖 Generated with Claude Code