From e8a32207d88bb7d0626ad79d79e84d8ff6f9cc6e Mon Sep 17 00:00:00 2001 From: glifocat Date: Mon, 6 Jul 2026 15:05:01 +0000 Subject: [PATCH] fix(agent-runner): match rate_limit_event as a top-level SDK message type The claude provider mapped rate-limit events with `message.type === 'system' && subtype === 'rate_limit_event'`, but `@anthropic-ai/claude-agent-sdk` 0.3.x ships rate limits as a top-level `SDKRateLimitEvent` (`{ type: 'rate_limit_event', ... }`) with no `system` subtype. The old condition never matched, so the quota-classified error event was never emitted and rate-limit signals were silently dropped. Match the top-level `type` instead. --- container/agent-runner/src/providers/claude.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/container/agent-runner/src/providers/claude.ts b/container/agent-runner/src/providers/claude.ts index 36ee7def0..27d8ffb68 100644 --- a/container/agent-runner/src/providers/claude.ts +++ b/container/agent-runner/src/providers/claude.ts @@ -449,7 +449,10 @@ export class ClaudeProvider implements AgentProvider { yield { type: 'result', text, isError: m.is_error === true }; } else if (message.type === 'system' && (message as { subtype?: string }).subtype === 'api_retry') { yield { type: 'error', message: 'API retry', retryable: true }; - } else if (message.type === 'system' && (message as { subtype?: string }).subtype === 'rate_limit_event') { + } else if (message.type === 'rate_limit_event') { + // SDK 0.3.x ships this as a top-level message type (SDKRateLimitEvent), + // not a `system` subtype — matching the old shape here left this branch + // dead and dropped the quota signal entirely. yield { type: 'error', message: 'Rate limit', retryable: false, classification: 'quota' }; } else if (message.type === 'system' && (message as { subtype?: string }).subtype === 'compact_boundary') { const meta = (message as { compact_metadata?: { pre_tokens?: number } }).compact_metadata;