Repository navigation
feat(search-events): correctly process attribute context in tests + deprecated attribute evals - #1440
nikkikapadia wants to merge 4 commits into
Conversation
…eprecated attribute evals
JoshuaKGoldberg
left a comment
There was a problem hiding this comment.
This generally looks good to me as a toolkit novice! I ran it through Claude and it produced a collection of reports that I narrowed down to a bunch of questions & nitpicks. So you shouldn't trust my review at all, this is just for me learning 😄
| 7. Use datasetAttributes substringMatch, query, and attributeTypes for targeted lookup when broad field discovery is truncated | ||
| 8. For non-replay datasets, call validateSearch after constructing the candidate request. If invalid, fix and validate again in this same pass | ||
| 9. NEVER replace a structured field:value filter with message/log.body/full-text matching. If an explicit field is unavailable on the dataset, keep it and let validation fail instead of inventing a weaker query | ||
| 10. If datasetAttributes lists a field under Deprecated Fields, use its replacement instead, even when the deprecated name appears in the guidance or examples in this prompt |
There was a problem hiding this comment.
[Question] Nothing in production passes context: true to fetchCustomAttributes. Is that something we handle separately?
There was a problem hiding this comment.
yes! we don't want to add it in just yet, i want to make sure all the evals are in and working before turning it on in the mcp
| * truncated off the end of the listing, and the swapped-out fields are | ||
| * returned separately so the agent can be told not to use them. | ||
| */ | ||
| function preferReplacementFields(fields: Record<string, AttributeDescriptor>): { |
There was a problem hiding this comment.
[Question] I think this swap goes the opposite direction from Sentry's own handling? When a deprecated attribute and its replacement are both in the same RPC page, the attributes endpoint hides the replacement and keeps the source (_replacement_superseded_by_present_source in organization_trace_item_attributes.py). Is that something we need to worry about?
And/or, should this have direct unit tests?
There was a problem hiding this comment.
oh? this is news to me i'd have to look into that. Maybe we can chat about this in the DMs
There was a problem hiding this comment.
took a look at this! This is true lol but the 🤖 took a look at how it's done in seer and it basically replaces the key/name with whatever the replacement attribute is and passed that to the llm so that it chooses correctly. I'm gonna do the same thing here. So instead of looking for that replacement attribute (which you're right wouldn't exist) i'm gonna change the key of the attribute so it represents the recommended attribute.
There was a problem hiding this comment.
That makes sense to me 🚀
| if (context?.isDeprecated) { | ||
| parts.push( | ||
| context.replacementAttribute | ||
| ? `DEPRECATED: use ${context.replacementAttribute} instead.` |
There was a problem hiding this comment.
[Bug?] This hint can steer the agent somewhere unhelpful when the replacement isn't in the list:
- 13 conventions are deprecated with no backfill/normalize status (e.g.
http.host→server.address,route→http.route), so the replacement may have no data db.params/db.sql.bindingshave the templated replacementdb.query.parameter.<key>, which can't be queried literally- On logs, numeric attributes come back as
tags[http.status_code,number]with replacementhttp.response.status_code. But the bare/directhttp.response.status_coderesolves as a string attribute on logs. Sohttp.response.status_code:503misses the numeric data. - On spans,
transactionwould read "DEPRECATED: use sentry.segment.name instead.", but the endpoint re-aliasessentry.segment.nametotransaction.environment/releaseget the same label even though they resolve to the same storage assentry.environment/sentry.release.
Should we maybe...
- ...give some kind of "if (thing) is possible" treatment? (or do agents just know to not fully trust these hints?)
- ...if this is legit, treat these mismatches as bugs... somewhere?
There was a problem hiding this comment.
hm yes maybe worth putting in there to use the replacement if possible and if it exists. I'll add that in and make an eval for a case like this!
| ${replacedFields.length > 30 ? `\n... and ${replacedFields.length - 30} more deprecated fields` : ""}` | ||
| : "" | ||
| } | ||
| Recommended Fields for ${dataset}: |
There was a problem hiding this comment.
[Bug] Recommended Fields and the EXAMPLE QUERIES below aren't filtered against replacedKeys, so the same output can say "do NOT use http.method" and then show has:http.method as an example. Rule 10 covers this for the prompt but just for the Deprecated Fields section.
Filtering or rewriting those here might be more reliable. And either way, something to test maybe?
There was a problem hiding this comment.
ya good point. I'll do an audit of those examples
| name: "datasetAttributes", | ||
| arguments: { | ||
| dataset: "spans", | ||
| substringMatch: "http.method", |
There was a problem hiding this comment.
[Testing] With params: "fuzzy", this requires a datasetAttributes call whose substringMatch contains "http.method", so a run that only calls { dataset: "spans" } and still produces the right query scores lower. The with-context case doesn't require it. Was that intentional?
There was a problem hiding this comment.
oh yes i actually was testing something and left this in accidentally 😭 i'll clean this up
| return [ | ||
| { | ||
| // EVENTUALLY Context marks http.method as deprecated in favor of http.request.method | ||
| // Context marks http.method as deprecated in favor of http.request.method |
There was a problem hiding this comment.
[Docs] Missing also updating the the suite-level comment above this?
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Want reviews to match your repository better? Bugbot Learning can learn team-specific rules from PR activity. A team admin can enable Learning in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit b4af07d. Configure here.
|
I talked to Dom yesterday about the concerns with replacement attributes for things fields that are not backfilled and he said it shouldn't matter because we still coalesce at query time. As for using |


The main purpose of this PR was to make sure that our evals with the attribute context take deprecated attributes into account and pick the replacement instead.
To do this, the attribute context we are providing in the mocks needed to be properly handled, parsed and passed to the agent in a way that it will understand. We've gone through and excluded attributes that have been deprecated from the list of attributes the agent sees and then also list out the deprecated fields and what its replacement attribute is.
I've adjusted some unit tests to reflect these changes as well.
Closes EXP-1288