Collapse query tool results by default#239
Merged
Merged
Conversation
The query tool result card currently starts expanded, which means the user sees the SQL query and result table inline in the chat. The LLM then typically reproduces that same table in its follow-up response, creating redundancy. The LLM's markdown table is often better formatted and more focused than the raw tool result, so the tool card ends up being visual clutter rather than adding value. This changes the default so only the visualize tool starts expanded (where the chart IS the content). All other tools — query, update, and reset — now start collapsed. Users can still expand the card to see the SQL and raw results whenever they want, and the QUERYCHAT_TOOL_DETAILS env var / R option still overrides the default. Additionally: - Adds a `collapsed` parameter to the R query tool (Python already had this), allowing the LLM to explicitly control the expand state per-call — e.g., setting collapsed=false when a result table is the primary answer. - Updates system prompts and tool descriptions in both languages to reflect that the LLM should not assume the user has seen the raw tool result, and should present key findings in its response text. - Refines the "Use Markdown tables" guideline: reproduce the full table for simple results, show only the most relevant subset for complex ones.
…efault # Conflicts: # pkg-r/NEWS.md # pkg-r/R/querychat_tools.R # pkg-r/inst/prompts/prompt.md # pkg-r/inst/prompts/tool-query.md
gadenbuie
approved these changes
May 28, 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.
Summary
When the
querytool runs, the result card (SQL + table) starts expanded in the chat. The LLM then typically replays the same data in its follow-up response — in a markdown table or prose summary. This creates redundant, cluttered output: two copies of the same information, with the less useful one taking up prime visual space.This PR changes the default so
querytool result cards start collapsed (except for the visualize tool, where the chart is the primary content). Users can still click to expand and see the SQL query and raw results whenever they want.Note
The Python package already has the
collapsedparameter on the query tool and the visualize tool (via ggsql support). The R package does not yet have ggsql/visualize support — that work is in draft at #224. This PR should stay in draft until #224 is merged, since the Rcollapsedparameter and the "only visualize starts expanded" default depend on that context to be fully useful.Related #147
What changed
visualizestarts expanded. Query, update/filter, and reset all start collapsed. TheQUERYCHAT_TOOL_DETAILSenv var / R option override still works as before.collapsedparameter: Python already had this — the LLM can explicitly setcollapsed=falseon a per-call basis when the result table is the primary answer and should be immediately visible.Test plan
QUERYCHAT_TOOL_DETAILS=expandedoverrides back to expanded