Skip to content

feat(tools): Return structured output from get_latest_base_snapshot - #1984

Merged
dcramer merged 5 commits into
mainfrom
feat/structured-get-latest-base-snapshot
Nov 5, 2026
Merged

dcramer merged 5 commits into
mainfrom
feat/structured-get-latest-base-snapshot

Conversation

@sentry-junior

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

Copy link
Copy Markdown
Contributor

get_latest_base_snapshot now declares an outputSchema and returns the latest base snapshot as structuredContent through structuredResult(). This follows the Structured Content policy in docs/contributing/tool-responses.md. It is one of a set of per-tool PRs that add output schemas to tools that don't have them yet.

What clients see

  • Model-visible text changes from the markdown summary and image tree to pretty JSON of the same payload (the server generates it).
  • Payload: top-level organizationSlug, appId, snapshotId, url, app (name, platform), vcs, totalImages, groups[] and responseNotes.
  • Images are grouped as groups: [{ group, images: [{ imageFileName, displayName, description }] }]. Ungrouped images go in a group: null bucket. Full imageFileName paths are kept and displayName is never dropped. Grouping keeps the "filter by group" workflow and is lossless.
  • The "Next Steps" hint moves to responseNotes (the responseNotes: string[] pattern get_issue_details uses), not suggestedActions, because the follow-up needs a placeholder image name.
  • The next step points at get_snapshot_image(organizationSlug, snapshotId, imageIdentifier='<imageFileName>') through formatToolCallInstruction. When that tool isn't in the session, it falls back to get_sentry_resource(url="<url>?selectedSnapshot=<URL-encoded imageFileName>"), and the imageIdentifier wording only appears on the direct path.
  • description is now included per image. The tool description already promised it, but the markdown never rendered it. The full head SHA replaces the 8-char prefix, and string pr_number values from the API are kept.
  • The tool description now uses the camelCase field names.

Leak safety
Images and VCS info are mapped field by field in the new tools/support/snapshots/structured.ts; no API object is spread into the payload, and non-object image entries are skipped. The test fixture includes content_hash, image_url, project_id and app_info.app_id, and a regression assertion checks that neither those keys nor fixture values such as "12345" reach structuredContent.

Token cost

  • measure-tokens: 47,079 → 47,096 (+17). That script doesn't count outputSchema.
  • The outputSchema adds about 278 tokens to tools/list (tiktoken, gpt-4), which measure-tokens doesn't report.
  • Response size on a realistic 160-image fixture: 2,251 tokens of markdown → 6,780 tokens of grouped JSON (~3x). A flat images[] shape was 7,764, so grouping saves 13%. Most of the gap is description, which the tool already promised but the markdown never showed; JSON keys per image add the rest. We accepted the ~3x because dropping description would break the tool's documented contract.

Checks

  • generate-definitions, pnpm --filter @sentry/mcp-core run tsc and root pnpm run lint pass. Root pnpm run tsc is left out because its Cloudflare build uploads source maps.
  • The full mcp-core suite passes (2082 tests).
  • In this sandbox I couldn't finish full pnpm run test: @sentry/cli3to4 needs GLIBC 2.35, and CLI permission tests fail when running as root.
  • Evals were skipped because they need provider keys.

Merge note: toolDefinitions.json and skillDefinitions.json will conflict with the sibling schema PRs. On rebase, regenerate them with pnpm run --filter @sentry/mcp-core generate-definitions. The get_snapshot PR is stacked on this branch and builds on structured.ts.

via @dcramer.

--

View Session [Sentry]

Declare an outputSchema and return the latest base snapshot as
structuredContent instead of markdown. Images are mapped field by field,
so internal fields such as content hashes and storage URLs stay out of
the public payload. The next-step hint moves to responseNotes.

Co-Authored-By: David Cramer <[email protected]>
@github-actions github-actions Bot added the risk: medium PR risk score: medium label Nov 5, 2026
The preprod snapshot API can send vcs_info.pr_number as a numeric
string. Parse those into prNumber instead of dropping them.
@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 7:49pm UTC

Request Review

…hot_image

Bucket structured images by snapshot group, skip non-object image
entries, and point the next step at get_snapshot_image with the
snapshotId and an imageFileName as imageIdentifier.

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

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

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 1490755. Configure here.

The get_sentry_resource fallback took the same imageIdentifier suffix
as the direct get_snapshot_image hint, but that tool uses the
selectedSnapshot query parameter instead.
Regenerate toolDefinitions.json after resolving the merge conflict.

