room: steer mid-turn chat to the next step boundary #1

Merged
vhaudiquet merged 2 commits from kosmos/rhema-together:room-chat-steering into main 2026-12-02 17:02:50 +00:00
Contributor

A message posted without a mention while the agent works waits for the next
turn today, so the model reads it only once the work the line is about is
finished. The spec's turn rules already promise the mid-turn half ("the next
step of the running turn"); the runner implements the turn-boundary half only.

This wires the framework's steering hook, which is already in the pinned
rhema-host-agent 0.5.2 (HostAgentConfig::steering, re-exported Steering)
and was simply passed as None.

What changes

  • runner::RoomSteering is the turn's source. 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, which the drop
    path owns and would otherwise be appended twice, or a message with images,
    which a line of text cannot carry — and leaves absorbed_seq there, so the
    boundary pass appends them in the log's order.
  • What it does drain advances absorbed_seq (in the row first, then in memory,
    so a failed write re-announces rather than drops), so the next boundary pass
    cannot repeat it.
  • agent::build_agent takes the source and passes it through.

What does not change

A mention still drops the turn future and restarts over the committed session.
That is the only way to stop a long shell command, and the interrupt semantics
in the spec's turn rules stay as written. This commit also does not touch
approval, the message tool, or the wire: a steered line reaches the room's
history, its author already prefixed by name: exactly as the boundary pass
writes it.

Verification

cargo fmt --all, cargo clippy --all-targets -- -D warnings and cargo test
were not run: the machine this was written on has no Rust toolchain and no C
compiler, so the tree could not be built. The diff is small and everything it
touches exists in 0.5.2, but treat it as unverified — please run the three
commands before merging.

Not this PR, but it is the answer to "why is it slow when nobody pings"

Time to first message is a prompt problem, not a steering problem: prompt.md
says "Do not narrate every command" and "always send one before your last
message", and the model reads that as "speak at the end". A first message right
after the plan settles TTFM without any framework work. Separate patch if you
want it.

A message posted without a mention while the agent works waits for the next turn today, so the model reads it only once the work the line is about is finished. The spec's turn rules already promise the mid-turn half ("the next step of the running turn"); the runner implements the turn-boundary half only. This wires the framework's steering hook, which is already in the pinned `rhema-host-agent 0.5.2` (`HostAgentConfig::steering`, re-exported `Steering`) and was simply passed as `None`. **What changes** - `runner::RoomSteering` is the turn's source. 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, which the drop path owns and would otherwise be appended twice, or a message with images, which a line of text cannot carry — and leaves `absorbed_seq` there, so the boundary pass appends them in the log's order. - What it does drain advances `absorbed_seq` (in the row first, then in memory, so a failed write re-announces rather than drops), so the next boundary pass cannot repeat it. - `agent::build_agent` takes the source and passes it through. **What does not change** A mention still drops the turn future and restarts over the committed session. That is the only way to stop a long shell command, and the interrupt semantics in the spec's turn rules stay as written. This commit also does not touch approval, the `message` tool, or the wire: a steered line reaches the room's history, its author already prefixed by `name: ` exactly as the boundary pass writes it. **Verification** `cargo fmt --all`, `cargo clippy --all-targets -- -D warnings` and `cargo test` were **not** run: the machine this was written on has no Rust toolchain and no C compiler, so the tree could not be built. The diff is small and everything it touches exists in 0.5.2, but treat it as unverified — please run the three commands before merging. **Not this PR, but it is the answer to "why is it slow when nobody pings"** Time to first message is a prompt problem, not a steering problem: `prompt.md` says "Do not narrate every command" and "always send one before your last message", and the model reads that as "speak at the end". A first message right after the plan settles TTFM without any framework work. Separate patch if you want it.
kosmos added 1 commit 2026-12-02 13:18:41 +00:00
room: steer mid-turn chat to the next step boundary
ci / checks (pull_request) Successful in 51s
ci / test (pull_request) Successful in 54s
ci / chart (pull_request) Successful in 4s
ci / web (pull_request) Successful in 16s
ci / docker (pull_request) Successful in 1m42s
ci / publish-edge-image (pull_request) Skipped
ci / publish-edge-chart (pull_request) Skipped
d310735c71
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 a steering source. 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, which the drop path owns, or a
message with images, which a line cannot -- and leaves the cursor there, so
the boundary pass appends them in the log's order. What it drains advances
`absorbed_seq`, so nothing is appended twice.

