Skip to content

Commit a2c45c8

Browse files
leeroybrunclaude
andcommitted
test(claude): treat rejected rate-limit telemetry as quota evidence in the SDK work-state test
A rejected rate_limit_event reports availability, not a failed parent turn (cca3875); only the provider result or error starts limit recovery. The work-state test now asserts the event becomes quota evidence with every reported window and stays out of the transcript. Refs #641 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 045617c commit a2c45c8

1 file changed

Lines changed: 8 additions & 17 deletions

File tree

‎apps/cli/src/backends/claude/remote/claudeRemoteAgentSdk.workState.test.ts‎

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,9 @@ async function runAgentSdkMessagesForRateLimitTest(params: Readonly<{
5353
}
5454

5555
describe('claudeRemoteAgentSdk work-state projection', () => {
56-
it('consumes rate_limit_event before transcript conversion drops it', async () => {
56+
it('consumes a rejected rate_limit_event as quota evidence, not a parent failure, before transcript conversion drops it', async () => {
5757
const onRateLimitEvent = vi.fn();
58+
const onQuotaEvidence = vi.fn();
5859
const onMessage = vi.fn();
5960

6061
await runAgentSdkMessagesForRateLimitTest({
@@ -78,26 +79,16 @@ describe('claudeRemoteAgentSdk work-state projection', () => {
7879
],
7980
onMessage,
8081
onRateLimitEvent,
82+
onQuotaEvidence,
8183
});
8284

83-
expect(onRateLimitEvent).toHaveBeenCalledWith({
84-
v: 1,
85-
resetAtMs: 1_768_100_000_000,
86-
retryAfterMs: null,
87-
limitCategory: 'usage_limit',
88-
quotaScope: 'account',
89-
recoverability: 'wait',
90-
providerLimitId: 'five_hour',
91-
planType: null,
92-
utilization: 100,
93-
overage: null,
94-
action: null,
95-
connectedService: null,
96-
}, [
97-
// Every window the event reported travels with the limit, so its snapshot keeps them all.
85+
// Availability telemetry never fails the parent turn; only the provider's result or error does.
86+
expect(onRateLimitEvent).not.toHaveBeenCalled();
87+
// Every window the event reported travels with the evidence, so its snapshot keeps them all.
88+
expect(onQuotaEvidence).toHaveBeenCalledWith(expect.arrayContaining([
9889
expect.objectContaining({ providerLimitId: 'five_hour', utilization: 100 }),
9990
expect.objectContaining({ providerLimitId: 'seven_day', utilization: 42 }),
100-
]);
91+
]));
10192
expect(onMessage).not.toHaveBeenCalledWith(expect.objectContaining({ type: 'rate_limit_event' }));
10293
});
10394

0 commit comments

Comments
 (0)