Co-Authored-By: David Cramer <[email protected]>
@dcramer
dcramer merged commit 7b283a5 into main Nov 5, 2026
35 checks passed
@dcramer
dcramer deleted the feat/structured-get-latest-base-snapshot branch November 5, 2026 21:46
dcramer added a commit that referenced this pull request Nov 5, 2026
`get_snapshot` now declares an `outputSchema` and returns the snapshot
comparison as `structuredContent` through `structuredResult()`,
following the Structured Content policy in
`docs/contributing/tool-responses.md`. It's one of the per-tool
outputSchema PRs.

**Stacked on #1984.** It reuses the grouped image shape and
`tools/support/snapshots/structured.ts` from that branch. After #1984
merges, retarget this PR to `main`.

**What clients see**
- Model-visible text changes from the markdown diff summary to pretty
JSON of the payload. It includes snapshot identity, `url`, `state`,
`comparisonType`, `app`, `vcs`, `approval`, `counts`, the image sections
and `responseNotes`.
- Every image section uses #1984's grouped shape: `[{ group, images: [{
imageFileName, displayName, ... }] }]`. Changed images carry
`diffPercent`, and renamed images carry `previous`.
- `images` (the full inventory) appears only when there are no diffs.
`unchanged`/`skipped` appear only with `showUnmodified=true` on a
non-solo snapshot, matching what the markdown showed.
- `responseNotes` point at `get_snapshot_image(organizationSlug,
snapshotId, imageIdentifier='<imageFileName>')` for previews and
`imageResolution='full'` for original bytes, through
`formatToolCallInstruction`. When `get_snapshot_image` isn't in the
session, the preview note falls back to
`get_sentry_resource(url="<url>?selectedSnapshot=<URL-encoded
imageFileName>")` without the imageIdentifier wording.
- `get_sentry_resource` passes the structured result through for
snapshot URLs. It has no outputSchema of its own, which the policy
allows. Its snapshot placeholders now use
`<organizationSlug>`/`<snapshotId>`/`<imageFileName>`.
- The markdown tree renderer and `fetchSnapshotSummary` helpers are
removed, since nothing calls them anymore.

**Review**
A reviewer pass found one must-fix: the imageIdentifier suffix sat
outside `formatToolCallInstruction`, so the `get_sentry_resource`
fallback named the wrong argument. It's fixed in this head. The same
commit adds an exact `responseNotes` assertion for the case where
get_snapshot_image is unavailable, and the diff percent math now reuses
the shared helper.

**Leak safety**
Fields are mapped explicitly, and no API object is spread. Tests assert
that internal fixture values (content hashes, storage URLs,
`project_id`) and hidden unchanged/skipped images don't reach
`structuredContent`.

**Token cost**
- `measure-tokens`: 47,096 → 47,114 on top of #1984 (+18; +35 vs main).
- The `outputSchema` adds about 1,010 tokens to `tools/list`, which
`measure-tokens` doesn't count. That's comparable to `find_releases`
(1,497).
- Response size, markdown → JSON on a 160-image fixture: diff 605 →
1,243 (2.05x), solo 2,277 → 5,175 (2.27x), `showUnmodified` 2,466 →
5,546 (2.25x).
- A file→displayName map shape measured 1.4–1.9x. We kept the
one-object-per-image shape for consistency with #1984.

**Checks**
- `generate-definitions`, `pnpm --filter @sentry/mcp-core run tsc` and
root `pnpm run lint` pass. Root `pnpm run tsc` is left out because its
Cloudflare build uploads source maps.
- The full mcp-core suite passes (2083 passed, 6 skipped).
- Evals were skipped because they need provider keys.

**Merge note:** `toolDefinitions.json` and `skillDefinitions.json` will
conflict with sibling schema PRs. Regenerate them on rebase with `pnpm
run --filter @sentry/mcp-core generate-definitions`.

<!-- junior-request-attribution:start -->
via @dcramer.
<!-- junior-request-attribution:end -->

<!-- junior-session-footer:start -->
<!-- junior-conversation-id:agent%3Af853d18200808c962eb0a3854bfd5b72 -->

--

[View
Session](https://junior-prod.sentry.dev/conversations/agent%3Af853d18200808c962eb0a3854bfd5b72)
[[Sentry]](https://sentry.sentry.io/explore/conversations/agent%3Af853d18200808c962eb0a3854bfd5b72/?project=4510944073809921)

<!-- junior-session-footer:end -->

---------

Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com>
Co-authored-by: David Cramer <[email protected]>

This branch was successfully deployed

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