Skip to content

False positive - RATE LIMIT warning when API returns rate_limit_event with status: "allowed" #433

@bbolek-ap

Description

@bbolek-ap

Summary

When the Claude API emits a rate_limit_event with status: \"allowed\" (i.e., an informational event — the request was not blocked), dotbot incorrectly displays a ⚠ RATE LIMIT warning and records a rate limit hit. This is a false positive that causes unnecessary alarm and may affect agent flow decisions.

Observed Behavior

Raw API event received (informational — request was allowed):

{\"type\":\"rate_limit_event\",\"rate_limit_info\":{\"status\":\"allowed\",\"resetsAt\":1779296400,\"rateLimitType\":\"five_hour\",\"overageStatus\":\"allowed\",\"overageResetsAt\":1780272000,\"isUsingOverage\":false}}

Warning incorrectly displayed:

⚠ RATE LIMIT: Rate limit hit (no reset time provided)

Note: status: "allowed" and overageStatus: "allowed" — the API explicitly confirmed the request was permitted.

Root Cause

Two files share the same bug:

1. .bot/core/runtime/ClaudeCLI/ClaudeCLI.psm1 — lines 700–733

if ($line[0] -eq '{' -and $line -match "hit your.*?limit|out of extra usage|error.*?rate_limit") {

The regex error.*?rate_limit matches any JSON line containing rate_limit anywhere in the string — including "type":"rate_limit_event". After matching, the code attempts to extract a message but finds none of the expected fields (result, message.content), then falls through to:

} elseif ($jsonObj.error -eq "rate_limit") {
    $rateLimitText = "Rate limit hit (no reset time provided)"   # fires incorrectly
}

The rate_limit_info.status field is never checked.

2. .bot/core/runtime/ProviderCLI/parsers/Parse-ClaudeStream.ps1 — lines 31–56

Identical pattern and identical gap — no check for status: "allowed".

Proposed Fix

After parsing $jsonObj, add an early return before any message extraction in both files:

# Skip informational rate_limit_event when status is "allowed" — not an actual block
if ($jsonObj.type -eq "rate_limit_event" -and $jsonObj.rate_limit_info.status -eq "allowed") {
    return
}

This should be inserted immediately after the ConvertFrom-Json call, before attempting to extract a $rateLimitText.

Files to Fix

File Lines
.bot/core/runtime/ClaudeCLI/ClaudeCLI.psm1 ~703 (after ConvertFrom-Json)
.bot/core/runtime/ProviderCLI/parsers/Parse-ClaudeStream.ps1 ~34 (after ConvertFrom-Json)

Environment

  • dotbot workspace: dotbot-flow/27
  • Provider: Claude (claude-opus-4-7)
  • Rate limit type in event: five_hour
  • Platform: Windows 11, PowerShell 7+

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    Status

    In Review

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions