Repository navigation
feat(tools)!: ask_user question hold, Interactive effect class, protocol 21 (T8) - #49
Merged
Merged
Conversation
…; Interactive effect class; protocol 21 (T8) The model gains a cheaper move than guessing when a request is ambiguous: `ask_user` carries 1-4 questions with 2-6 options each or free text, and the run holds until the human answers. Nothing dispatches: the call is classified `Interactive`, held like an approval (register before publish, same timeout), and settled `completed` with the rendered questions and answers as its result when the client sends `ApprovalDecision::Answer`. Every approval mode holds it — a question is never dangerous — and the reviewer is not consulted. Malformed arguments never hold; they reach dispatch only to return the contract error naming the failing bound. Protocol 21 (breaking for strict peers): `question: Option<Box< QuestionPreview>>` on `tool_approval_requested`, the `answer` decision, the `answered` resolution, `HeadlessStatus::NeedsInput` (exit 5), and T12's `InputPart::WorkspaceFile.range` folded into the same bump. `v20` goldens are retained decode-only; `v21` goldens add the question hold, the answer command, and a headless `needs_input` stream. `SessionEvent` stays within its 336-byte bound: the preview is boxed. `qq run` has no human: it cancels at the first question and exits `needs_input` with the question in the outcome message, so a supervisor can resume with the answer instead of the run stalling to the approval timeout or the model guessing. A spawned child's question is declined on the spot. Direct runs without a session gate answer "no user is available". TUI: the inline approval block becomes a question block for `ask_user` — numbered options, digits pick, the composer takes free text, Esc declines; answers accumulate across questions and send together. Prompt v12 tells the model to ask once, offer concrete options, and never ask what a tool could find out. Verification: 1439 workspace tests (12 new: bounds/rendering, every-mode policy, four session round trips incl. decline + idempotent replay + timeout, TUI keys and render, headless exit); fmt, clippy -D warnings, wasm qq-client, minimal qq-provider profile. `tool_dispatch` A/B after the H22.2 rebase: 42.3 → 42.5 µs median (noise). ADR-0021 written (shared with T9's `Network`).
This was referenced Sep 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes ENG-779. Tool-layer slice T8 (
docs/plans/tool-layer.md§ D7, § New effect classes). Stacked onmain@c7fd5c4(after H22.2).What changed
ask_user— the model can put 1–4 structured questions to the human (2–6 options each, or free text) and wait for the answers, instead of guessing or ending its turn with a question in prose.Interactive(newEffectClass); the session gate holds it exactly like an approval — register the waiter, persistawaiting_approval, publishtool_approval_requestedwith the parsedquestion— and every approval mode holds it (a question is never dangerous;read-onlymay still consult its user). The reviewer is not consulted.ApprovalDecision::Answer { answers }(one string per question) settles the callcompletedin the sameRespondToolApprovaltransaction, with the rendered Q/A asresult, resolutionanswered. An empty answer set declines with a fixed "proceed on your judgement" result. Timeout →denied_timeoutas today. Second answer → idempotent replay.question 1 needs 2-6 options…).prompt → answer.y/a/w/nare not live while a question is pending.qq runhas no human, so it cancels at the first question and exitsneeds_input(5) with the question inoutcome.message; the stream already carries thetool_approval_requestedevent for a supervisor to resume with. A spawned child's question is declined so the child proceeds. Direct gate-less runs answer "no user is available".Protocol 21 (
!)Additive fields, but strict peers reject the new tags, so the version moves:
question: Option<Box<QuestionPreview>>ontool_approval_requested(boxed:SessionEventstays ≤ 336 B — the H22.2 size test caught the unboxed version)ApprovalDecision::Answer,ApprovalResolution::Answered, capabilitiesapprovalsadvertisesanswerHeadlessStatus::NeedsInput= exit 5 (exit table pinned by test +headless-contract.md)InputPart::WorkspaceFile.rangefolded into this bump (as flagged in feat(tui): @ mentions attach workspace files client-side with ranges, dirs, globs, @diff/@sha, and completion (T12) #45)v21goldens:event_tool_approval_requested_question,command_respond_tool_approval_answer, headlessneeds_input.jsonl;v20retained decode-only. Harbor trace fixtures bumped.Design decisions
GateDecision::Answered { result }and the run loop records it as aRetainedResultwithout dispatch;RuntimeEvent::ToolCallAnsweredmirrorsToolCallDenied(session layer already persisted/published).ToolClass::Interactive { question: Option<QuestionPreview> }— classification parses once;evaluatereturnsPolicyDecision::AskUserforSome,Execute(→ contract error at dispatch) forNone.Interactive(shipped) andNetwork(T9 amends).Verification
askbounds/defaults/indexed errors/rendering + clipping; policy every-mode hold + malformed + grants irrelevant; 4 session round trips (read-only hold → exact result text in the next provider request with no start/finish events; decline + idempotent replay; timeout; malformed → error, no hold); TUI keys; TUI render; headlessneeds_inputend-to-end.cargo fmt --check,clippy --all-targets --all-features -D warnings, wasmqq-client, minimalqq-providerprofile.Measurements
tool_dispatchread_tool_loop, pinned core, 5 interleaved pairs after the rebase: base 42.3 → cand 42.5 µs median (noise). Before rebasing I saw a consistent +4 µs; bisected to H22.2 having landed onmainbetween the two builds, not this slice (plan_compile22.4 → 23.4 µs is the 8th declaration's share of catalog/prefix compile — same order as T2/T7). Evidencetarget/qq-perf/t8-2026-09-15/(untracked).Docs
tools.md§ Built-In Tools, new § Asking The User, § Approval Policy decision table ·protocol.mdv21 note, decision/resolution tables,questionpreview ·headless-contract.mdexit table + approval semantics ·adr/0021-interactive-and-network-effect-classes.md· ledger T12 → Shipped, T8 → In review + receipt.Follow-ups (recorded in ledger)
--answer/resume-with-answer relay; T13 measures how often models ask.ToolCallDisplayfor answered calls if the transcript wants a form, not text.