Skip to content

fix(cursor): size prior keeps provably-small bare resource_exhausted on the 429 class - #2342

Merged
lidge-jun merged 1 commit into
devfrom
codex/cursor-bare-re-size-prior
Aug 22, 2026
Merged

fix(cursor): size prior keeps provably-small bare resource_exhausted on the 429 class#2342
lidge-jun merged 1 commit into
devfrom
codex/cursor-bare-re-size-prior

Conversation

@lidge-jun

@lidge-jun lidge-jun commented Aug 22, 2026

Copy link
Copy Markdown
Owner

Summary

Live-probe-driven refinement of the #2320 bare-resource_exhausted overflow mapping (devlog 260, probe evidence in 210): a plan-gated model returns the same bare RE shape on a ~20-token prompt that a real overflow produces, so the pure message-shape classifier compacts turns that entitlement — not size — rejected.

classifyCursorError gains an optional size prior: a bare RE with a provably small request (estimate < 50% of the model's context window) keeps the 429-class mapping; large or unknown sizes keep today's overflow mapping, so the prior only ever removes false overflows it can prove. The adapter supplies the estimate at its single error-mapping seam (safeCursorTransportError). Explicit quota cues and size phrases classify before the prior and are unaffected. senpi's T01 shares this false-overflow bug — this is a beyond-parity refinement.

Verification

  • bun x tsc --noEmit clean.
  • tests/cursor-errors.test.ts +5 cases (small→429, large→overflow, unknown→overflow unchanged, quota cue wins, size phrase wins) — 24 pass.
  • Adjacent suites green: cursor-protobuf-events, cursor-request-builder — 111 pass / 0 fail total.
  • Full suite deferred to final CI per maintainer instruction.

Checklist

  • Targets dev
  • Focused regression tests added
  • Behavior change is strictly narrowing (unknown context keeps existing mapping)
  • No logging/credential changes

Summary by CodeRabbit

  • Bug Fixes

    • Improved error classification for request failures based on estimated request size.
    • Small requests that exceed service limits are now more accurately identified as rate-limit errors.
    • Large or unknown-size requests continue to be identified as context-limit errors.
    • Explicit quota and request-size messages retain their appropriate classifications.
  • Tests

    • Added coverage for small, large, incomplete, and unknown request-size scenarios.

…lass

Live probe evidence (devlog 260822_senpi_cursor_transfer/210, 260): a
plan-gated model (claude-opus-4-7-low-fast without -fast entitlement)
returns the SAME bare 0-token resource_exhausted shape on a ~20-token
prompt that a real payload overflow produces. #2320's overflow mapping
then makes Codex compact a tiny turn — the wrong remedy for an
entitlement rejection, and the retry can never succeed.

Add a size prior to classifyCursorError: when the caller can prove the
request was small relative to the model's context window (estimate <
50% of window), a bare RE keeps the 429-class mapping; large or unknown
sizes keep today's overflow mapping, so the prior only ever removes
false overflows it can prove. The adapter supplies the estimate from
the outgoing request text and the static context-window table at its
single error-mapping seam. Explicit quota cues and size phrases are
unaffected (they classify before the prior).

senpi's T01 (#1009/#1036) shares this false-overflow bug; this is a
beyond-parity refinement.
@lidge-jun
lidge-jun requested a review from Ingwannu as a code owner August 22, 2026 04:39
@lidge-jun
lidge-jun merged commit 8f3ac5f into dev Aug 22, 2026
8 of 9 checks passed
@lidge-jun
lidge-jun deleted the codex/cursor-bare-re-size-prior branch August 22, 2026 04:39
@github-actions

Copy link
Copy Markdown
Contributor

Deterministic PR hygiene checks passed.

@github-actions github-actions Bot added the bug Something isn't working label Aug 22, 2026
@coderabbitai

coderabbitai Bot commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 1da2a6af-ca7a-42aa-995e-b2776cc6a739

📥 Commits

Reviewing files that changed from the base of the PR and between 896cb57 and f3a7cd4.

📒 Files selected for processing (3)
  • src/adapters/cursor.ts
  • src/adapters/cursor/cursor-errors.ts
  • tests/cursor-errors.test.ts

📝 Walkthrough

Walkthrough

The Cursor adapter now computes request-size context and passes it to error classification. Bare resource_exhausted errors use request size to distinguish rate limits from context-limit errors. Tests cover small, large, unknown, and explicit error cases.

Changes

Cursor error classification

Layer / File(s) Summary
Compute and propagate request-size context
src/adapters/cursor.ts (lines 6-7, 28, 57-79, 105-107, 130, 313)
The adapter estimates input tokens and infers the model context window after building the request. It stores this context and passes it to transport error formatting.
Classify errors using size thresholds
src/adapters/cursor/cursor-errors.ts (lines 126-149, 199, 217-221, 282-283), tests/cursor-errors.test.ts (lines 139-169)
CursorSizeContext supports size-aware classification. Known-small bare resource_exhausted errors map to rate limits. Large, unknown, or incomplete contexts retain context-limit classification, while explicit cues retain precedence.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant CursorAdapter
  participant TokenEstimator
  participant CursorErrorFormatter
  participant ErrorClassifier
  CursorAdapter->>TokenEstimator: estimate input tokens and context window
  CursorAdapter->>CursorErrorFormatter: format transport error with size context
  CursorErrorFormatter->>ErrorClassifier: classifyCursorError with size context
  ErrorClassifier-->>CursorErrorFormatter: return error category and message
Loading

Suggested reviewers: ingwannu, wibias

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/cursor-bare-re-size-prior

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant