Skip to content

Deliver a Claude Code thread message at once, with its line fork beside it - #6616

Merged
max-sixty merged 6 commits into
mainfrom
wake-on-late-line
Nov 20, 2026
Merged

max-sixty merged 6 commits into
mainfrom
wake-on-late-line

Conversation

@max-sixty

@max-sixty max-sixty commented Nov 20, 2026 •

Copy link
Copy Markdown
Owner

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

  • Which messages get a line fork. The pages follower lists one for each round: an open thread whose waiting messages have nothing of the agent's after the oldest of them, read as the round stood when its newest message arrived. A message that joins a round before its line gets a line fork about all of them. One that joins after the agent spoke in the thread gets none. The follower 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.
  • When the line goes in. Only while its round still awaits it: the thread's waiting messages are the ones the line fork read, and the agent has said nothing there since, by a message or a rewrite. Leaf checks this under the lock the append takes (thread.Receipt's fence), 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 as dropped.
  • On it. Waiting messages read On it once the line stands, until the session answers, as before. Before the line lands they read as their delivery does: Queued, then Delivered.
  • The summary fork still runs beside each listed round, even where the agent spoke first. A delivery leaves the summary hint to it by the same reading.

Deleted

holding.py, line turns (state.AGENT_TURNS and its helpers), the held pickup phase, activity.STARTING_GRACE and 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, and leaf page state's holder. Production code nets −1,079 lines, tests −874, leaf-dev −119.

To weigh

  • The page protocol moves to 53, because the pickup's phases lose held.
  • For the second or two before the line lands, a message reads Queued or Delivered rather than On it.
  • A message the user sends before the pages follower first reads the page gets no line. As before, the session gets it anyway.
  • Whether a delivery carries the summary hint now turns on whether the follower holds the session's lane when the delivery is built (forks.lane_up), rather than on a record in the log.
  • leaf-dev eval run 'line-fork*' --base can't compare across this change, since its scripts call the new forks.look under 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-fork pastes moves to leaf-delivery/52, and test_an_agent_reply_can_remove_a_subject_and_detach_its_open_thread expects the thread's new rewritten_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 check passes. leaf-dev journey run claude-code passed 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.

This was written by Claude Code on behalf of max-sixty

…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
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.
@max-sixty
max-sixty merged commit 43e3196 into main Nov 20, 2026
6 checks passed
@max-sixty
max-sixty deleted the wake-on-late-line branch November 20, 2026 21:54
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`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants