Skip to content

fix: run chat interrupt messages before earlier queued messages - #30729

Merged
ethanndickson merged 3 commits into
mainfrom
ethanndickson/chat-interrupt-send-first
Oct 14, 2026
Merged

ethanndickson merged 3 commits into
mainfrom
ethanndickson/chat-interrupt-send-first

Conversation

@ethanndickson

Copy link
Copy Markdown
Member

If an agent is working with a message already queued, and you send another message with busy_behavior=interrupt, the agent stops, but then answers the queued message first and yours second. The interrupt send appends to the end of the queue, and finishing the interruption promotes the head of the queue, which is the older message.

To fix, we'll put the message that starts the interruption at the front of the queue, so it's the one promoted once the partial response is saved. Messages sent whilst an interruption is already in progress still go to the back, as they do today, so a burst of interrupts keeps the order it was sent in. On a chat waiting on dynamic tool results, or one that errored with messages still queued, an interrupt send now goes straight into history ahead of the queue (cancelling any pending tool calls), instead of waiting behind it.

This is just a narrow fix to the current queue behaviour, and it doesn't change the API shape. It's compatible with the queued message delivery rework I've got in progress, which replaces these code paths. The one case this doesn't fix is a second interrupt sent during the first, which still waits behind earlier queued messages; that rework handles it properly.

A busy_behavior=interrupt send on a running chat appended the message
to the queue tail, so finishing the interruption promoted an older
queued message first. The send that starts the interruption now moves
to the queue head. Sends during a pending interruption still go to the
tail, so a burst keeps its order. On requires_action chats and errored
chats with a queue, an interrupt send now inserts the message into
history ahead of the queue.
@ethanndickson

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 97a2086d32

ℹ️ 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".

Comment thread coderd/x/chatd/chatstate/transition.go Resolved
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 14, 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-10-14T02:57:30.633683Z d643f3e Draft marked ready
ℹ️ 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

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ddbf01843a

ℹ️ 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".

Comment thread coderd/x/chatd/chatstate/transitions.go Resolved
…ends

The hooks pre-check rejected interrupt sends to E1 and A* chats with a full queue, although those sends go straight into history. chatstate now owns one routing rule and one capacity check, CheckSendMessageQueueCapacity, which the hooks pre-check and Tx.SendMessage both call.
@ethanndickson

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d643f3ed44

ℹ️ 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".

Comment thread coderd/x/chatd/chatstate/transitions.go Resolved
@ethanndickson

Copy link
Copy Markdown
Member Author

@codex review

re: Allow immediate unowned interrupts when the queue is full

This was already the case before this PR, so I'm leaving it out of scope here. On main, sendMessageInterrupt called insertQueuedMessage, which ran requireQueueCapacity before finishUnownedInterruption could promote the row. The hooks pre-check rejected the send too. So main also returns 429 for an interrupt to an unowned R1 chat at a full queue. This PR only changes where an interrupt that succeeds goes in the queue. Unowned I1 interrupts and E1 queue sends have the same gap, because they also add one row and promote one row. If we change the capacity rule, it should cover all of them in a separate PR.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Already looking forward to the next diff.

Reviewed commit: d643f3ed44

ℹ️ 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 marked this pull request as ready for review October 14, 2026 02:55
@pr-queue-manager
pr-queue-manager Bot requested a review from f0ssel October 14, 2026 02:56
@ethanndickson
ethanndickson merged commit 60c6c09 into main Oct 14, 2026
35 checks passed
@ethanndickson
ethanndickson deleted the ethanndickson/chat-interrupt-send-first branch October 14, 2026 03:00
@github-actions github-actions Bot locked and limited conversation to collaborators Oct 14, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants