Repository navigation
feat!: steer chat messages by default and remove the interrupt busy behavior - #31174
ethanndickson merged 12 commits into
Conversation
Docs previewCheck off each page once it's been reviewed. If a page changes in a later push, its checkbox clears automatically so it gets a fresh look. Pages not yet wired into the docs navigation aren't listed here. |
|
@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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a43ef55bb2
ℹ️ 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".
a43ef55 to
6a3df77
Compare
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6a3df7790b
ℹ️ 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".
|
@codex review |
fdc75cd to
f255cba
Compare
|
@codex review |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f255cba759
ℹ️ 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".
|
@codex review |
|
Codex Review: Didn't find any major issues. Nice work! Reviewed commit: ℹ️ 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". |
nickvigilante
left a comment
There was a problem hiding this comment.
One real docs gap worth reviewing
|
@codex review |
|
Codex Review: Didn't find any major issues. 🎉 Reviewed commit: ℹ️ 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". |
…ehavior
POST /api/v2/chats/{chat}/messages now steers by default: a busy chat gets
the message before its next model call. busy_behavior accepts steer or queue.
The interrupt value returns 400. Clients should call the interrupt endpoint and then send.
Queued messages now report their busy_behavior.
POST /api/v2/chats/{chat}/interrupt returned 409 when the chat had no
active turn. A client that interrupts and then sends a message failed
when the turn ended between the two calls, and never sent the message.
Interrupt is now idempotent. From waiting, error, or an owned
interrupting chat it leaves the chat unchanged, and the endpoint
returns 200 with the current chat. InterruptChat reports whether it
interrupted anything, and interrupt_agent returns that value instead of
a tool error for an errored subagent.
The 400 for busy_behavior "interrupt" no longer points at the interrupt
endpoint.
…ctive Replace the two TODO notes that the interrupt no-op change added. - The Interrupt transition lists the states where it writes nothing: W, E0, E1, and an owned I0 or I1 chat. It also says that an unowned interrupting chat, like an unowned running chat, finishes the interruption in the same transaction. - The state diagram gains the Interrupt self-loops on W, E0, E1, I0 and I1, to match the transition matrix. - The interrupt endpoint section lists these states, and no longer says that an owned interrupting chat is rejected.
Add a field comment to CreateChatMessageRequest.BusyBehavior so the generated API schema and reference state that steer is the default and when each value delivers the message. Put each sentence of the new migration guide text and the interrupt endpoint description on one source line, as the docs contract requires.
Follow-up messages now reach the agent before its next model call by default. Document that, the queue option, and interrupting first. Also fix a chatstate comment that still said chatd defaults empty busy behavior to queue.
…ter delivery The next sentences already say not to interrupt first and what happens to queued messages after an interrupt.
The busy_behavior and coder_interrupt_chat descriptions framed a steer message as the way to correct or redirect a busy chat. A follow-up can also add information, so the texts now give only the rule: interrupt a chat only to stop it, not before you send a message.
Say to interrupt a busy agent only to stop it, not to send it a message. Call messages that wait for a delivery point "held", as the architecture page already does, because "queue" is also the name of the lane that delivers after the turn.
The comment still described a single queue whose head an errored chat promotes.
e00d0ee to
043a0c5
Compare
Queued chat messages now store a delivery mode. Later in this stack, `steer` messages go in before the next model call instead of at turn end, so chatd needs to know which queued rows are steer rows. The migration adds the enum `chat_busy_behavior` (`queue`, `steer`) and the column `chat_queued_messages.busy_behavior`. It's `NOT NULL DEFAULT 'queue'`, so existing rows get `queue`, and chatstate still passes `queue` on every insert for now, so this doesn't change behaviour. The old `InsertChatQueuedMessage` query doesn't set the column and just gets the default, but only tests use it. There's no `interrupt` value on purpose. An interrupt isn't a delivery mode, it's something that happens to the chat, and #31174 stops the API accepting it as a busy behaviour. This supersedes #29783. 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
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
"Send now" on a queued message (`POST
/api/v2/chats/{chat}/queue/{queuedMessage}/promote`) now just moves it
to the end of the steer lane. It never interrupts the chat, so it can't
cancel the step that would have answered it. The endpoint's request
doesn't change. Before, it moved the message to the head of the queue
with `MIN(position) - 1`, so if you pressed "Send now" on two messages,
the second one went first. With a queue of `Q1 Q2 Q3 S4`, "Send now" on
`Q1` then `Q3` now delivers `S4 Q1 Q3`, and `Q2` keeps waiting.
If the chat has errored or is paused, the steer lane goes in straight
away, like a send. Otherwise it goes in at the next delivery point:
before the next model call, when the turn ends, or when an interrupt
finishes. Stop is the only thing that interrupts.
"Send now" and "Remove" on a message that's already been delivered now
return a 404 instead of a 409, the same as editing one, and "Remove" on
an archived chat returns a 400.
In chatstate, `SteerQueuedMessage` replaces `PromoteQueuedMessage`. It
moves the message to the end of the steer lane, and on an errored or
paused chat it also delivers the steer lane and resumes the chat, like a
send does. The `SteerChatQueuedMessage` query sets `position =
nextval(...)` and replaces `ReorderChatQueuedMessageToHead`. Most of the
diff is tests.
#31174 then makes `steer` the API default and removes `interrupt` as a
busy behaviour, #31175 makes `message_agent` always steer, and #31173
updates the site.
Part of CODAGT-1140
`message_agent` no longer takes an `interrupt` flag, and always steers. If the child is busy, it gets the message before its next model call and keeps working. To correct or redirect a busy child, the parent just calls `message_agent`, and `interrupt_agent` only stops it, which is the same split the API has after #31174. The tool result also drops `interrupted`, as it was just whether the child was running before the send. That was the last caller of the interrupt busy behaviour, so chatd and chatstate drop it too. `SendMessage` never interrupts now. On a busy chat it only ever adds the message to a lane, so the sends that moved a running chat to interrupting, or a `requires_action` chat back to running, are gone, along with the send's inline interruption finish for chats with no worker. Most of the diff is deleted tests. A steer send to a paused chat, or to an errored chat whose next message is being edited, no longer fails with a 429 at the queue limit when it's delivered straight away, which is whenever the message being edited is a queue message. Part of CODAGT-1140
The site has never sent a `busy_behavior`, so since #31174 a message sent whilst the agent is working already steers. This catches the UI up. The send button now just says "Send" whilst the agent is busy, instead of "Queue", and the queued messages list groups rows by lane, "Next step" for steer messages and "After turn" for queue messages, in the order they'll be delivered. Queue messages can still come from the API or MCP, there's just no way to make one from the site. "Send now" moves a row to the end of the "Next step" group instead of hiding it, and the row leaves the list once the server delivers it. That gets rid of the separate set of hidden "Send now" rows in the chat store. When a send delivers queued messages, e.g. on an errored chat, reconciliation now removes the rows named by `queued_message_id` on the inserted messages, instead of assuming it was the queue head. The store also compares queued rows by ID and lane, so a row that only moves to the other lane still re-renders. Removing a queued message now ignores a 404, as the message may have been delivered or removed in the meantime. Since #31156, "Send now" doesn't interrupt, so on a running chat it no longer clears the live stream or sets the status. Whilst the agent is working, a "Next step" row already goes in before the next model call, so we hide its "Send now", and Enter on an empty composer doesn't send a steer head either. The docs now describe the two groups and "Send now". Part of CODAGT-1140
Since #31174 made steer the default, there's been no way to send a queue message from the site, i.e. one that waits for the current turn to end. This adds that back in two ways. Whilst the agent is working, Cmd/Ctrl+Enter now sends the message under "After turn" (`busy_behavior: "queue"`), and Enter still steers. If you've turned on "Require Cmd/Ctrl+Enter to send agent messages", or you're on a touch device where Enter is a newline, Cmd/Ctrl+Enter already sends, so Option/Alt+Enter sends after the turn instead. The send button tooltip lists both shortcuts, as "Send during turn" and "Send after turn". A shortcut isn't very discoverable, and there isn't one on a phone, so right-clicking the send button, or long pressing it on a touch screen, opens a small menu with "Send during turn" and "Send after turn". The menu only opens whilst the agent is busy and there's something to send, as otherwise there's no turn to wait for. Editing a sent message doesn't get the option either, since an edit has no lane to pick. The docs now describe both. Part of CODAGT-1140
Breaking API Change for changelog:
This is where steering becomes the default for API clients. A send without a
busy_behaviorused 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.queuestill 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.ChatBusyBehaviorInterruptis gone.coder_send_chat_messagein 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. The interrupt endpoint also returns the chat unchanged when there's nothing to interrupt, instead of a 409.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 (#31156) reportssteer.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 acceptsinterruptinternally, asmessage_agentuses it, and #31175 removes both.Part of CODAGT-1140