A mention still drops the turn: that is the only way to stop a running
command, and this change does not touch it.
vhaudiquet added 1 commit 2026-12-02 17:01:52 +00:00
room: advance the steer cursor after the checkpoint
ci / checks (push) Successful in 55s
ci / test (push) Successful in 59s
ci / chart (push) Successful in 5s
ci / web (push) Successful in 17s
ci / docker (push) Successful in 1m49s
ci / publish-edge-image (push) Skipped
ci / publish-edge-chart (push) Skipped
ci / checks (pull_request) Canceled after 0s
ci / test (pull_request) Canceled after 0s
ci / chart (pull_request) Canceled after 0s
ci / web (pull_request) Canceled after 0s
ci / docker (pull_request) Canceled after 0s
ci / publish-edge-image (pull_request) Canceled after 0s
ci / publish-edge-chart (pull_request) Canceled after 0s
6b2624f0ba
The steering source seeded from `config.absorbed_seq`, which the runner
loaded before the boundary pass advanced the row. When the burst that
started the turn held a chat line before the mention, the first drain read
that line back, appended it a second time, and moved the row backwards,
so the next boundary pass appended the mention again.

The row now has one writer. `RoomSteering::drain` keeps the cursor in
memory, `commit` writes it after `save_session` succeeds, and the
boundary pass hands its own cursor down in the config the turn reads.
That is the order the boundary pass already uses, append then checkpoint
then advance, and the framework's contract for a steering source: a line
that comes back is deduped within the turn, a line retired too early is
gone.

A failed commit leaves the row behind, so a line can repeat, and it
reports the failure instead of swallowing it. The drain rule moves to
`steerable`, a pure function over the messages, and four tests cover it,
the cursor handoff, and the row's waits.
Owner

The first commit's cursor had two writers and started from a snapshot taken
before the boundary pass ran. When the burst that started the turn held a chat
line before the mention, the first drain read that line back, appended it a
second time, and moved the row backwards, so the next boundary pass appended
the mention again.

6b2624f gives the row one writer: drain keeps the cursor in memory,
commit writes it after save_session succeeds, and the boundary pass hands
its own cursor down in the config the turn reads. A failed commit now reports
itself instead of being swallowed, and four tests cover the drain rule, the
handoff, and the row's waits.

cargo fmt --all --check, cargo clippy --all-targets -- -D warnings and
cargo test pass on 6b2624f, so the "unverified" note above is settled.

The first commit's cursor had two writers and started from a snapshot taken before the boundary pass ran. When the burst that started the turn held a chat line before the mention, the first drain read that line back, appended it a second time, and moved the row backwards, so the next boundary pass appended the mention again. `6b2624f` gives the row one writer: `drain` keeps the cursor in memory, `commit` writes it after `save_session` succeeds, and the boundary pass hands its own cursor down in the config the turn reads. A failed commit now reports itself instead of being swallowed, and four tests cover the drain rule, the handoff, and the row's waits. `cargo fmt --all --check`, `cargo clippy --all-targets -- -D warnings` and `cargo test` pass on `6b2624f`, so the "unverified" note above is settled.
vhaudiquet merged commit 0a3c7b7b45 into main 2026-12-02 17:02:50 +00:00
vhaudiquet deleted branch room-chat-steering 2026-12-02 17:02:50 +00:00
Sign in to join this conversation.
No Reviewers
No labels
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: vhaudiquet/rhema-together#1