fix(claude): surface usage-limit pauses in the thread #7165
main fromrefs/pull/7165/headmerged by juliusmarminge View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:M
- apps/server/src/provider/Layers/ClaudeAdapter.ts line 4473OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -4423,3 +4468,6 @@4423446844244469 const updatedAt = yield* nowIso;44254470 context.turnState = turnState;4471+ // A retry inside the same window renders the identical line: every new4472+ // turn gets to announce the pause again.4473+ context.lastUsageLimitNotice = undefined;
- apps/server/src/provider/Layers/ClaudeAdapter.ts line 3572OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -3512,3 +3554,19 @@35123554 rateLimits: message,35133555 },35143556 });3557+ // A rejected window parks the turn inside the SDK: no further messages3558+ // arrive and no result lands, so without a row the thread just spins.3559+ // Warnings (allowed_warning) still have headroom and stay quiet, an3560+ // account spending provisioned overage keeps running despite the reject,3561+ // and between turns there is no turn to report as paused.3562+ const rateLimitInfo = message.rate_limit_info;3563+ if (3564+ rateLimitInfo !== undefined &&3565+ rateLimitInfo.status === "rejected" &&3566+ rateLimitInfo.overageStatus !== "allowed" &&3567+ rateLimitInfo.isUsingOverage !== true &&3568+ rateLimitInfo.overageInUse !== true &&3569+ context.turnState !== undefined3570+ ) {3571+ const notice = describeClaudeUsageLimit(rateLimitInfo, Date.parse(stamp.createdAt));3572+ if (notice !== context.lastUsageLimitNotice) {
- apps/server/src/provider/Layers/ClaudeAdapter.ts line 3901Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -3513,2 +3555,21 @@35133555 },35143556 });3557+ // A rejected window parks the turn inside the SDK: no further messages3558+ // arrive and no result lands, so without a row the thread just spins.3559+ // Warnings (allowed_warning) still have headroom and stay quiet, an3560+ // account spending provisioned overage keeps running despite the reject,3561+ // and between turns there is no turn to report as paused.3562+ const rateLimitInfo = message.rate_limit_info;3563+ if (3564+ rateLimitInfo !== undefined &&3565+ rateLimitInfo.status === "rejected" &&3566+ rateLimitInfo.overageStatus !== "allowed" &&3567+ rateLimitInfo.isUsingOverage !== true &&3568+ rateLimitInfo.overageInUse !== true &&3569+ context.turnState !== undefined3570+ ) {3571+ const notice = describeClaudeUsageLimit(rateLimitInfo, Date.parse(stamp.createdAt));3572+ if (notice !== context.lastUsageLimitNotice) {3573+ context.lastUsageLimitNotice = notice;3574+ yield* emitRuntimeWarning(context, notice, rateLimitInfo);3575+ }
- apps/server/src/provider/Layers/ClaudeAdapter.ts line 3579OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -3514,0 +3559,21 @@3559+ // Warnings (allowed_warning) still have headroom and stay quiet, an3560+ // account spending provisioned overage keeps running despite the reject,3561+ // and between turns there is no turn to report as paused.3562+ const rateLimitInfo = message.rate_limit_info;3563+ if (3564+ rateLimitInfo !== undefined &&3565+ rateLimitInfo.status === "rejected" &&3566+ rateLimitInfo.overageStatus !== "allowed" &&3567+ rateLimitInfo.isUsingOverage !== true &&3568+ rateLimitInfo.overageInUse !== true &&3569+ context.turnState !== undefined3570+ ) {3571+ // Keyed on the limit itself rather than the rendered row: a parked3572+ // window re-fires while the remaining wait shrinks, and every turn —3573+ // including a synthetic one — carries its own id, so the next turn3574+ // parked on the same window announces it again.3575+ const limitKey = `${context.turnState.turnId}:${rateLimitInfo.rateLimitType ?? "unknown"}:${3576+ rateLimitInfo.resetsAt ?? "unknown"3577+ }`;3578+ if (limitKey !== context.lastUsageLimitKey) {3579+ context.lastUsageLimitKey = limitKey;
github-actions[bot](GitHub profile, opens in a new tab) removed labelssize:M
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:L
- apps/server/src/provider/Layers/ClaudeAdapter.ts line 3881Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -3509,3 +3551,16 @@35093551 rateLimits: message,35103552 },35113553 });3554+ // A rejected window parks the turn inside the SDK: no further messages3555+ // arrive and no result lands, so without a row the thread just spins.3556+ // Warnings (allowed_warning) still have headroom and stay quiet, an3557+ // account spending provisioned overage keeps running despite the reject,3558+ // and between turns there is no turn to report as paused.3559+ const rateLimitInfo = message.rate_limit_info;3560+ if (3561+ rateLimitInfo !== undefined &&3562+ rateLimitInfo.status === "rejected" &&3563+ rateLimitInfo.overageStatus !== "allowed" &&3564+ rateLimitInfo.isUsingOverage !== true &&3565+ rateLimitInfo.overageInUse !== true &&3566+ context.turnState !== undefined
github-actions[bot](GitHub profile, opens in a new tab) removed labelssize:L
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:M
github-actions[bot](GitHub profile, opens in a new tab) removed labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted
github-actions[bot](GitHub profile, opens in a new tab) removed labelssize:M
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:L
macroscopeapp[bot](GitHub profile, opens in a new tab) approved these changes
juliusmarminge approved these changes
juliusmarminge merged this940e823
juliusmarminge closed this
Sign in to join this conversation.





Important
Review skipped#
Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
.coderabbit.yamlfile in this repository. To trigger a single review, invoke the@coderabbitai reviewcommand.⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Team
Run ID:
e29d6ed1-263f-44bc-b694-cd8e6e402c14You can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.Use the checkbox below for a quick retry:
Warning
Your free Security trial is over. An organization admin can upgrade to Advanced for continuous pull request security review or dismiss this notice.
Comment `@coderabbitai help` to get the list of available commands.