Skip to content

feat(search): Split search_events into dataset-specific tools - #1374

Merged
skaasten merged 2 commits into
mainfrom
feat/split-search-events-by-dataset
Oct 2, 2026
Merged

skaasten merged 2 commits into
mainfrom
feat/split-search-events-by-dataset

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

Supersedes #1371. Instead of making dataset required on search_events, this splits search into one tool per dataset, so the agent picks the dataset by picking the tool and has fewer ways to get it wrong.

What changed

New direct tools, all backed by the same handler:

  • search_errors: errors, Seer Errors

  • search_logs: logs, Seer Logs

  • search_traces: spans, Seer Traces

  • search_metrics: metrics, Seer Metrics

  • search_profiles: profiles, no Seer

  • search_replays: replays, no Seer

  • The handler moved from tools/catalog/search-events.ts to tools/support/search-events/search.ts (runSearchEvents). Each tool sets its own dataset and passes lockDataset: true. The embedded agent prompt says the dataset is fixed, and the handler ignores any dataset switch the agent suggests. This way search_logs can't return spans.

  • Each tool has a shorter description that covers only its own dataset. The event tools have no dataset param, and environment filters go in query. search_replays has no fields and keeps its separate environment param.

  • search_traces documents same-trace cross-event queries ("checkout requests that also have an error log"). Seer only applies cross-event filters with the Traces strategy.

  • Compatibility: search_events is still in the catalog as a deprecated alias (execute_sentry_tool can still call it). It is off the direct surface and left out of skill definitions.

  • Direct surface (surfaces.ts) grows from 9 to 14 tools. That's still under the target of 20 and the hard limit of 25.

  • Updated next-step hints that pointed at search_events: trace details, profile formatter, Seer unsupported-issue message, search_issues formatters, get_sentry_resource.

  • Updated the plugin agent prompts, evals (search-events.eval.ts now expects the specific tool), the Cloudflare stdio setup copy, and the docs (spec, testing, architecture, READMEs). Regenerated the tool/skill definitions.

Tradeoffs

  • Token cost: the direct-surface definitions go from 5,786 to 8,906 tokens (+3,120), per pnpm run measure-tokens. The six search tools total 4,238 tokens, compared with 1,130 for search_events, because each one repeats the shared params. Possible follow-ups: keep search_profiles/search_replays catalog-only, or trim the shared param descriptions.
  • Misrouting still happens, just earlier. Picking a tool by name is usually more reliable than picking from an enum, but "slow requests with an error log" can still go to search_logs instead of search_traces. The cross-event hint on search_traces is meant to catch that.
  • Out of scope: the Seer gate still skips structured-looking queries and explicit fields/sort. That's a separate change.

Testing

  • mcp-core: 1749 tests pass. That includes new tests for each tool, covering the locked dataset and the schema with no dataset param. search_traces also has a test that sends a natural-language query to Seer's Traces strategy.
  • mcp-cloudflare: 430 tests pass.
  • Typecheck passes for core, cloudflare, server, evals and test-client. packages/cli typecheck fails in my sandbox with a Node loader error (ERR_INVALID_RETURN_PROPERTY_VALUE). The same failure happens on clean main.
  • Lint passes.
  • Not yet run: CI evals, and a live check against an org that has Seer enabled.

via shaun.kaasten.

--

View Junior Session [Sentry]

Replace the multi-dataset search_events tool on the direct MCP surface
with one tool per dataset: search_errors, search_logs, search_traces,
search_metrics, search_profiles, and search_replays. Tool selection now
picks the dataset, so agents can no longer omit or mis-pick a `dataset`
argument (which silently fell back to errors and skipped Seer).

All six tools share one handler, moved to
tools/support/search-events/search.ts. Each tool fixes its dataset and
passes lockDataset so the embedded agent cannot switch datasets.
search_traces documents same-trace cross-event queries, since Seer only
runs cross-event filters for the Traces strategy.

search_events stays in the catalog as a deprecated alias for backward
compatibility and is excluded from skill definitions.

Co-Authored-By: Shaun Kaasten <shaun.kaasten@sentry.io>
Comment thread packages/mcp-core/src/tools/catalog/get-latest-base-snapshot.ts Outdated
Comment thread packages/mcp-core/src/tools/catalog/search-profiles.test.ts Outdated
Replace the six copy-pasted per-tool test files (each mocking the AI SDK
and MSW endpoints) with one-test baselines that mock only
runSearchEvents via a shared test-utils helper. The lockDataset
behavior is tested once against the shared handler in
search-events.test.ts, reusing its existing mocks.

Also drop the "not search_replays or search_issues" clause from the
get_latest_base_snapshot description to save tokens.
@skaasten
skaasten marked this pull request as ready for review October 2, 2026 16:44
@github-actions github-actions Bot added the risk: medium PR risk score: medium label Oct 2, 2026
@skaasten
skaasten merged commit a60b9fe into main Oct 2, 2026
35 checks passed
@skaasten
skaasten deleted the feat/split-search-events-by-dataset branch October 2, 2026 17:51

This branch was successfully deployed

1 active deployment
Actions — b63856ad Deployed Oct 2, 2026 by sentry-junior[bot] via eval #1169
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