Skip to content

feat: store interrupt sends in the steer lane - #31155

Merged
ethanndickson merged 3 commits into
ethanndickson/chat-steer-next-stepfrom
ethanndickson/chat-interrupt-send-steer
Nov 9, 2026
Merged

ethanndickson merged 3 commits into
ethanndickson/chat-steer-next-stepfrom
ethanndickson/chat-interrupt-send-steer

Conversation

@ethanndickson

@ethanndickson ethanndickson commented Oct 22, 2026 •

Copy link
Copy Markdown
Member

An interrupt send to a running or interrupting chat now goes to the end of the steer lane, and the whole steer lane goes in once the interruption finishes. Before, it went to the head of the queue lane if it started the interruption, or the tail if the chat was already interrupting, and only the head went in. So if you sent two messages with interrupt whilst the agent was stopping, the second one went to the back of the queue. Now both go in once it stops, in the order you sent them.

Interrupt is still a send option here, it just means "interrupt, then steer" now. #31174 removes it from the API and #31175 from message_agent, so you call the interrupt endpoint first, then send.

There's one gap until #31156. "Send now" still only moves a message to the head of its own lane, so if you send with interrupt and then press "Send now" on a queued message before the agent stops, only the steer lane goes in when it stops, and the "Send now" message waits for the next turn end. #31156 makes "Send now" steer too, so both go in.

The codersdk change is just the doc comment on ChatBusyBehaviorInterrupt.

Part of CODAGT-1140

@linear-code

linear-code Bot commented Oct 22, 2026

Copy link
Copy Markdown

CODAGT-1140

@ethanndickson

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-04T10:35:58.621023Z 69e0c1c Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@ethanndickson
ethanndickson force-pushed the ethanndickson/chat-interrupt-send-steer branch from feec7ad to d04d3af Compare October 22, 2026 08:49
@ethanndickson
ethanndickson force-pushed the ethanndickson/chat-interrupt-send-steer branch from d04d3af to f3b97ca Compare October 22, 2026 09:11
@ethanndickson
ethanndickson marked this pull request as ready for review October 22, 2026 10:40
@ethanndickson
ethanndickson force-pushed the ethanndickson/chat-interrupt-send-steer branch from f3b97ca to 5ad6ffb Compare October 22, 2026 10:57
@ethanndickson
ethanndickson force-pushed the ethanndickson/chat-interrupt-send-steer branch from 5ad6ffb to ec3def8 Compare October 23, 2026 01:47
@ethanndickson
ethanndickson force-pushed the ethanndickson/chat-interrupt-send-steer branch from ec3def8 to 38face0 Compare October 26, 2026 04:19
@ethanndickson
ethanndickson force-pushed the ethanndickson/chat-interrupt-send-steer branch from 38face0 to 1e33829 Compare October 27, 2026 00:46
@ethanndickson
ethanndickson force-pushed the ethanndickson/chat-interrupt-send-steer branch from 1e33829 to 9ffd3f0 Compare October 30, 2026 02:18
Comment thread coderd/x/chatd/chatstate/transitions.go Resolved
@ethanndickson
ethanndickson force-pushed the ethanndickson/chat-interrupt-send-steer branch from 693512e to 9b34e1a Compare November 2, 2026 06:50
@ethanndickson
ethanndickson force-pushed the ethanndickson/chat-interrupt-send-steer branch from 9b34e1a to a052416 Compare November 3, 2026 05:56
@ethanndickson
ethanndickson force-pushed the ethanndickson/chat-interrupt-send-steer branch from a052416 to 69e0c1c Compare November 4, 2026 08:55
@ethanndickson

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

💡 Codex Review

