Repository navigation
feat: let web UI chats ask questions without ending the turn - #31310
ibetitsmike wants to merge 6 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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6b48421c38
ℹ️ 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. Delightful! 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". |
@codex review |
|
Codex Review: Didn't find any major issues. Keep them coming! 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". |
905fb04 to
f7d3973
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f7d3973a2f
ℹ️ 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. You're on a roll. 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". |
Documentation CheckBlocking
Suggestions this round (non-blocking), as inline comments:
Design notes
Findings for agents- id: learner-1
persona: learner
class: suggestion
blocking: false
file: docs/coder-agents/architecture.md
line: 157
quote: "`propose_plan` and `ask_user_question` are exposed while plan mode is active."
evidence:
- docs/coder-agents/architecture.md:163-168
- coderd/x/chatd/turn_environment.go:724-728
rule: null
problem: A reader can briefly conclude ask_user_question is plan-mode-only from this grouped sentence, corrected only eight lines later.
fix: "`propose_plan` is exposed only while plan mode is active. `ask_user_question` is exposed in plan mode, and also outside plan mode in chats created from the Coder dashboard."
verified: true
- id: learner-2
persona: learner
class: suggestion
blocking: false
file: docs/coder-agents/architecture.md
line: 167
quote: "Coder also sends the chat owner a web push notification when such a question opens."
evidence:
- coderd/x/chatd/turn_environment.go:1224-1225
- coderd/x/chatd/chatd.go:2682
rule: null
problem: The unqualified claim overstates a guaranteed delivery when web push is not configured.
fix: "When web push notifications are enabled, Coder also sends the chat owner a push notification when such a question opens."
verified: trueAutomated review via Coder Agents. Reply to a finding's thread with the reason if the finding is wrong. |
1dc6bce to
8addf7d
Compare
Outside plan mode, root chats created from the web UI get an async ask_user_question. The call returns at once with an "async" marker, the agent keeps working, and the answer arrives later as a user message whose first line names the call. The chat owner gets one web push per question, sent only after the step that holds the result commits. Options now carry only a label: the schema asks for one short, complete answer and drops the description field. Plan mode and chats created through the API keep the blocking tool. Refs CODAGT-1460
…label-only question options without a placeholder
…label-only question options with a story
… sees The paragraph said the answer names the tool call, which only holds once the web UI adds the call line later in the stack, and it described the tool's call mechanics instead of what happens in the chat.
…raph This page's tools table and the paragraph above name each tool, so the paragraph about ask_user_question names it too. The only wrong claim was that the answer names the tool call, which the web UI does not do until later in the stack.
8addf7d to
563300c
Compare
…an mode This PR exposes ask_user_question outside plan mode in dashboard chats, so the tools table and the plan mode note no longer call it plan-mode-only. The architecture page names Coder as the actor.
| | `ask_user_question` | Asks the user structured clarification questions. | | ||
|
|
||
| `propose_plan` and `ask_user_question` are only exposed while plan mode is active. | ||
| `propose_plan` and `ask_user_question` are exposed while plan mode is active. |
There was a problem hiding this comment.
This grouped sentence states that propose_plan and ask_user_question are exposed while plan mode is active, but the next paragraph (163-168) makes clear ask_user_question is also exposed outside plan mode for dashboard chats. A reader who reads the tools column and this sentence first can briefly conclude ask_user_question is plan-mode-only, and is only corrected eight lines later. Since the two tools no longer share the same availability, consider splitting the sentence so the dashboard case is clear at first mention (Newcomer).
| `propose_plan` and `ask_user_question` are exposed while plan mode is active. | |
| `propose_plan` is exposed only while plan mode is active. `ask_user_question` is exposed in plan mode, and also outside plan mode in chats created from the Coder dashboard. |
| In chats created from the Coder dashboard, Coder also exposes `ask_user_question` outside plan mode. | ||
| There it returns at once, and the agent keeps working. | ||
| The answer arrives later as a user message. | ||
| Coder also sends the chat owner a web push notification when such a question opens. |
There was a problem hiding this comment.
This states the chat owner gets a web push notification as a certainty, but delivery is best-effort and config-dependent: dispatchQuestionPush returns immediately when web push is not configured, and delivery runs in the background. A reader who configures no web push (or has no push subscription) gets no notification and has no way to know why. Consider qualifying it (Newcomer).
| Coder also sends the chat owner a web push notification when such a question opens. | |
| When web push notifications are enabled, Coder also sends the chat owner a push notification when such a question opens. |
ethanndickson
left a comment
There was a problem hiding this comment.
Approving. The chatd side and the overall direction look good to me.
⚠️ Must resolve before this stack merges: steer is now the default on main
This stack is based on e746555 (6 Nov). I merged the steer stack (CODAGT-1140) on 9 Nov, after this stack was cut, and it made steer the default busy_behavior for chat messages. So this one's on me.
What that changes for this stack:
- The question card sends its answer through
submitChatTurnwith nobusy_behavior(handleSendAskUserQuestionResponseinAgentChatPage.tsx), and on main an emptybusy_behaviornow meanssteer. After a rebase, an answer sent while the agent works reaches the model before its next model call in the same turn. It no longer waits for the turn to end. - The PR body says "while a turn runs, the answer is queued and starts the next turn", and lists steering an answer into a running turn (CODAGT-1140) as a follow-up outside this stack. Neither is true on main any more.
- The UAT covered the queue behaviour, not this one. The tool description and status text still read fine with steer, but nobody has exercised this flow yet.
- This PR's Go code merges cleanly with main (only
docs/coder-agents/index.mdconflicts). The frontend PRs conflict with the steer queue code inchatQueueReconciliation.tsandchatStore.ts, and #31294 changes the "Send now" path, which the steer stack redesigned.
Could we rebase the whole stack onto current main, update the PR body, and re-run the "answer while the agent works" UAT with steer before any of it merges? Steer should make this feature better, since an answer can now change the running turn instead of arriving after it.
Generated by an agent on behalf of the user
ethanndickson
left a comment
There was a problem hiding this comment.
A thought on the ask_user_question descriptions in chattool/askuserquestion.go. It is a direction to consider, not a required change.
The async description is 815 characters, and about half of it repeats text that the model already sees elsewhere:
- The result's
statusalready tells the model not to wait and to continue with other work, and it gives the answer prefix with the call ID. - The schema already requires
header,questionand 2 to 4options, and the handler rejects any other count. - The
labeldescription already says how to write an option.
Could the descriptions carry only what the model needs before it calls the tool, and leave the rest to the schema and the result? That is: what the tool does, when to use it, that the answer arrives later, and that a new question replaces an unanswered one. Guidance that matters only after the call, such as "if you cannot continue, end your turn", could live in the status text. The model reads it at the moment it decides whether to stop, and it costs tokens only in chats that call the tool. The last two sentences of the plan mode description repeat the schema in the same way.
For scale, Codex's async equivalent (request_user_input_async) is about 560 characters, and its blocking request_user_input is about 120. A rough cut along these lines puts the async description near 320 characters.
If the option guidance is repeated because models ignored the label description without it, that is a good reason to keep it. Nobody has run an eval on either wording, so this is about less repetition, not a proven improvement.
Generated by an agent on behalf of the user
Stack
This stack lets the agent in Coder Agents web UI chats ask a question with
ask_user_questionwithout ending its turn. Chats created through the API and plan mode keep the blocking tool.ask_user_questionwhose options are one-line answers, and sends a web push.Refs CODAGT-1460
What changes (
coderd/x/chatd)Outside plan mode,
ask_user_questionis registered for root chats withclient_type = ui, which only the web UI sends; the API default isapi. In that mode the tool is async: it has its own description, it is not a stop tool, and it returns{"questions", "async": true, "status"}at once. The status tells the model to keep going and that the answer arrives later as a user message whose first line isAnswer to ask_user_question call <id>:. An async result over 16 KiB, the smallest tool-result budget, fails validation, because truncation would cut theasyncmarker.An async question sends one web push (
Question: <first question>, truncated to 200 runes) to the chat owner. The push goes out only after the step that holds the tool result commits, so it never points at a question the UI cannot show yet. If that commit fails, or the step ends the turn in error, only the error push goes out. When one step asks more than once, only the last question is pushed.Options now carry only a
label, which the schema describes as the answer exactly as the user would send it. Both tool descriptions ask for one complete answer per option.json.Unmarshalignores unknown keys, so a model that still sendsdescriptiongets no error. The current question card renders a label-only option without the "No description provided." placeholder; #31555 replaces that card. Plan mode keeps its description, result shape and stop behavior for every client, and subagents still never get the tool.No new API fields, no migration, no busy-behavior change: while a turn runs, the answer is queued and starts the next turn.
architecture.mddescribes the async mode.Until #31294 lands, the web UI shows an async question as a normal question card that unlocks when the turn ends.
Validation
go test ./coderd/x/chatd/chattool/...andgo test ./coderd/x/chatd/pass. They cover the result shape and gating, the label-only schema, the stop-tool set, and integration tests where the turn continues and the push is sent, and where the result commit fails and only the error push is sent. Earlier remote dogfood UAT with a real model checked that API-created chats send the same tool list as main, that plan mode still ends the turn, and that each async question sends exactly one push.Known follow-ups (not in this stack)