Skip to content

fix(search-events): Preserve structured trace searches#969

Merged
dcramer merged 11 commits into
mainfrom
fix/search-events-structured-fields
May 15, 2026
Merged

fix(search-events): Preserve structured trace searches#969
dcramer merged 11 commits into
mainfrom
fix/search-events-structured-fields

Conversation

@dcramer
Copy link
Copy Markdown
Member

@dcramer dcramer commented May 14, 2026

Summary of changes from main:

  • Preserve caller-provided structured trace-item searches in search_events for spans/logs/metrics. Complete explicit requests can execute directly, and partial requests that still invoke the embedded agent now keep the caller-provided query filters, fields, sort, and time range when those inputs are explicit and valid.
  • Guard agent-repaired structured queries so they can add constraints but cannot silently replace user filters, including exact token checks and quoted-value handling. Non-replay environment params are appended as query filters instead of being dropped.
  • Tighten Sentry search-syntax detection so URLs, time labels, and prose labels do not bypass the agent as false structured queries.
  • Extend the Sentry API client and datasetAttributes tool with targeted trace-item attribute lookup, exact attribute validation, attributeTypes, substring/query filtering, and typed attribute-source parsing.
  • Include executed search details in responses and add regression and eval coverage for custom tag fields, environment preservation, repaired query preservation, quoted values, attribute validation, and agent preservation of explicit Sentry search syntax.

Fixes #968

Comment thread packages/mcp-core/src/tools/search-events/formatters.ts Fixed
@dcramer dcramer force-pushed the fix/search-events-structured-fields branch from d25ace3 to 8600ce5 Compare May 14, 2026 17:31
Comment thread packages/mcp-core/src/tools/search-events/handler.ts
Respect caller-provided structured search syntax for explicit trace-item dataset requests and add targeted attribute discovery and validation so agents do not discard valid custom fields.

Fixes #968
Co-Authored-By: GPT-5 Codex <noreply@openai.com>
@dcramer dcramer force-pushed the fix/search-events-structured-fields branch from 8600ce5 to e34c33e Compare May 14, 2026 17:52
Append non-replay environment filters to trusted structured trace searches and avoid partial markdown escaping in executed-search output.

Type trace item attribute sources using the upstream Sentry API shape instead of forwarding unknown JSON.

Refs #968
Co-Authored-By: GPT-5 Codex <noreply@openai.com>
Comment thread packages/mcp-core/src/tools/search-events/utils.ts
Avoid treating URL schemes, time labels, and prose labels as trusted structured Sentry search syntax for trace datasets.

Keep valid tags, dotted fields, known fields, and lowercase custom field filters eligible for direct structured execution.

Refs #968
Co-Authored-By: GPT-5 Codex <noreply@openai.com>
@dcramer dcramer marked this pull request as ready for review May 14, 2026 18:22
Only accept an agent-repaired structured trace query when the repaired query still contains the original user filters. This lets the agent add constraints without replacing caller-supplied search input.

Refs #968
Co-Authored-By: GPT-5 Codex <noreply@openai.com>
Comment thread packages/mcp-core/src/tools/search-events/handler.ts Outdated
Use token-aware containment when deciding whether an agent-repaired structured trace query preserved the original user filters.

Refs #968
Co-Authored-By: GPT-5 Codex <noreply@openai.com>
Comment thread packages/mcp-core/src/tools/search-events/handler.ts
dcramer and others added 2 commits May 14, 2026 12:18
Tokenize structured query filters without splitting quoted values so repaired trace queries cannot pass preservation checks after changing a quoted filter value.

Refs #968

Co-Authored-By: GPT-5 Codex <noreply@openai.com>
Add a behavior-level search_events agent eval that starts from a user-style request and asserts explicit Sentry search filters, fields, sort, and time range survive the agent translation.

Mock trace item attribute validation for eval runs so future agent calls can validate exact attributes without escaping the local mock server.

Refs #968

Co-Authored-By: GPT-5 Codex <noreply@openai.com>
Keep the preservation eval focused on output behavior so future exact datasetAttributes validation arguments do not fail the test.

Refs #968

Co-Authored-By: GPT-5 Codex <noreply@openai.com>
Comment thread packages/mcp-core/src/tools/search-events/handler.ts
Remove the environment-name sniffing from appendSearchFilter so quoted search values cannot suppress an explicit environment parameter.

Refs #968

Co-Authored-By: GPT-5 Codex <noreply@openai.com>
Comment thread packages/mcp-core/src/tools/search-events/handler.ts
Avoid appending the same exact environment filter twice when an agent-repaired structured trace query already contains it.

Refs #968

Co-Authored-By: GPT-5 Codex <noreply@openai.com>
Copy link
Copy Markdown

@cursor cursor Bot left a comment

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.

Reviewed by Cursor Bugbot for commit 89d737b. Configure here.

Comment thread packages/mcp-core/src/tools/search-events/formatters.ts
Pad executed-search inline code when values start or end with backticks so Markdown parsers preserve the literal value.

Refs #968

Co-Authored-By: GPT-5 Codex <noreply@openai.com>
@dcramer dcramer merged commit f7dfaad into main May 15, 2026
16 of 18 checks passed
@dcramer dcramer deleted the fix/search-events-structured-fields branch May 15, 2026 00:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

search_events agent silently drops custom tag predicates from query (e.g. tags[type], tags[sequence])

2 participants