Skip to content

feat(tools): Add outputSchema to get_profile_details - #2024

Merged
dcramer merged 4 commits into
mainfrom
feat/structured-get-profile-details
Nov 5, 2026
Merged

dcramer merged 4 commits into
mainfrom
feat/structured-get-profile-details

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

get_profile_details now returns an outputSchema and schema-conforming structuredContent. Errors still throw.

The root object is { profile, samples, suggestedActions }:

  • profile is a discriminated union on profileType: transaction, legacy or continuous. It holds only the summary fields.
  • samples is shared by transaction and continuous profiles, and is null for legacy profiles.
  • suggestedActions holds concrete follow-up calls.

The now-unused profile details markdown formatters are removed.

Fixes from review

  • Legacy follow-up step: a legacy profile now returns a get_profile suggested action (organizationSlug, projectSlugOrId, transactionName, plus the resolved regionUrl).
    • It only appears when the profile has a transaction name and get_profile can be called in the session.
    • It's wrapped in execute_sentry_tool when get_profile is in the catalog but not a direct tool. That keeps the follow-up when the profile is reached through get_sentry_resource.
    • Tests cover the suggestion present, the tool unavailable, no transaction name, the regionUrl pass-through and the catalog wrapping.
  • Null instead of placeholders: an empty or missing continuous release/environment now maps to null (ProfileChunkSchema no longer defaults release to "unknown"). The topFrames function and location fields are now nullable instead of falling back to the literal "unknown".
  • samples moved up: it's now a top-level sibling (sampleAnalysisSchema.nullable()) rather than part of each union branch.
  • Legacy no-leak test: it checks that the raw speedscope profiles, shared, frames and metadata keys and an injected raw value don't appear in the output.

Tokens (o200k_base, JSON vs old markdown)

Profile JSON pretty JSON compact Old markdown
Transaction 1039 718 813
Continuous 1015 706 822
Legacy ~280 ~240 317

The legacy numbers include ~60 tokens for the suggestion. The outputSchema is 821 tokens, down from 912; about 77 of those are the suggestedActions schema. The description is 490 tokens. measure-tokens doesn't count the outputSchema.

(B) Shared helper: packages/mcp-core/src/internal/tool-helpers/suggested-actions.ts is byte-identical to the canonical blob ee84917 from feat/structured-get-replay-details, so whichever lands second adds nothing for that file.

Follow-up (A), known existing bug in get_profile, not changed here: the flamegraph comparison compares absolute sumDuration across windows of different length (7d vs 14d), so results lean toward "improvement".

Merge note: this PR and the get_profile PR both touch the profile formatter. Whichever merges second must git rm both packages/mcp-core/src/tools/support/profile/formatter.ts and formatter.test.ts, then regenerate. Keeping either side's formatter breaks tsc or leaves dead code.

On rebase: regenerate toolDefinitions.json with pnpm run --filter @sentry/mcp-core generate-definitions.

Note: on main, the test "copies profilerId from the request when the chunk payload omits it" mocks only sentry.io, while the request goes to us.sentry.io, so it likely doesn't exercise the fallback. It's left unchanged here.

Checks run with SENTRY_AUTH_TOKEN unset: generate-definitions (no diff), mcp-core tsc, full mcp-core vitest and root lint all pass. Root tsc, test and build were not run.

via @dcramer.

--

View Session [Sentry]

sentry-junior Bot and others added 3 commits November 5, 2026 19:55
Return one profile as structured content under `profile`, discriminated by
`profileType`: `transaction` (sample-format), `legacy` (speedscope summary
only), or `continuous` (profile chunk). Transaction and continuous profiles
share one `samples` shape with frame/sample/stack counts, per-thread sample
counts, and the top frames by occurrence. The continuous shape no longer
repeats chunk metadata the way the old "Raw Sample Analysis" section did.

Follow-up guidance from the old markdown (open profile/trace URLs, use
search_profiles, call get_profile for legacy profiles) moves into the tool
hints. The now-unused profile details markdown formatters and their tests
are removed; their behavior tests move to the structured builders.

Co-Authored-By: David Cramer <[email protected]>
Suggest a get_profile call for legacy profiles that name a transaction when
get_profile is callable in the session, so the follow-up survives dispatch
through get_sentry_resource. Adds the shared suggested-actions builder,
copied unchanged from the get_replay_details branch.

Move sample analysis out of the profile union into a top-level `samples`
field (null for legacy profiles), which shrinks the output schema.

Map empty or missing continuous release and environment to null, dropping
the "unknown" release default from ProfileChunkSchema, and add a no-leak
test for legacy speedscope profiles.

Co-Authored-By: David Cramer <[email protected]>
@vercel

vercel Bot commented Nov 5, 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 5, 2026 10:29pm UTC

Request Review

@github-actions github-actions Bot added the risk: medium PR risk score: medium label Nov 5, 2026
#2023 landed get_profile structured output, so the profile markdown
formatter and its test have no callers left. Remove both and
regenerate tool definitions.
@dcramer
dcramer merged commit 8cf34ee into main Nov 5, 2026
34 checks passed
@dcramer
dcramer deleted the feat/structured-get-profile-details branch November 5, 2026 22:58

This branch was successfully deployed

1 active and 1 inactive deployments
Preview — 559ed249 Deployed Nov 5, 2026 by vercel[bot]
Actions — 559ed249 Deployed Nov 5, 2026 by sentry-junior[bot] via eval #1657
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.

1 participant