Skip to content

feat(coderd/x/chatd): deliver steer and interrupt messages before the next model call - #29784

Closed
ethanndickson wants to merge 3 commits into
ethanndickson/chat-steer-storefrom
ethanndickson/chat-steer-delivery
Closed

ethanndickson wants to merge 3 commits into
ethanndickson/chat-steer-storefrom
ethanndickson/chat-steer-delivery

Conversation

@ethanndickson

@ethanndickson ethanndickson commented Sep 23, 2026 •

Copy link
Copy Markdown
Member

Part of CODAGT-1140

This PR delivers steer and interrupt messages that are waiting in a busy chat's queue. Right before each assistant model call, chatd checks the queue, and if there's a steer or interrupt row in there, we promote everything from the head up to and including the last one. So with a queue of Q1 S1 Q2, the model sees Q1 S1 on its next call and Q2 waits for turn end. History order always matches send order, which is how "Send after step" works in mux.

A steer never cancels anything; it just waits for the in-flight call and that step's tool calls to finish. An interrupt still cancels the request, then waits for the same point.

The check lives in generateAssistant, where a new PromoteQueuedBeforeStep transition runs in the same transaction as RecordGenerationAttempt. SendMessage locks the same chat row, so a steer that commits before the call starts always makes it into that call. Compaction and tool execution don't promote, as neither of them answers the user.

Only Go callers can send steer for now. The next PR adds it to the API.

This does change existing behaviour in a few places, so I'd like sign-off from the chatd owners:

  1. An interrupt sent during requires_action now reaches the model straight after the cancelled tool results, instead of waiting for the next turn end.
  2. An interrupt behind queued rows now goes out with them on the first call after the interrupt, instead of waiting for its own turn.
  3. A queue row ahead of a steer or interrupt row now goes out with it, mid-turn.

The web UI doesn't send busy_behavior, so none of this affects it.

A few smaller things I've accepted: promoted rows reset the per-turn step count and can switch the model (promoted queue rows already do both), a Stop hook can nudge once more in the same turn, and a steer still waits for long tool calls like execute or wait_agent to finish. Returning early from those is a follow-up.

@ethanndickson

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 23, 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-09-25T06:53:33.586391Z 017ea0e 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.

@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: 1194531623

ℹ️ 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/generation.go Resolved
Comment thread coderd/x/chatd/chatstate/transition.go Resolved
@linear-code

linear-code Bot commented Sep 23, 2026

Copy link
Copy Markdown

CODAGT-1140

@ethanndickson
ethanndickson force-pushed the ethanndickson/chat-steer-delivery branch from 736e1c9 to 398168d Compare September 24, 2026 05:07
@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: dfaa2884dd

ℹ️ 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/chatd.go Resolved
@ethanndickson

Copy link
Copy Markdown
Member Author

@codex review

re: Expose steer through the public message API

Intended. This PR is layer 2 of a stack, and only Go callers get steer here. #29785 adds steer to codersdk.ChatBusyBehavior, to the Swagger enum, and to the conversion in exp_chats.go.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Delightful!

Reviewed commit: dfaa2884dd

ℹ️ 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 September 24, 2026 06:53

@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: dfaa2884dd

ℹ️ 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/generation.go Resolved
@ethanndickson

Copy link
Copy Markdown
Member Author

@codex review

re: Promote due rows before compaction model calls

Intended. Steer rows target the next assistant call, and compaction does not answer the user. Promoting before compaction would not change what the model sees: compaction keeps the trailing unanswered user rows out of the summary input and repeats them after the summary. Here, the first action after compaction is generate_assistant, and beginAssistantAttempt promotes the steer before that call. So the model gets "summary, then steer" either way, and history does not get a model-only copy of the steer.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🎉

Reviewed commit: dfaa2884dd

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

…pt starts

The generation loop read the queue when it chose its next action, before
it prepared the step. A steer row that arrived during preparation missed
the next model call.

The worker now promotes due rows in the same transaction that records
the model call attempt. SendMessage locks the same chat row, so a steer
or interrupt row that commits before the attempt starts reaches that
call.

PromoteQueuedBeforeStep now reads the queue before it checks for
outstanding tool calls, so a call with no due rows writes nothing.
@ethanndickson
ethanndickson force-pushed the ethanndickson/chat-steer-delivery branch from dfaa288 to 017ea0e Compare September 25, 2026 05:44
@ethanndickson

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Hooray!

Reviewed commit: 017ea0e041

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

Copy link
Copy Markdown
Member Author

Superseded by #30074.

After discussing CODAGT-1191, the design changed: steer becomes the default busy behaviour, interrupt is no longer a send option (interrupt, then send), and steer messages skip ahead of queued messages instead of pulling them into history early. That was enough change that I rebuilt the stack from main instead of rebasing this one.

@github-actions github-actions Bot locked and limited conversation to collaborators Sep 29, 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