Repository navigation
feat: store interrupt sends in the steer lane - #31155
ethanndickson merged 3 commits into
Conversation
|
@codex review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
feec7ad to
d04d3af
Compare
d04d3af to
f3b97ca
Compare
f3b97ca to
5ad6ffb
Compare
5ad6ffb to
ec3def8
Compare
ec3def8 to
38face0
Compare
38face0 to
1e33829
Compare
1e33829 to
9ffd3f0
Compare
693512e to
9b34e1a
Compare
9b34e1a to
a052416
Compare
a052416 to
69e0c1c
Compare
|
@codex review |
💡 Codex Reviewcoder/coderd/x/chatd/ARCHITECTURE.md Line 143 in 69e0c1c 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 ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
a7c6cef to
6125048
Compare
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.
6125048 to
f5ab996
Compare
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
…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
…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
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
codersdkchange is just the doc comment onChatBusyBehaviorInterrupt.Part of CODAGT-1140