feat: group lints in get_advisors response - #390
Open
mattrossman wants to merge 4 commits into
Open
Conversation
get_advisors response
Coverage Report for CI Build 33192641335Coverage increased (+0.08%) to 96.595%Details
Uncovered ChangesNo uncovered changes found. Coverage RegressionsNo coverage regressions found. Coverage Stats
💛 - Coveralls |
…roup-lints-in-get_advisors-to-reduce-response-bloat
commit: |
mattrossman
marked this pull request as ready for review
August 28, 2026 17:04
|
I tested this against Base I used the same 301 advisor findings on both sides and asked the agent to fetch both security and performance advisors, then return every group with its count, severity, and a sample object. The Base response was about 178k characters, while the grouped PR response was about 41k.
On Base, none of the attempts managed to return the complete summary within the result budget. With this PR, all 12 did. The grouping helped a lot here. |
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.
Problem
get_advisorsreturns a list with one object per finding, each carrying the same keys. The lint SQL emitstitle,descriptionandremediationas literals on each row, so 300 instances of the same lint means those same three strings 300 times.See diagnosis thread with metrics demonstrating that is is the longest tail context hog in studio's AI Assistant.
Fix
Groups findings by lint.
findingslist on thelintsentry, with conveniencecountcache_key, which primarily exists for the dashboard UIBefore
{ "lints": [ { "name": "lint_a", "title": "…", "level": "WARN", "facing": "…", "categories": ["…"], "description": "…", "remediation": "…", "detail": "… object_1 …", "metadata": { "name": "object_1" }, "cache_key": "…" }, { "name": "lint_a", "title": "…", "level": "WARN", "facing": "…", "categories": ["…"], "description": "…", "remediation": "…", "detail": "… object_2 …", "metadata": { "name": "object_2" }, "cache_key": "…" }, { "name": "lint_a", "title": "…", "level": "WARN", "facing": "…", "categories": ["…"], "description": "…", "remediation": "…", "detail": "… object_3 …", "metadata": { "name": "object_3" }, "cache_key": "…" }, { "name": "lint_a", "title": "…", "level": "WARN", "facing": "…", "categories": ["…"], "description": "…", "remediation": "…", "detail": "… object_4 …", "metadata": { "name": "object_4" }, "cache_key": "…" }, { "name": "lint_a", "title": "…", "level": "WARN", "facing": "…", "categories": ["…"], "description": "…", "remediation": "…", "detail": "… object_5 …", "metadata": { "name": "object_5" }, "cache_key": "…" }, // ...296 more, each repeating the same 7 shared fields ]}After
{ "lints": [ { "name": "lint_a", "title": "…", "level": "WARN", "facing": "…", "categories": ["…"], "description": "…", "remediation": "…", "count": 301, "findings": [ { "detail": "… object_1 …", "metadata": { "name": "object_1" } }, { "detail": "… object_2 …", "metadata": { "name": "object_2" } }, { "detail": "… object_3 …", "metadata": { "name": "object_3" } }, { "detail": "… object_4 …", "metadata": { "name": "object_4" } }, { "detail": "… object_5 …", "metadata": { "name": "object_5" } }, // ...296 more ] } ]}In the turn cited above, the response shrinks to 293,485 chars, ~73k tokens.
How to review
Take a look at the new tests to understand the expecting grouping behavior.
Point an MCP client at the preview build below then call
get_advisorsfor a project with some advisors, and observe the shape.Screenshot from my testing in MCP Inspector:
Follow-ups
detailis only included per-finding becausepg-metaputs index names, policy names, roles and actions in prose instead ofmetadata. If we fill those in,detailcould be dropped entirely, making that same payload ~4x smallertools/listoutput is untouched so no ChatGPT resubmission needed.Closes AI-1136