Skip to content

feat: let web UI chats ask questions without ending the turn - #31310

Open
ibetitsmike wants to merge 6 commits into
mainfrom
mike/codagt-1460-chatd-async-ask
Open

ibetitsmike wants to merge 6 commits into
mainfrom
mike/codagt-1460-chatd-async-ask

Conversation

@ibetitsmike

@ibetitsmike ibetitsmike commented Oct 26, 2026 •

Copy link
Copy Markdown
Collaborator

🤖 Xum opened this PR for Mike.

Stack

This stack lets the agent in Coder Agents web UI chats ask a question with ask_user_question without ending its turn. Chats created through the API and plan mode keep the blocking tool.

  1. feat: let web UI chats ask questions without ending the turn #31310 (this PR): chatd gives web UI chats an async ask_user_question whose options are one-line answers, and sends a web push.
  2. feat(site/src/pages/AgentsPage): show ask_user_question options as numbered one-line answers #31555: the question form shows options as numbered one-line answers that number keys pick, and keeps unsent answers per call.
  3. feat(site/src/pages/AgentsPage): show async question answers without their call line #31315: async answers show without their call line in the bubble, the queue, Copy, Edit and the prompt history.
  4. feat(site/src): answer async agent questions in the timeline while the agent works #31294: an async question card stays answerable while the agent works, and closes when a newer question replaces it.
  5. feat: pin the open async question above the chat input #31312: the open async question is pinned above the chat input, plus docs.

Refs CODAGT-1460

What changes (coderd/x/chatd)

Outside plan mode, ask_user_question is registered for root chats with client_type = ui, which only the web UI sends; the API default is api. 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 is Answer to ask_user_question call <id>:. An async result over 16 KiB, the smallest tool-result budget, fails validation, because truncation would cut the async marker.

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.Unmarshal ignores unknown keys, so a model that still sends description gets 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.md describes 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/... and go 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)

  • An API-level open-question state for other clients, such as the Slack bot.
  • Steering an answer into a running turn (CODAGT-1140).
  • A question push sent before the chat title is generated carries the placeholder title.

@linear-code

linear-code Bot commented Oct 26, 2026

Copy link
Copy Markdown

CODAGT-1460

@ibetitsmike
ibetitsmike added this pull request to stack #31311 October 26, 2026 23:49
@ibetitsmike ibetitsmike changed the title mike/codagt 1460 chatd async ask feat(coderd/x/chatd): let web UI chats ask questions without ending the turn Oct 26, 2026
@ibetitsmike
ibetitsmike removed this pull request from stack #31311 October 27, 2026 00:38
@ibetitsmike
ibetitsmike added this pull request to stack #31316 October 27, 2026 00:38
@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

Xum posted this comment for Mike.

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 27, 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-30T23:21:14.586128Z 1dc6bce 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: 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".

Comment thread coderd/x/chatd/turn_environment.go Resolved
Comment thread coderd/x/chatd/generation.go Resolved
@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

Xum posted this comment for Mike.

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

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

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

@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

Xum posted this comment for Mike.

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep them coming!

Reviewed commit: 61ca1cc8a2

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

@ibetitsmike
ibetitsmike force-pushed the mike/codagt-1460-chatd-async-ask branch from 905fb04 to f7d3973 Compare October 30, 2026 21:20
@ibetitsmike ibetitsmike changed the title feat(coderd/x/chatd): let web UI chats ask questions without ending the turn feat: let web UI chats ask questions without ending the turn Oct 30, 2026
@ibetitsmike
ibetitsmike removed this pull request from stack #31316 October 30, 2026 21:22
@ibetitsmike
ibetitsmike added this pull request to stack #31597 October 30, 2026 21:23
@ibetitsmike
ibetitsmike marked this pull request as ready for review October 30, 2026 22:22

@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: 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".

@ibetitsmike
ibetitsmike requested a review from a team as a code owner October 30, 2026 23:16
@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. You're on a roll.

Reviewed commit: 1dc6bce85d

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

@coderagents coderagents Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Documentation check review of PR #31310 (head 1dc6bce).

Comment thread docs/ai-coder/agents/architecture.md Resolved
Comment thread docs/coder-agents/architecture.md Resolved
Comment thread docs/coder-agents/architecture.md Resolved
Comment thread docs/ai-coder/agents/architecture.md Resolved
@coderagents

coderagents Bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

Documentation Check

Blocking

  • docs/coder-agents/index.md (open) - The table row no longer says ask_user_question is plan-mode-only; it now reads "in plan mode, or outside plan mode without stopping work in chats created from the Coder dashboard." Fixed in 9e7a2487eb.
  • docs/coder-agents/index.md (open) - The plan-mode claim is split correctly: propose_plan is plan-mode-only, and ask_user_question is also plan-mode-only for API chats. Fixed in 9e7a2487eb.
  • docs/coder-agents/architecture.md (open) - The passive "is also exposed" was changed to "Coder also exposes" (active voice). Fixed in 9e7a2487eb.

Suggestions this round (non-blocking), as inline comments:

  • docs/coder-agents/architecture.md - The grouped sentence at line 157 could briefly imply ask_user_question is plan-mode-only before the dashboard case is explained; consider splitting it.
  • docs/coder-agents/architecture.md - The web push claim at line 167 reads as a guaranteed delivery but is config-dependent; consider qualifying it.

Design notes

  • The ask_user_question behavior now differs by client type (plan mode stops the turn, dashboard chats are async, API chats are plan-mode-only), and the docs describe each case accurately.
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: true

Automated review via Coder Agents. Reply to a finding's thread with the reason if the finding is wrong.

@mafredri
mafredri force-pushed the mike/codagt-1460-chatd-async-ask branch from 1dc6bce to 8addf7d Compare November 3, 2026 20:24
ibetitsmike and others added 5 commits November 6, 2026 19:08
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
… 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.
@mafredri
mafredri force-pushed the mike/codagt-1460-chatd-async-ask branch from 8addf7d to 563300c Compare November 6, 2026 19:25
…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.
@ibetitsmike
ibetitsmike temporarily deployed to main November 7, 2026 13:37 — with GitHub Actions Inactive

@coderagents coderagents Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Documentation check review of PR #31310 (head 9e7a248).

| `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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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).

Suggested change
`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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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).

Suggested change
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 ethanndickson left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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 submitChatTurn with no busy_behavior (handleSendAskUserQuestionResponse in AgentChatPage.tsx), and on main an empty busy_behavior now means steer. 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.md conflicts). The frontend PRs conflict with the steer queue code in chatQueueReconciliation.ts and chatStore.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 ethanndickson left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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 status already 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, question and 2 to 4 options, and the handler rejects any other count.
  • The label description 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

This branch was previously deployed

1 inactive deployment
main — 9e7a2487 Deployed Nov 7, 2026 by ibetitsmike via cla #252096
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants