Skip to content

feat(mcp): search_attributes query for specific attributes - #2209

Open
nikkikapadia wants to merge 17 commits into
mainfrom
nikki/search-attributes/find-specific-attr
Open

nikkikapadia wants to merge 17 commits into
mainfrom
nikki/search-attributes/find-specific-attr

Conversation

@nikkikapadia

@nikkikapadia nikkikapadia commented Nov 12, 2026 •

Copy link
Copy Markdown
Member

Building on top of what we currently have on the search_attributes tool; in addition to showing a list of all attributes, we now find attributes based on a user query. Users can define what attribute they're looking for and the tool will provide the best match and additional candidates.

To achieve this behaviour we pass the query to a couple of subagents. The first agent will look at the user's query and provide substring hints that we can pass to the attributes endpoint. This happens because the attributes endpoint will return a limited number of attributes; so the attribute we're looking for may not be there. It will generate between 3-5 hints, query the attributes endpoint with these substrings and then merge those results with our recommended attributes. NOTE: If it notices that the total number of attributes is less than the attribute endpoints limit, it assumes those are all the attributes and will not generate these hints. This list of attributes gets formatted and passed to the second subagent. That subagent scans through all the attributes and gets max 10 candidates that the user might be talking about.

At the end we format the results and send it back to the agent that called the tool with suggested presentation but ultimately how that agent presents the information is up to them.

Some file guidance:
agents.ts -> all of the subagent calls
config.ts -> the prompts that are put into the respective subagents
format.ts -> output formatting functions that format the results that get handed back to the caller agent
search.ts -> tooling decisions and returns to the caller agent

Closes EXP-1353

@vercel

vercel Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
sentry-local Ready Ready Preview Nov 13, 2026 8:53pm UTC

Request Review

@cursor cursor Bot 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.

Stale Bugbot comment from a previous run.

@sentry-junior sentry-junior Bot 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.

Nice shape overall: the fallbacks are well scoped, toAttributeMatches drops invented keys, and the cut-off/hint path has real tests. Two things before this goes to wider review:

  • Shortlist prompt size in large orgs. In search.ts, shortlistAttributesAgent gets every row: the base fetch plus all hint results. The endpoint returns up to explore.trace-items.keys.max + 1 keys per type (default 1000, across string/number/boolean, plus array behind a flag), so the orgs that trigger mayBeCutOff are the same ones that send roughly 3k+ attribute lines, with descriptions, in a single prompt on every query call. Those orgs are the main audience for this feature. Most of the base page is just the first ~1000 keys by name, so it's mostly noise once hints have run. datasetAttributes in search-events pages at 50 fields for this reason. Something like this would help: when the list was cut off, shortlist only the hint rows plus the recommended/convention keys from the base page, or put a hard cap on the lines sent. It would also help to log or measure the prompt token count on that path.
  • No model-in-the-loop coverage. Both prompts in config.ts are what the feature depends on, but the unit tests mock both agents, and nothing in mcp-server-evals runs search_attributes with a query. One or two evals would show that the hint and shortlist prompts work together. Use a cut-off-sized fixture where the right key only appears through a hint search (e.g. "payment provider" → checkout.payment_processor). That would cover the first point too.

@cursor cursor Bot 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.

Stale Bugbot comment from a previous run.

@nikkikapadia
nikkikapadia marked this pull request as ready for review November 12, 2026 20:56
@github-actions github-actions Bot added the risk: medium PR risk score: medium label Nov 12, 2026
@linear-code

linear-code Bot commented Nov 12, 2026

Copy link
Copy Markdown

EXP-1353

@cursor cursor Bot 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.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Want fixes drafted automatically? Bugbot Autofix can create code changes for findings. A team admin can enable Autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 1cc7198. Configure here.

recommendedKeys.has(attribute.key),
);
rows = mergeByKey([recommendedRows, ...hintRows]);
narrowedByHints = true;

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.

Recommended keys dropped past cutoff

Medium Severity

When the attributes page looks cut off, recommended keys are taken only from that truncated first fetch. Common fields that sort after the cap never enter the hint-narrowed set, even though the fallback copy still says Sentry's common search fields are included.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 1cc7198. Configure here.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

this is fine imo because it's just the recommended keys and not the attributes queried from the hint keys.

@nikkikapadia
nikkikapadia added this pull request to stack #2245 November 13, 2026 17:02

@lzhao-sentry lzhao-sentry left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lgtm, i left two minor comments

* Map the agent's keys back to fetched attributes. Drops keys that weren't
* fetched (invented or altered by the model) and repeats, then applies the limit.
*/
export function toAttributeMatches(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Minor thing: I noticed when querying for attributes i.e., "HTTP status code" the call usually returns the deprecated http.status_code as the best match. I don't think it's an issue because we get the alternative key to use as well, but maybe one thing to look into is to best match non deprecated attributes over deprecated ones?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

hrmm good point! this could probably be fixed in the way we ask the agent to display things. I'll take a look at either the subagent prompt or the return formatting.

// The endpoint sorts keys by name and stops at about 1000 per type, so in a
// large org the right key can be past the cut. A substring search looks
// through every key, so search again with hints made from the query.
if (mayBeCutOff(rows)) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think this might be more of the API endpoint is weird, but in small orgs, when I search for "span duration" it doesn't successfully get span.duration. I think it's because built in attributes can be cut off for for some unholy reason?

I don't think it's a blocker for this PR, but we should file an ticket to investigate it

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

def weird. The way it works rn is that we match the built in fields to what comes back in the endpoint. Seems like span.duration isn't being sent in any of their spans then. It is kind of weird behaviour tho. Maybe we can look at putting in these recommended attributes regardless in the near future?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

ah actually, might be because i didnt send any test data recently to my test org so it was outside the period 😭, lemme check on that does have it to see if its an issue

This branch was successfully deployed

2 active deployments
Preview — 5f4de26e Deployed Nov 13, 2026 by vercel[bot]
Actions — 5f4de26e Deployed Nov 13, 2026 by nikkikapadia via eval #1875
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: medium PR risk score: medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants