Repository navigation
Conversation
smirea
force-pushed
the
fix/cursor-weekly-usage-limit
branch
from
November 29, 2026 21:44
94adcc7 to
73c51a1
Compare
Owner
Author
|
Opened upstream as pingdotgg#45740 (fixes pingdotgg#45739). |
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.
Problem
When a Cursor account hits its weekly usage limit (
Weekly usage limit reached. It resets in 3 days. Buy credits to keep going now.),isCursorUsageLimitError()returnsfalse:packages/provider-cursor/src/server/adapter.ts) classify the failure asprovider_error("Provider error") instead ofusage_limit("Usage limit reached" / sidebarLimitedbadge), contradictingdocs/internals/03_providers.md("Classify quota/rate-limit errors asusage_limit(with reset time when available) rather than generic failures").packages/provider-cursor/src/server/textGeneration.ts— thread titles, branch names, commit messages, PR descriptions) falls back to"Cursor SDK request finished with an error."instead of"Cursor usage limit reached. Try again later or choose another text-generation provider.", missing the case PR fix(cursor): Cursor text generation names usage-limit failures pingdotgg/t3code#29748 and PR fix(server,cursor,opencode): refresh provider usage when a turn hits its usage limit pingdotgg/t3code#26234 intended to cover.Root cause: In
@cursor/sdk@1.5.2,AgentClientwraps aConnectErrorcarryingaiserver.v1.ErrorDetails(PRO_USER_USAGE_LIMIT,RATE_LIMITED, etc.) into an internalActionRequiredErrorwhose.causeis theConnectErrorand which has no.code.LocalAgent'stoRunError/wrapErroronly checkserr instanceof CursorSdkErroranderr instanceof ConnectError(nevererr.cause), so it falls back toUnknownAgentErrorand returnsRunResult.error = { message }withcode: undefined. In addition,CURSOR_USAGE_LIMIT_CODEdid not matchUSAGE_PRICING_REQUIREDorUSAGE_PRICING_REQUIRED_CHANGEABLE.Change
isCursorUsageLimitError()inpackages/provider-cursor/src/server/CursorAgentSdk.ts:.causechain (matchingblockedInlineMcpServersandisCursorCancellationError) so wrapped SDK errors preserve structuredname/status/codedetection.CURSOR_USAGE_LIMIT_CODEto includeusage_pricing_required(?:_changeable)?and\w*_usage_limit_exceeded.codeis absent or generic ("",error,unknown,unspecified,custom,custom_message,provider_error), fall back to matching start-anchored Cursor usage/spending/rate-limit error messages (CURSOR_USAGE_LIMIT_MESSAGE) so embedded strings in unrelated failures (e.g., file paths) and errors with specific non-usage codes (e.g.,internal) are excluded.cause(preservingdocs/internals/02_effect-services.mdand PR fix(cursor): Cursor text generation names usage-limit failures pingdotgg/t3code#29748).packages/provider-cursor/src/server/CursorAgentSdk.test.tsfor codeless usage-limit messages,USAGE_PRICING_REQUIRED*, wrapped causes, and non-limit exclusions.Fixing this in
CursorAgentSdk.tskeeps the diff minimal without editing the 17 MB minifiedpatches/@cursor__sdk@1.5.2.patchorpnpm-lock.yaml, survives SDK upgrades, and also handlesCUSTOM_MESSAGE/USAGE_PRICING_REQUIREDpayloads.Scope
Fixes #
isCursorUsageLimitError()— regular Cursor turns (adapter.tson bothresult.errorand throwncause, across web, desktop, and mobile clients via server-side failure classification) and Cursor text generation (textGeneration.tsfor thread title, branch name, commit message, and PR generation).usageLimits.ts), parsing coarse"It resets in 3 days"text intoresetsAt, and patching@cursor/sdk'swrapErrorto recover error codes for non-usage-limit error classes.Verification
Reproducible on a Linux VM with no Cursor account
CursorAgentSdk.tstoorigin/main: newisCursorUsageLimitErrortest inpackages/provider-cursor/src/server/CursorAgentSdk.test.tsfails (expected false to be true).vp test run packages/provider-cursor/src/server/CursorAgentSdk.test.ts packages/provider-cursor/src/server/textGeneration.test.ts packages/provider-cursor/src/server/CursorAgentSdkProcessRunner.test.ts packages/provider-cursor/src/server/adapter.test.ts— 4 files, 74/74 passed.vp run check:changed— format, lint, knip, typecheck, and affected tests all pass.scenarios:proveagainstorigin/main):Ran an offline scenario against a local HTTP/1.1 ConnectRPC stub Cursor backend (
CURSOR_BACKEND_URL=http://127.0.0.1:13998 CURSOR_API_KEY=test-cursor-key) returningaiserver.v1.ErrorDetails(PRO_USER_USAGE_LIMIT, title"Weekly usage limit reached.", detail"It resets in 3 days. Buy credits to keep going now.") through the real@cursor/sdk@1.5.2worker.df2cbe3961: ❌ failed (Provider errorin timeline, noLimitedbadge, Regenerate title toast shows"Cursor SDK request finished with an error.").73c51a1093: ✅ passed (Usage limit reachedbanner,Limitedbadge in sidebar, Regenerate title toast shows"Cursor usage limit reached. Try again later or choose another text-generation provider.").code: "internal","Backend service unavailable"). Confirmed regular Cursor turns still classify asProvider errorand Regenerate title still shows"Cursor SDK request finished with an error.".df2cbe3961)73c51a1093)Offline E2E repro scenario (
scripts/scenarios/cursor-weekly-usage-limit.e2e.ts)Run with:
T3_SCENARIO_INHERIT_ENV='CURSOR_BACKEND_URL,CURSOR_API_KEY' \ CURSOR_BACKEND_URL=http://127.0.0.1:13998 \ CURSOR_API_KEY=test-cursor-key \ vp run scenarios:prove scripts/scenarios/cursor-weekly-usage-limit.e2e.ts --base origin/mainNot verified / requires a live account
aiserver.v1.ErrorDetailsPRO_USER_USAGE_LIMITwire payload through the real@cursor/sdk@1.5.2worker).Note
Written by Gemini 4 Neon in T3 Code on behalf of Stefan.