Skip to content

feat: group lints in get_advisors response - #390

Merged
mattrossman merged 7 commits into
mainfrom
mattrossman/ai-1136-group-lints-in-get_advisors-to-reduce-response-bloat
Sep 1, 2026
Merged

mattrossman merged 7 commits into
mainfrom
mattrossman/ai-1136-group-lints-in-get_advisors-to-reduce-response-bloat

Conversation

@mattrossman

@mattrossman mattrossman commented Aug 28, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

get_advisors returns a list with one object per finding, each carrying the same keys. The lint SQL emits title, description and remediation as 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.

  • Findings only merge when all seven shared fields match
  • Merged findings appear as a findings list on the lints entry, with convenience count
  • Drops cache_key, which primarily exists for the dashboard UI

Before

{ "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_advisors for a project with some advisors, and observe the shape.

Screenshot from my testing in MCP Inspector:

CleanShot 2026-08-28 at 12 42 40@2x

Follow-ups

  • Even with the shrunken response, tool outputs are unbounded and can flood context. The worst recent call returned 10,649 findings, where even with grouping it's ~2.5x over Assistant's context limit. This exploration will continue in AI-865.
  • detail is only included per-finding because pg-meta puts index names, policy names, roles and actions in prose instead of metadata. If we fill those in, detail could be dropped entirely, making that same payload ~4x smaller

tools/list output is untouched so no ChatGPT resubmission needed.

Closes AI-1136

@mattrossman mattrossman changed the title feat: group lints in get_advisors response feat: group lints in get_advisors response Aug 28, 2026
@coveralls

coveralls commented Aug 28, 2026 •

Copy link
Copy Markdown

Coverage Report for CI Build 33521185464

Coverage increased (+0.07%) to 96.592%

Details

  • Coverage increased (+0.07%) from the base build.
  • Patch coverage: 52 of 52 lines across 1 file are fully covered (100%).
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 3087
Covered Lines: 3002
Line Coverage: 97.25%
Relevant Branches: 405
Covered Branches: 371
Branch Coverage: 91.6%
Branches in Coverage %: Yes
Coverage Strength: 50.52 hits per line

💛 - Coveralls

@mattrossman mattrossman added the publish-preview Runs `publish-preview` workflow to publish preview packages via https://pkg.pr.new/ label Aug 28, 2026
@pkg-pr-new

pkg-pr-new Bot commented Aug 28, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

pnpm add https://pkg.pr.new/@supabase/mcp-server-postgrest@619d66f
pnpm add https://pkg.pr.new/@supabase/mcp-server-supabase@619d66f
pnpm add https://pkg.pr.new/@supabase/mcp-utils@619d66f

commit: 619d66f

@mattrossman
mattrossman marked this pull request as ready for review August 28, 2026 17:04
@mattrossman
mattrossman requested a review from a team as a code owner August 28, 2026 17:04
@lokicik

lokicik commented Aug 29, 2026

Copy link
Copy Markdown

I tested this against Base 30baa1f and the current PR head 8e4b8bc.

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.

Model Base PR
DeepSeek V4 Flash 0/3 3/3
GPT-5.6 Luna 0/3 3/3
Qwen 3.5 Flash 0/3 3/3
MiMo v2.5 0/3 3/3

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.

@barryroodt barryroodt left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The payload reduction looks like a clear win. I’ve left two comments before approval: only group responses with the shape we expect, and cover grouping through the real get_advisors path.

Mapping missing fields and explicit nulls to the same sentinel let
unrelated lints collapse into one group.
Existing get_advisors tests only used empty lint lists, so removing
the groupAdvisorsResult call would still pass.
…roup-lints-in-get_advisors-to-reduce-response-bloat
@mattrossman
mattrossman merged commit 48d593a into main Sep 1, 2026
7 checks passed
@supabase-releaser supabase-releaser Bot mentioned this pull request Sep 1, 2026
barryroodt pushed a commit that referenced this pull request Sep 4, 2026
🤖 I have created a release *beep* *boop*
---


<details><summary>mcp-utils: 0.8.0</summary>

##
[0.8.0](mcp-utils-v0.7.0...mcp-utils-v0.8.0)
(2026-09-04)


### Features

* **mcp:** add project cost confirmation elicitation
([#391](#391))
([fb50882](fb50882))
* **mcp:** hide legacy cost tools from form-capable clients
([#411](#411))
([2f04461](2f04461))
</details>

<details><summary>mcp-server-supabase: 0.12.0</summary>

##
[0.12.0](mcp-server-supabase-v0.11.0...mcp-server-supabase-v0.12.0)
(2026-09-04)


### Features

* group lints in `get_advisors` response
([#390](#390))
([48d593a](48d593a))
* **mcp:** add branch cost confirmation elicitation
([#394](#394))
([867a160](867a160))
* **mcp:** add project cost confirmation elicitation
([#391](#391))
([fb50882](fb50882))
* **mcp:** hide legacy cost tools from form-capable clients
([#411](#411))
([2f04461](2f04461))


### Bug Fixes

* ensure correct escaping in advisor
([#407](#407))
([a6cf4a0](a6cf4a0))
* make server instructions intent-based instead of naming tools
([#372](#372))
([fc54ea2](fc54ea2))
</details>

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: supabase-releaser[bot] <223506987+supabase-releaser[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

publish-preview Runs `publish-preview` workflow to publish preview packages via https://pkg.pr.new/

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants