Repository navigation
Deliver a Claude Code thread message at once, with its line fork beside it - #6616
Merged
Merged
Conversation
…de it Leaf held each Claude Code thread message from the main session while a line fork wrote the agent's working line: admission opened a line turn and logged a `held` pickup, and the thread went to the session when the line posted, the line fork failed, or the line turn lapsed after 30 s, which #6592 made the page server nudge for. The hold came with #6156, when the line fork also judged whether a working fork should take the message, a judgment the session had to wait for. #6574 removed that judgment, so the hold bought only that the line went in before the session's own words. Max chose on 20 Nov 2026 to deliver at once, reversing the decision `forks.py`'s header recorded ("The user chose to hold a kept-back message this way"). A thread message now reaches the session as any input does, delivered and nudged as in Codex and Pi, and the line fork runs beside it: - The pages follower lists a line fork for each round that awaits a line: an open thread whose waiting turns have nothing of the agent's after the oldest of them (`forks.unlined`). It lists only rounds newer than its first look at a page, and the module runs each id once, so a round gets at most one line fork, across a module reload too. - The line goes in only while its round still awaits it, asked under the lock its append takes (`thread.Receipt`'s `fence`); otherwise it is recorded as dropped. So it never lands after the session's words in the thread, nor speaks for a round a later message joined. - The waiting messages read On it once the line stands, until the session answers, as before. They no longer read On it before the line lands. - A delivery leaves a thread's summary hint out where its newest message came to a round that awaited a line while a follower held the session's lane, since the summary fork beside that line fork takes the hint. Deleted: `holding.py`; line turns (`state.AGENT_TURNS` and its helpers, presence's `agent_turns`, the served reading's `$agents`); the `held` pickup phase, so the page protocol moves to 53; `activity.STARTING_GRACE`, `running_agent_turns`, `agent_turn_end` and `agent_holds`; admission's `kept_from_main_at_admission` and its `fork_admission` note; the hand-over, `_line_runs` and the follow-up that replaced a line turn; delivery's branch for input a line turn kept past the cursor, and `not_awaited`; the `fork-holds-thread` advice; `leaf page state`'s `holder`; and #6592's lapse nudge (`presence.nudge_left` is `nudge_interrupted` again). A line fork's outcome is now `posted`, `dropped`, `refused` or `failed`.
#6573 moved the delivery record to format 52 and gave each thread digest `rewritten_from`; the third delivery `beside-work-goes-to-a-fork` pastes still had neither, which test_every_delivery_an_eval_pastes_is_the_envelope_leaf_writes caught on main.
The fold keeps only a message's latest rewrite, so counting an agent's rewrites in a reading as of an earlier seq let a later rewrite change what that moment read: the follower could list a round anew, and ask its summary fork, after the delivery had already given the session the hint. The reading as of a seq now counts the agent's messages, which never move; the current reading, which decides whether the line goes in, still counts rewrites. Codex's re-review found it; the new test fails without the fix.
The Anatomy of a fork journey followed a 19 Nov run under the hold, whose Leaf lane kept the message back and handed the thread over. It now follows the claude-code journey's run at 10:55 PT on 20 Nov 2026 on this branch's code: Leaf admits the message and lists it for a line fork, posts the line 1.6 s later, and delivers the message at the main thread's tool call at 25.0 s. Every time and Claude Code text comes from that run's evidence; the prompt slot for the delivery is `delivery` rather than `hand-over`.
leaf-agent
previously approved these changes
Nov 20, 2026
… the thread state test_an_agent_reply_can_remove_a_subject_and_detach_its_open_thread compared the whole thread record, and #6573 added rewritten_from to it without updating this expectation, so the test failed on main as on this branch.
leaf-agent
approved these changes
Nov 20, 2026
max-sixty
added a commit
that referenced
this pull request
Nov 21, 2026
…e protocol 54 #6616 took protocol 53 and removed line turns, `holding.py` and the `held` pickup. holding.py stays deleted, and `deliverable` keeps this branch's named receipts without its reading of who holds each thread: what no receipt names, less what awaits its receipt in the open turn, with each update both pending and owed handed over once. `receive_passed`, which main kept for `confirm_entered`, goes, since that receipt now names what the transcript shows. The line-turn tests main deleted stay deleted, and the owed answer keeps `acknowledged` without main's removed `holder`.
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.
A Claude Code thread message now reaches the main session at once, delivered and nudged as any input is, as in Codex and Pi. The line fork runs beside the delivery and posts the agent's working line when it answers. Until now Leaf held the message from the session while the line fork wrote, for up to 30 s.
Max chose this on 20 Nov 2026. The hold came with #6156, when the line fork also judged whether a working fork should take the message, and the session had to wait for that judgment. #6574 removed the judgment, which left the hold buying only that the line went in before the session's own words. This reverses the decision
forks.py's header recorded, and deletes the hold and everything that existed only for it.What holds now
thread.Receipt'sfence), so a line never lands after the session's words, nor speaks for a round a later message joined. A line that fails the check is recorded asdropped.Deleted
holding.py, line turns (state.AGENT_TURNSand its helpers), theheldpickup phase,activity.STARTING_GRACEand the lapse, #6592's lapse nudge, admission's keep-back, the hand-over, the follow-up that replaced a line turn, delivery's branch for input a line turn kept past the cursor,fork-holds-thread, andleaf page state'sholder. Production code nets −1,079 lines, tests −874,leaf-dev−119.To weigh
held.forks.lane_up), rather than on a record in the log.leaf-dev eval run 'line-fork*' --basecan't compare across this change, since its scripts call the newforks.lookunder the base arm's Leaf too.How it works' Forks tab describes the new flow, and its "Anatomy of a fork journey" is re-recorded from the journey run on this branch.
Also fixes two tests #6573 left failing on main: the third delivery that
evals/beside-work-goes-to-a-forkpastes moves toleaf-delivery/52, andtest_an_agent_reply_can_remove_a_subject_and_detach_its_open_threadexpects the thread's newrewritten_from.Tests: model and process suites for the touched modules pass. New tests cover delivery at once, a joining message, the agent speaking first (answer, message, progress, rewrite), the race under the lock, a repeated step, and the summary fork's ownership. Each new guarantee has a test that fails without its fix.
pnpm run checkpasses.leaf-dev journey run claude-codepassed all 14 steps on the final code. The line was in the thread 1.6–2.0 s after each message (the line fork itself took 1.3–2.0 s), and an idle session's prompt took a message 0.2–0.4 s after it was sent. Before this change it waited for the line. Codex reviewed the change and then its fixes. It found three gaps, each fixed with a test that fails without the fix: a rewrite of the agent's own answer didn't stop a late line, the agent's progress could leave a long thread's summary with no owner, and a second rewrite could list a round again.