Repository navigation
feat(tools): Return structured output from get_latest_base_snapshot - #1984
Merged
Merged
Conversation
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]>
The preprod snapshot API can send vcs_info.pr_number as a numeric string. Parse those into prNumber instead of dropping them.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
…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]>
Contributor
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ 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
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

get_latest_base_snapshotnow declares anoutputSchemaand returns the latest base snapshot asstructuredContentthroughstructuredResult(). This follows the Structured Content policy indocs/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
organizationSlug,appId,snapshotId,url,app(name,platform),vcs,totalImages,groups[]andresponseNotes.groups: [{ group, images: [{ imageFileName, displayName, description }] }]. Ungrouped images go in agroup: nullbucket. FullimageFileNamepaths are kept anddisplayNameis never dropped. Grouping keeps the "filter by group" workflow and is lossless.responseNotes(theresponseNotes: string[]patternget_issue_detailsuses), notsuggestedActions, because the follow-up needs a placeholder image name.get_snapshot_image(organizationSlug, snapshotId, imageIdentifier='<imageFileName>')throughformatToolCallInstruction. When that tool isn't in the session, it falls back toget_sentry_resource(url="<url>?selectedSnapshot=<URL-encoded imageFileName>"), and the imageIdentifier wording only appears on the direct path.descriptionis 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 stringpr_numbervalues from the API are kept.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 includescontent_hash,image_url,project_idandapp_info.app_id, and a regression assertion checks that neither those keys nor fixture values such as"12345"reachstructuredContent.Token cost
measure-tokens: 47,079 → 47,096 (+17). That script doesn't countoutputSchema.outputSchemaadds about 278 tokens totools/list(tiktoken, gpt-4), whichmeasure-tokensdoesn't report.images[]shape was 7,764, so grouping saves 13%. Most of the gap isdescription, which the tool already promised but the markdown never showed; JSON keys per image add the rest. We accepted the ~3x because droppingdescriptionwould break the tool's documented contract.Checks
generate-definitions,pnpm --filter @sentry/mcp-core run tscand rootpnpm run lintpass. Rootpnpm run tscis left out because its Cloudflare build uploads source maps.pnpm run test:@sentry/cli3to4needs GLIBC 2.35, and CLI permission tests fail when running as root.Merge note:
toolDefinitions.jsonandskillDefinitions.jsonwill conflict with the sibling schema PRs. On rebase, regenerate them withpnpm run --filter @sentry/mcp-core generate-definitions. Theget_snapshotPR is stacked on this branch and builds onstructured.ts.via @dcramer.
--
View Session [Sentry]