- `SendMessage(m, busy_behavior)` inserts a user message directly when the chat is idle, or queues it when the chat is busy. `busy_behavior` must be `queue`, `steer` or `interrupt`. `queue` and `steer` name the lane (see [Queued message lanes](#queued-message-lanes)). Outside `E1`, a busy send with one of them stores `m` in its lane and keeps the status, except a `steer` send from `E1P` or `P`. From `E1`, `E1P`, and `P`, `busy_behavior=steer` inserts the queued `steer` messages and then `m` into history, and `queue` messages stay queued. From `E1`, `busy_behavior=queue` queues `m` as a `queue` message and promotes the next messages. With `busy_behavior=interrupt`, it also requests interruption, or cancels a pending dynamic-tool action and inserts the message directly. A queued interrupt message goes to the end of the `steer` lane. A `queue` send never runs before a message under edit; an interrupt send runs before it, unless an interruption is already in progress.

P2 Badge Correct the stale interruption exception

The final sentence still says an interrupt send does not run ahead of an edited message when an interruption is already in progress. With this change, an interrupt sent from I1P is stored in the steer lane and does bypass an edited queue-lane message, transitioning to I1 as covered by transitions_matrix_test.go:1016; it waits only when the edited message is itself in the steer lane. Leaving the broader exception here makes the architecture reference contradict the implemented state-machine behavior.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@ethanndickson
ethanndickson force-pushed the ethanndickson/chat-interrupt-send-steer branch from a7c6cef to 6125048 Compare November 5, 2026 06:41
An interrupt send now stores the message at the end of the steer lane.
Before, it went to the head of the queue lane from R0, R1, or R1P, and
to the tail of the queue lane from I1 or I1P. FinishInterruption
delivers the whole steer lane, so the message goes into history after
the steer messages that were queued before it. A steer message under
edit still stops the delivery, so the message waits behind it.
@ethanndickson
ethanndickson force-pushed the ethanndickson/chat-interrupt-send-steer branch from 6125048 to f5ab996 Compare November 6, 2026 06:03
@ethanndickson
ethanndickson merged commit 5138fa3 into main Nov 9, 2026
38 of 62 checks passed
@ethanndickson
ethanndickson deleted the ethanndickson/chat-interrupt-send-steer branch November 9, 2026 04:55
ethanndickson added a commit that referenced this pull request Nov 9, 2026
As suggested on #30074, steer messages are now their own lane, rather
than queue rows that jump ahead with a lower position. chatstate uses a
queued message's `busy_behavior` as its lane, and the steer lane always
goes first. `GetChatQueuedMessages` lists the steer lane first, so the
queue is shown in the order it'll actually be delivered.

At turn end, when an interruption finishes, and on a send to an errored
chat, the whole steer lane goes in. If there aren't any steer messages,
the queue head goes in like it does today. So with a queue of `Q1 S1 Q2
S2`, turn end delivers `S1 S2`, and `Q1` waits for the next turn end.

chatstate accepts `steer` here, but nothing sends it yet, so users won't
see a change. Until later in the stack, a few things still ignore the
steer lane:

- An interrupt send goes to the head of the queue lane, so it waits
behind any steer messages. #31155 moves it to the end of the steer lane.
- "Send now" on a running or interrupting chat only moves the message to
the head of its own lane, so when the interruption finishes, the steer
lane goes in instead of it.
- "Send now" on an errored chat, or one waiting on tool results, puts
the message into history straight away, ahead of any queued steer
messages.

#31156 fixes both "Send now" cases by making it steer. None of these can
happen yet, as there are no steer messages to get in the way.

I've added a "Queued message lanes" section to the chatd architecture
doc. Most of the diff is new cases in the transition matrix tests.

Since the first review, lane rule 3 in the architecture doc also says
that delivery stops at a message under edit, and which model and
reasoning effort a batch of delivered messages uses.

Part of CODAGT-1140
ethanndickson added a commit that referenced this pull request Nov 9, 2026
…30074)

This is where the steer lane gets delivered mid-turn. Before each
assistant model call, the generation task now runs
`DeliverSteerMessages`. If there are steer messages queued, they go into
history and the task returns without calling the model, and the history
change starts a new generation task that sends them to the model. It
never cancels anything, it just waits for the in-flight call and that
step's tool calls to finish. Queue messages still wait for turn end, and
compaction calls don't deliver steer messages, as they don't answer the
user.

A delivered steer message is a new prompt, so tracing treats it like any
other newer prompt: a new `chat_turn` span starts at it, and the span
before it ends as `abandoned`.

`chatd.SendMessage` now accepts `steer`, but the HTTP handler and
`message_agent` still only pass `queue` or `interrupt`, so the API
doesn't change in this PR. #31174 makes `steer` the API default. Outside
of tests, nothing creates steer messages until #31155 stores interrupt
sends in the steer lane, so this PR doesn't change behaviour for users
on its own.

I've split the earlier version of this PR up, so some of the review
comments are now addressed elsewhere in the stack. #31153 moves queue
delivery into one helper, #31154 adds the two lanes, #31155 stores
interrupt sends in the steer lane, and #31156 makes "Send now" steer,
which also fixes two presses being delivered in reverse order.

This supersedes #29784.

Since the first review, a steer message delivered before a model call
also records `queue_wait`, like the other delivery points.

Part of CODAGT-1140
ethanndickson added a commit that referenced this pull request Nov 9, 2026
…ehavior (#31174)

Breaking API Change for changelog:

> `POST /api/v2/chats/{chat}/messages` now steers by default. If the
chat is busy, the message is delivered before the agent's next model
call, instead of after the turn ends. `busy_behavior` accepts `steer` or
`queue`, and `interrupt` now returns a 400. To redirect the agent, just
send a message, and only call `POST /api/v2/chats/{chat}/interrupt` to
stop it. Queued messages now include their `busy_behavior`.

This is where steering becomes the default for API clients. A send
without a `busy_behavior` used to wait for the turn to end, and now it
goes in the steer lane, so the agent sees it before its next model call
and keeps going. `queue` still waits for the turn to end.

Interrupt isn't a busy behaviour any more. Since #31155 it just meant
"interrupt, then steer", so the API now returns a 400 for it, and
`codersdk.ChatBusyBehaviorInterrupt` is gone. `coder_send_chat_message`
in the MCP server gets the same default and enum. A steer message
already corrects a busy agent, and combining it with an interrupt goes
wrong in either order, so the docs and the MCP tool descriptions now say
to send a message to redirect the agent, and to interrupt only to stop
it.

Queued messages now report their `busy_behavior`, and the queue lists
the steer lane first, so clients can show which messages go in at the
next step and which wait for the turn to end. A message moved with Send
now reports `steer`.

The site doesn't send a `busy_behavior`, so its sends start steering
with this PR, but its queue UI doesn't know about the steer lane until
#31173. chatd still accepts `interrupt` internally, as `message_agent`
uses it, and #31175 removes both.

Part of CODAGT-1140
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