Repository navigation
fix(core): retain ask_user question text in the tool result display - #29677
elberthc-byte wants to merge 2 commits into
Conversation
Once the AskUser dialog closes, the CLI hides the tool description for
completed Ask User calls, so the result display becomes the only record
of the interaction. It previously contained only the short header chip
and the answer (e.g. "Retry Subagent → Yes"), losing the question (and
any explanation it carried) from the chat history and from resumed
sessions.
Include the full question text, prefixed by its header, with the answer
nested beneath it:
**User answered:**
Retry Subagent: The build timed out. Would you like to retry it?
→ Yes
llmContent and telemetry data are unchanged.
Fixes google-gemini#29021
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request improves the usability of the Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
|
📊 PR Size: size/M
|
🛑 Action Required: Evaluation ApprovalSteering changes have been detected in this PR. To prevent regressions, a maintainer must approve the evaluation run before this PR can be merged. Maintainers:
Once approved, the evaluation results will be posted here automatically. |
There was a problem hiding this comment.
Code Review
This pull request updates the AskUserTool to retain and format the full question text along with its answer in the returnDisplay output, ensuring context is preserved after the dialog closes. It also adds comprehensive unit tests to verify various formatting scenarios, including multi-line questions and answers. Feedback on these changes suggests improving robustness by safely handling cases where question.header is missing or whitespace-only, and defensively handling potentially null or undefined answer values to prevent runtime crashes.
Address review feedback: fall back to the positional label when the header is whitespace-only (the previous `??` fallback never caught empty strings), degrade to just the label when the question text is missing, and guard the answer before splitting it into lines.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request updates the AskUserTool to retain the full question text in the returnDisplay output after a user answers, ensuring the context of the question is preserved even after the UI dialog closes. It also improves formatting for multi-line questions and answers, adds fallback handling for orphaned answers or empty headers, and introduces comprehensive unit tests to verify these formatting behaviors and prevent regressions. There are no review comments, and I have no feedback to provide.
Summary
After answering an
ask_userdialog, the completed tool block in the chathistory showed only the short header chip and the answer
(e.g.
Retry Subagent → Yes). The question itself — which foryesnopromptsoften carries the entire explanation — disappeared, leaving the human with no
context for the recorded decision, both in the live session and after
/resume.This PR keeps the full question text in the Ask User result display, with the
answer nested beneath it.
Before
After
Details
Root cause — two independent decisions combine to drop the information:
ToolInfo(packages/cli/src/ui/components/messages/ToolShared.tsx)deliberately hides the tool description (
Asking user: …) once an Ask Usercall reaches a terminal status, on the assumption that "the result display
speaks for itself" (feat: wire up
AskUserToolwith dialog #17411).AskUserInvocation.execute()(packages/core/src/tools/ask-user.ts) builtreturnDisplayfrom onlyquestion.header(a ≤16-char chip label) plus theanswer;
question.questionwas never emitted.Once the modal closes, no rendered surface contains the question text.
Fix — a formatting-only change in
AskUserInvocation.execute():<header>: <question>followed by→ <answer>. Multi-line questions/answers keep their continuation linesaligned, and multiple questions are unambiguously paired with their answers.
(
Q<index>) is preserved.llmContent(what the model receives) and the telemetrydatapayload areunchanged, so there is no impact on model behaviour or metrics.
/resumerebuilds tool blocks from the persistedresultDisplay,resumed sessions retain the question as well.
Design decision — this intentionally does not add a settings toggle
(unlike the earlier attempt in #29022, which touched 10 files to plumb a
ui.keepAskUserQuestionsInHistoryflag throughConfig). There is no scenarioin which hiding the question benefits the person reading the scrollback, and the
cost is one extra line per answered question. Default-on keeps the change
surgical and avoids settings-schema/docs churn.
The lines are rendered through the existing Markdown path; the leading spaces and
→prefix are plain text (not list markers), verified by rendering throughToolGroupMessagewith Ink.Related Issues
Fixes #29021
Related to #29022 (previous attempt, closed as stale)
How to Validate
Unit tests (includes a regression test mirroring the reporter's scenario,
plus coverage for multi-question pairing, multi-line answers, multi-line
questions, and the positional fallback):
npm test -w @google/gemini-cli-core -- src/tools/ask-user.test.tsExpected: 35 tests pass. On
main, the regression testshould retain the question text in returnDisplay after answering (#29021)fails with
expected '**User answered:**\n Retry Subagent …' to contain 'The subagent failed because the build…'.Manual check:
npm run build && npm startPrompt:
Use the ask_user tool to ask me a yes/no question whose text explains that a build timed out and asks whether to retry.Answer thedialog. The completed Ask User block should now show
Retry: <full question text>followed by→ Yes. Run/resumeon thesession afterwards and confirm the question is still visible.
Edge cases covered by tests: multiple questions (each paired with its answer,
in order), multi-line text answers (continuation lines aligned under the
answer), multi-line questions (continuation lines indented), and an answer
whose index has no matching question (
Q<index>fallback).Local CI parity:
npm run preflight(clean, install, format, build, alllinters, typecheck,
test:ci) passes.Pre-Merge Checklist
docs/tools/ask-user.mddocuments parameters andllmContent, neither ofwhich changed.