Skip to content

feat(search-events): correctly process attribute context in tests + deprecated attribute evals - #1440

Open
nikkikapadia wants to merge 1 commit into
mainfrom
nikki/digest-eval-mock-context
Open

nikkikapadia wants to merge 1 commit into
mainfrom
nikki/digest-eval-mock-context

Conversation

@nikkikapadia

@nikkikapadia nikkikapadia commented Oct 7, 2026 •

Copy link
Copy Markdown
Member

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

@linear-code

linear-code Bot commented Oct 7, 2026

Copy link
Copy Markdown

EXP-1288

@nikkikapadia
nikkikapadia marked this pull request as ready for review October 7, 2026 18:56
@github-actions github-actions Bot added the risk: medium PR risk score: medium label Oct 7, 2026

@JoshuaKGoldberg JoshuaKGoldberg 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.

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

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.

[Question] Nothing in production passes context: true to fetchCustomAttributes. Is that something we handle separately?

* 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>): {

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.

[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?

if (context?.isDeprecated) {
parts.push(
context.replacementAttribute
? `DEPRECATED: use ${context.replacementAttribute} instead.`

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.

[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.bindings have the templated replacement db.query.parameter.<key>, which can't be queried literally
  • On logs, numeric attributes come back as tags[http.status_code,number] with replacement http.response.status_code. But the bare/direct http.response.status_code resolves as a string attribute on logs. So http.response.status_code:503 misses the numeric data.
  • On spans, transaction would read "DEPRECATED: use sentry.segment.name instead.", but the endpoint re-aliases sentry.segment.name to transaction. environment/release get the same label even though they resolve to the same storage as sentry.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?

${replacedFields.length > 30 ? `\n... and ${replacedFields.length - 30} more deprecated fields` : ""}`
: ""
}
Recommended Fields for ${dataset}:

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.

[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?

type: attributeType,
attributeSource,
...(secondaryAliases ? { secondaryAliases } : {}),
context,

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.

[Style] Super nitty nit, feel free to ignore: but the line just above this only sets secondaryAliases if it's defined. Teeny little inconsistency.

Also, to nitpick everyone and everything, I personally like:

...(value && { value })

...just for being a little more succinct. 😄

(absolutely not a blocker ofc)

name: "datasetAttributes",
arguments: {
dataset: "spans",
substringMatch: "http.method",

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.

[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?

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

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.

[Docs] Missing also updating the the suite-level comment above this?

This branch was successfully deployed

1 active deployment
Actions — 9ef270d4 Deployed Oct 7, 2026 by nikkikapadia via eval #1263
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