Repository navigation
feat(seer): Add Seer credit check helper and endpoint - #129130
Merged
Merged
Conversation
Add a helper that asks billing whether an org has enough Seer credits for an operation, using placeholder per-operation estimates, and an endpoint the UI can call before triggering one. Gated by organizations:seer-credit-checks and token-billed-seer-enabled. Refs CW-2323
srest2021
commented
Oct 29, 2026
Comment on lines
+22
to
+23
| AUTOFIX = "autofix" | ||
| EXPLORER = "explorer" |
Member
Author
There was a problem hiding this comment.
Using DATA_CATEGORY_BILLABLE_SEER_CREDITS features as a reference
srest2021
commented
Oct 29, 2026
| @dataclass(frozen=True) | ||
| class SeerOperationConfig: | ||
| feature: SeerFeature | ||
| estimate: Callable[[], int] |
Member
Author
There was a problem hiding this comment.
Extendable for when we want to dynamically calculate these
volokluev
reviewed
Oct 29, 2026
srest2021
commented
Oct 29, 2026
Rename the helper to can_run_seer_operation so it no longer shares a name with quotas.backend.has_seer_credits, and the response field to hasEnoughCredits. Drop the token-billed-seer-enabled check, which belongs in getsentry's quotas implementation. Refs CW-2323
volokluev
reviewed
Oct 29, 2026
quotas.backend.has_seer_credits now takes a HasSeerCreditsRequest and returns a HasSeerCreditsResponse, so getsentry can share it with the LLM proxy's lease_llm_quota RPC. take_lease is false until leases exist. Refs CW-2323
srest2021
marked this pull request as ready for review
October 29, 2026 21:30
srest2021
requested review from
sehr-m and
volokluev
and removed request for
a team
October 29, 2026 21:30
Co-Authored-By: Sofia Rest <[email protected]>
Co-Authored-By: Sofia Rest <[email protected]>
Co-Authored-By: Sofia Rest <[email protected]>
srest2021
commented
Oct 30, 2026
|
|
||
| def can_run_seer_operation(organization: Organization, operation: SeerOperation) -> bool: | ||
| """Whether the organization has enough Seer credits to run the operation.""" | ||
| if not features.has("organizations:seer-credit-checks", organization): |
Member
Author
There was a problem hiding this comment.
I do not check the token-based billing flag here since I assume quotas.backend.check_seer_credits will do that anyway.
volokluev
approved these changes
Oct 30, 2026
This was referenced Nov 2, 2026
# Conflicts: # static/app/utils/api/knownSentryApiUrls.generated.ts Co-Authored-By: Sofia Rest <[email protected]>
Match the open_pr step value the frontend sends to the autofix endpoint. Co-Authored-By: Sofia Rest <[email protected]>
volokluev
added a commit
that referenced
this pull request
Nov 2, 2026
Seer credit checks go through `quotas.backend.check_seer_credits` (added in #129130). That means getsentry has to implement them in `getsentry/quotas.py`, which is already overloaded ([review comment](getsentry/getsentry#22885 (comment))). This PR adds a dedicated swappable backend, `SENTRY_SEER_CREDIT`, built the same way as `SENTRY_PARTNERSHIPS`: - `sentry.seer_credit.SeerCredit` is the default. Every check passes, which matches the current `Quota.check_seer_credits` default. - `can_run_seer_operation` now calls `seer_credit.backend.check_seer_credits`. - `Quota.check_seer_credits` is removed. No user-facing change: credit checks are still behind `organizations:seer-credit-checks`, and every backend involved returns `has_enough_credits=True`. **Follow-up:** getsentry/getsentry#22888 implements the backend in `getsentry/seer_credit.py` and sets `SENTRY_SEER_CREDIT`. Merge this PR first, then that one. In the gap, getsentry's `SubscriptionQuota.check_seer_credits` (from getsentry#22885) is no longer called, so the Seer wallet balance-lookup sample pauses until #22888 lands. <!-- junior-request-attribution:start --> via **volo**. <!-- junior-request-attribution:end --> <!-- junior-session-footer:start --> <!-- junior-conversation-id:slack%3AD0BNNTBGH53%3A1793659141.093839 --> -- [View Session](https://junior-prod.sentry.dev/conversations/slack%3AD0BNNTBGH53%3A1793659141.093839) [[Sentry]](https://sentry.sentry.io/explore/conversations/slack%3AD0BNNTBGH53%3A1793659141.093839/?project=4510944073809921) <!-- junior-session-footer:end --> Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com> Co-authored-by: Volo Kluev <[email protected]>
billyvg
added a commit
that referenced
this pull request
Nov 5, 2026
Adds `useSeerCreditCheck(operation)`, which asks `GET
/organizations/{org}/seer/credit-check/?operation=…` whether the org can
afford one Seer operation (an autofix step or a chat message) and
returns `hasEnoughCredits`. Nothing uses it yet; the gating PRs stacked
on this one do.
- It only calls the endpoint for orgs with `seer-credit-checks`. Without
the flag, when disabled, or when the request fails, it returns
`hasEnoughCredits: true`, so a broken check never blocks Seer and the
backend still has the final say.
- `isPending` is only true while a check is in flight (a disabled
TanStack query reports pending forever), so callers can show a
placeholder instead of flashing the start button.
- It is deliberately separate from `useOrganizationSeerSetup`:
setup-check is mounted on many pages that should not make a billing
call, so this one should only be mounted where a Seer trigger is about
to show.
- `staleTime: 0` because credits change outside the page (a run
elsewhere spends them, a billing member tops up in another tab), so the
check reruns on mount and window focus.
The endpoint landed in #129130.
Fixes CW-2327
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Claude Opus 5.5 <[email protected]>
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.
Fixes CW-2320
Relates to CW-2323
Adds a backend credit check helper & endpoint for token-billed Seer, so the UI & other entrypoints can tell whether an org can afford an operation before triggering it.
can_run_seer_operation(organization, operation)insentry/seer/credits.pyasks billing via a newquotas.backend.check_seer_credits(CheckSeerCreditsRequest) -> CheckSeerCreditsResponse.autofix/explorer) and a credit estimate. For now every estimate is a placeholder of 100 credits until we figure out better estimates.organizations:seer-credit-checksflag; otherwise alwaysTrue. Whether the org is token-billed is left to getsentry's quotas implementation.GET /organizations/{org}/seer/credit-check/?operation=autofix_root_causereturns{"hasEnoughCredits": bool}.via sofia.
--
View Session [Sentry]