Repository navigation
feat(platform): add clarifying questions to chat and automation runs - #2961
Israeltheminer wants to merge 5 commits into
Conversation
d2a5303 to
eb4b744
Compare
One question shape and one component for every lane that asks a person something mid-turn, so the chat composer and the automation-run card cannot drift apart. The format this replaces had ten field types and a tool description saying, in capitals, never to present choices as plain text. Models wrote `textarea` for every field anyway, and what reached the user was a form: four blank boxes with the examples buried in a subtitle. So the shape enforces it instead: `options` is required and there is no free-text question type at all. `Other…` is injected by the client, which also keeps it localised. Sets cap at four questions and four options each. One-question-at-a-time lifts completion, but the gain lives at five-to-ten fields and stepping fewer costs more than it returns — so a single question renders with no progress chrome. Picking an option advances, and the panel says so beforehand (WCAG 3.2.2) with Back always available. Nothing is focus-trapped or `aria-modal`. Display strings clamp to their bounds rather than rejecting the whole set; the structural rules still reject, because those change what a question means. Both caps are pinned to literals, since a test that derives its fixture from the constant moves with it and cannot catch a changed bound.
Chat had no way to ask a clarifying question at all. The AI-backend rewrite drew a real boundary — chat retrieves, tasks produce deliverables — but took "chat does not DO things" to mean "chat does not ASK things", so a vague request produced a confident guess. The seams for the answer were left standing and unused, and the manual test plan still specified behaviour nothing could produce. `ask_question` is the fourth tool in the loadout. It reaches nothing and returns no data: it PAUSES the turn. The release notes for v0.2.91 record the previous gate being auto-retried straight past into acting on a guess, so the loop breaks on a valid call, while a rejected one comes back as a correctable error the model can fix rather than stranding the thread. The wire schema takes its bounds from the shared Zod schema and a test asserts they agree, so a rejected call is always a model mistake and never a contract mismatch. A pending question lives on an `approvals` row, but its LIFETIME is derived rather than recorded: it is outstanding only while the conversation has not moved past it, and "the person said something since" is already in the messages table. Nothing the reader sees depends on a bookkeeping write landing. The answer becomes the person's next message, so the thread reads as the conversation it is — no hidden system message, no second resume path. Access is gated the way this lane gates every other thread read. The pre-rewrite `canAccessThread` helper reads a table the rewritten chat never writes, so it does not restrict access — it denies all of it, and the query answers "nothing pending" however correct the row is.
The shape this replaces sat inline in the transcript, so the reader had to scroll back to find it. The panel takes the composer's own frame instead — same width cap, border and shadow — because for as long as it is up, it IS the input area. It never traps. Esc collapses it to a one-line bar over a usable composer; Skip retires it outright; and simply saying something else retires it too, which is the only reason "Type instead" existed and why it is not here. A question the person has settled leaves the screen immediately, whether or not the write closing its row has landed. Deriving the panel from the live query alone left the bar sitting above the reply to the very answers that were supposed to clear it. Closing the row is bookkeeping; sending is the conversation. They were ordered so the write was awaited first, which meant any failure discarded every answer the person had just given, under a message telling them to try again. The write is best-effort now and the send happens either way.
`ask_human` gave the operator one open box whatever it asked. It can now
carry the same question set chat uses, and the card renders the same shared
flow — one question at a time, options first.
Choices stay OPTIONAL here, unlike chat. A run's blocker is often genuinely
open ("what is the staging URL?"), and forcing four invented options onto
that is worse than one honest box. A malformed set is refused rather than
silently dropped, so the agent learns the shape instead of wondering where
its options went.
The field is additive and optional, so existing asks carry none and render
exactly the card that ships today; the schema gate classifies the change as
data-safe and requires no migration.
Folding two asks into one drops back to plain text: half-merging two option
sets would produce a set neither agent asked for, and the joined question
still carries everything.
The card omits the two affordances that only make sense in chat — there is
no composer on this lane to hand back to, and nothing to collapse to, since
the card is the surface.
A paused turn was drawn as three things at once. The tool call became a generic "Asking question" step; the `human-input` part became a bordered card repeating the question and the answers; and the turn's own emptiness was reported as a failure. A tool whose purpose is to put something in front of the person is drawn AS that thing, never as a step announcing it happened — steps are for invisible work like a search, where the step is the only evidence any of it occurred. The exclusion derives from `isPausingChatTool`, which already means exactly that, so there is no second list to drift. What remains is one row, in the same format as the searches above it. It is history: while the question is outstanding the composer is already showing it, so the row appears once the question has ended, which is when it becomes the only remaining trace. Only a skip is labelled — "Answered" restated the message directly below it, but a skip can be followed by nothing at all. The strip had three row formats, so its left edge came out ragged and the header read as a different kind of thing from the rows under it. They are one component now, its disclosure slot holding a same-width spacer when there is nothing to open. The header also vanished on a 28-second turn that had run three tools: it read time-to-first-token, which a turn that writes nothing never stamps. It falls back to the duration it did measure, and pausing on a question created the first class of turns that produce no text at all. Two predicates also read a paused turn as broken — the timeline drew a warning triangle on a call that had worked, and the "response couldn't be completed" notice fired on a turn whose silence was the point.
eb4b744 to
8fe87df
Compare
|
Agreed — closing this. The repositioning is the deciding point: if chat is Q&A rather than an agent, then asking the user questions is out of scope regardless of how the asking is done, and holding the tool count hard is the only way that line survives contact with plausible-sounding additions. This was one of those. Two things from this branch are worth keeping separately, since neither is the chat tool:
The tester complaint that prompted this (answering 3–5 questions at once with no support) still applies to the automation-run lane, where |
Chat can ask a clarifying question again, and this time the shape stops it becoming a form.
Why
The AI-backend rewrite (#2857) drew a real boundary — chat retrieves, tasks produce deliverables — but it took "chat does not DO things" to mean "chat does not ASK things". The assistant lost every way to ask, so a vague request produced a confident guess. The seams for the answer were left standing and unused: a
human-inputmessage part, ahuman_input_requestapproval type with a thread index, awaiting-inputgeneration status, and a manual test plan (chat.mdF18) still specifying behaviour nothing could produce.The shape that shipped before the rewrite asked badly. Four required fields stacked at once, each a blank textarea with its examples buried in a subtitle, mounted inline in the transcript so the reader had to scroll back to find it and then compose four answers before anything happened.
That format already supported
single_selectwith options, and its tool description said, in capitals, never to present choices as plain text. Models wrotetextareafor every field anyway.What changed
Options are required; free text is the escape hatch. Ten field types collapse to one shape with no free-text question type at all, so the old failure mode is unrepresentable rather than discouraged.
Other…is injected by the client — always present, always localised, never model-authored.One question at a time. Sets cap at four and options at four per question. A single question renders with no progress chrome: one-at-a-time lifts completion, but the gain lives at five-to-ten fields and stepping fewer costs more than it returns.
It takes the input area, and never traps. The panel occupies the composer's own frame. Esc collapses it to a one-line bar over a usable composer; Skip retires it outright; and simply saying something else retires it too. Picking advances, and the panel says so first (WCAG 3.2.2), with Back always available.
The turn stops on a question.
ask_questionis the fourth chat tool and returns no data — it pauses. The release notes for v0.2.91 record the previous gate being auto-retried straight past into acting on a guess, so the loop breaks on a valid call while a rejected one comes back as a correctable error the model can fix.Both lanes share one schema and one component, so the chat composer and the automation-run card cannot drift. On the automation lane options stay optional: a run's blocker is often genuinely open ("what is the staging URL?"), and forcing four invented options onto that is worse than one honest box.
Notable decisions
messagestable. Nothing the reader sees depends on a bookkeeping write landing.Compatibility
No migration — the schema gate classifies the one new field (
automationHumanAsks.questions) as data-safe. Existing asks carry noquestionsand render exactly the card that ships today. Pre-rewritehuman_input_requestapproval rows do not parse as the new shape and are hidden rather than crashed on.Verification
lint --type-aware0 ·typecheck0 · server + pii 74,778 tests · ui 3,262 tests ·migrations:checkclean · SAST 0 findings.Behaviour is mutation-tested throughout — each guard was verified to fail when removed, after several passed against broken code.
Known flake, present on
maintoo:turbo run test test:uiconcurrently failstest:ui; both suites pass when run alone.