room: steer mid-turn chat to the next step boundary
ci / checks (push) Successful in 51s
ci / test (push) Successful in 1m1s
ci / chart (push) Successful in 5s
ci / web (push) Successful in 18s
ci / docker (push) Successful in 6s
ci / publish-edge-image (push) Successful in 11s
ci / publish-edge-chart (push) Successful in 4s

A message posted without a mention while the agent worked waited for the
next turn, so the model read it only once the work the line was about was
finished. The spec's turn rules already promised the mid-turn half ("the
next step of the running turn"); the runner implemented the turn-boundary
half only.

The turn now hands the framework's steering hook a source over the room's
`absorbed_seq` cursor. The driver drains it between two steps and appends
one User-role message per drain, so the line lands in the history without
the step in flight dying. The drain stops at the first line it cannot
carry, a mention (the drop path owns that one) or a message with images (a
line of text cannot hold them), and leaves the cursor there, so the
boundary pass appends them in the log's order.

The row has one writer. `drain` carries the cursor in memory only, and
`commit` writes it after `save_session` succeeds, which is the order the
boundary pass already uses: append, checkpoint, advance. The boundary pass
hands its own cursor to the turn in the config the turn reads, so the
first drain never reads back what that pass just appended. A line retired
too early would be gone, one that comes back is deduped within the turn.

A mention still drops the turn: that is the only way to stop a running
command, and this change does not touch it.

Co-authored-by: Kosmos <kosmos@vhaudiquet.fr>
This commit was merged in pull request #1.
This commit is contained in:
kosmos authored and Valentin Haudiquet committed 2026-12-02 17:02:49 +00:00
1 parent 2e17e7463c
commit 0a3c7b7b45
4 files changed
+346 -15

No files matched your search

+19 -1
View File
@@ -190,6 +190,21 @@ an `absorbed_seq` cursor, so nothing is appended twice. The cursor
advances on every append, whatever the path, so the boundary pass and
the interrupt path cannot both write the same line.
The mid-turn half of that is the framework's steering hook
(`HostAgentConfig::steering`), not a step-level drop: the turn's
`RoomSteering` source hands the driver one User-role line per drain at a
step boundary, so a member can correct the agent while it works without
the step in flight dying. It stops at the first line it cannot carry, a
mention (the drop path owns that one) or a message with images (a line
of text cannot hold them), and leaves the cursor there, so the boundary
pass appends them in the log's order. The source only reads that
cursor. The turn writes it after the session holding the drained lines
is saved, the order the boundary pass already uses: append, checkpoint,
advance. A crash before the checkpoint repeats a line at worst, and the
framework's per-turn dedupe drops the repeat. What steering still cannot
do is stop a running command: only the mention drop does that, and only
between steps.
A burst of mentions that lands before the first drop completes all goes
into the same restart, in order, one message each. Nothing is folded.
@@ -663,7 +678,10 @@ Backups: the SQLite file (attachments included) and the secret key.
Small and additive, in the framework's own terms:
1. `HostAgent::step` plus the turn setup around it, so a frontend can own
the loop and drop one step. `rhema-code` steers at turn level: it
the loop and drop one step. The steering hook covers the common case
today: chat lands at a step boundary without a drop. A drop is still
what stops a long command, and it still costs the whole turn.
`rhema-code` steers at turn level: it
drops the whole turn future and starts a new turn with the nudge on
the same agent and session (`turn.rs`). That is enough for a
single-user TUI, where a turn boundary is a ledger row. A room wants