Skip to content

feat(seer-billing): Show out-of-credits Seer failures in MCP - #2031

Merged
srest2021 merged 7 commits into
mainfrom
srest2021/CW-2330
Nov 11, 2026
Merged

srest2021 merged 7 commits into
mainfrom
srest2021/CW-2330

Conversation

@srest2021

@srest2021 srest2021 commented Nov 5, 2026 •

Copy link
Copy Markdown
Member

Fixes CW-2330

Depends on getsentry/sentry#130284

analyze_issue_with_seer now says why a run didn't start when Sentry answers 402, for out-of-credits and out-of-quota orgs, instead of returning an API error. It tells the two apart by code. A 402 without the out-of-credits code, including the bare-string out-of-quota body that Sentry sends before #130284, still reads as out of quota.

When a run stopped because the org ran out of credits (failure_reason=out_of_credits), the tool and get_issue_details now say why.

Until the Sentry PRs ship, a run that runs out of credits still starts and then stops with out_of_credits, which this PR already explains. Both Sentry checks are behind organizations:seer-credit-checks.

analyze_issue_with_seer checks the organization's Seer credits before starting a run, and tells the user when a run stopped because the organization ran out of credits. get_issue_details shows the same reason. A failed credit check never blocks a run.

Refs CW-2330
@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 11, 2026 5:45pm UTC

Request Review

@linear-code

linear-code Bot commented Nov 5, 2026

Copy link
Copy Markdown

CW-2330

@srest2021 srest2021 changed the title feat(seer): Check Seer credits and show out-of-credits failures feat(seer-billing): Check Seer credits and show out-of-credits failures Nov 5, 2026
@srest2021
srest2021 marked this pull request as ready for review November 5, 2026 22:05
@github-actions github-actions Bot added the risk: medium PR risk score: medium label Nov 5, 2026
@srest2021
srest2021 requested a review from a team November 5, 2026 22:06
Say auto-reload, which is what the billing settings call it, and point to someone with billing access, since MCP users can have any role.

Refs CW-2330
Sentry checks Seer credits when analyze_issue_with_seer starts a run and answers 402 if there aren't enough, so the extra credit-check request isn't needed. The tool now turns a 402 from starting a run into an "Analysis Not Started" message instead of an error.

Refs CW-2330

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@srest2021 srest2021 changed the title feat(seer-billing): Check Seer credits and show out-of-credits failures feat(seer-billing): Show out-of-credits Seer failures Nov 9, 2026
Sentry now tags billing 402s with seer_out_of_credits or
seer_out_of_quota. Branch on the code instead of the body shape. A 402
without the out-of-credits code, including the bare string older Sentry
versions send, still reads as out of quota.

Co-Authored-By: Sofia Rest <sofia.rest@sentry.io>

if (existingStatus !== "completed") {
output += `\n**Status**: ${existingStatus}\n`;
output += getFailureReasonGuidance(

@jaydgoss jaydgoss Nov 11, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This keeps returning the old out-of-credits run even after the org tops up, since we only start a new run when none exists. The CLI (#2150) starts a new run when the last one errored. Worth doing the same here? Fine as a follow-up.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yeah I noticed that too, we can definitely do a followup 👍 Added a ticket to track it here https://linear.app/getsentry/issue/CW-3094/mcp-restart-a-run-when-the-last-one-failed

A 402 doesn't say whether auto-reload is off or the Seer spend limit
was hit, so "turn on auto-reload" is wrong when it's already on.
Use the same "adjust Seer spend and auto-reload" copy as #2150.

Co-Authored-By: Sofia Rest <sofia.rest@sentry.io>
Co-Authored-By: Sofia Rest <sofia.rest@sentry.io>
@srest2021 srest2021 changed the title feat(seer-billing): Show out-of-credits Seer failures feat(seer-billing): Show out-of-credits Seer failures in MCP Nov 11, 2026
BYK pushed a commit that referenced this pull request Nov 11, 2026
`sentry issue explain` and `sentry issue plan` treat every 402 from the
autofix endpoint as "Seer requires a paid plan" and offer a free trial.
An org on token-based billing that runs out of Seer credits gets that
message too. A run that starts and then stops for credits reads as
"Analysis completed but no root causes found" or "Plan creation failed".

- A 402 with `code: "seer_out_of_credits"` (added in
getsentry/sentry#130284) now raises a new `out_of_credits` Seer error.
Any other 402, including `seer_out_of_quota` and the 402 with no code
that older Sentry versions send, keeps the current no-budget error.
- A run that ends with `failure_reason: "out_of_credits"` raises the
same error from both commands.
- The error has its own exit code, 43, and is left out of the free trial
prompt.

What the user sees:

```
Your organization is out of Seer credits.

Someone with billing access can adjust Seer spend and auto-reload in Sentry:
  https://my-org.sentry.io/settings/billing/overview/?product=seer
```

A failed run is still retried on the next invocation, so someone who
topped up recovers by running the command again.

The 402 comes from getsentry/sentry#130283 and getsentry/sentry#130284,
which have both merged. Sentry's credit checks are behind the
`organizations:seer-credit-checks` flag, so for an org without it the
CLI behaves as it does today. The MCP equivalent is #2031.

Fixes CW-3075
@srest2021
srest2021 enabled auto-merge (squash) November 11, 2026 17:52
@srest2021
srest2021 merged commit 83b4719 into main Nov 11, 2026
55 checks passed
@srest2021
srest2021 deleted the srest2021/CW-2330 branch November 11, 2026 17:58
vaind added a commit that referenced this pull request Nov 13, 2026
Fixes CW-3094

`analyze_issue_with_seer` returns an issue's existing run as soon as it
has finished, and that includes failed runs. A run that stopped because
the org ran out of Seer credits keeps coming back as the result, so it
can't be retried after someone tops up. Follow-up to #2031, from [this
review
thread](#2031 (comment)).

The tool now starts a new run whenever the last one ended in `error`,
whatever the reason, matching the CLI (#2150). Completed and
waiting-for-input runs are still returned as they are. If the org is
still out of credits, the new start gets a 402, which the tool already
explains as "Analysis Not Started". It now also shows whatever the
failed run found before it stopped, such as a root cause.

Tested manually against sentry.io with the local stdio server. On an
issue whose last run had failed, the tool started a new run and returned
its root cause, and the issue's latest run is now the completed one. The
402 path is covered only by unit tests, since it needs an org that's out
of credits.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

This branch was successfully deployed

2 active (1 outdated) deployments
Actions — a697e12a Deployed Nov 11, 2026 by sentry-junior[bot] via eval #1803
Preview — 1fe7ba48 Deployed Nov 11, 2026 by vercel[bot]
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.

3 participants