Skip to content

fix: add rate limit patterns for 'too many tokens' and 'tokens per day'#39377

Merged
altaywtf merged 1 commit intoopenclaw:mainfrom
gambletan:fix/38822-rate-limit-tokens-per-day
Mar 8, 2026
Merged

fix: add rate limit patterns for 'too many tokens' and 'tokens per day'#39377
altaywtf merged 1 commit intoopenclaw:mainfrom
gambletan:fix/38822-rate-limit-tokens-per-day

Conversation

@gambletan
Copy link
Copy Markdown
Contributor

Summary

Fixes Issue #38822 - Rate limit detection missing 'too many tokens per day' pattern (AWS Bedrock)

Changes

  • Add AWS Bedrock 'too many tokens per day' pattern to rate limit detection
  • Add 'tokens per day' and 'too many tokens' to failover-matches.ts
  • Add patterns to errors.ts, timer.ts, and manager-embedding-ops.ts

Testing

Build passes successfully.

Related

Fixes #38822

@openclaw-barnacle openclaw-barnacle bot added app: web-ui App: web-ui scripts Repository scripts agents Agent runtime and tooling size: S labels Mar 8, 2026
@aisle-research-bot
Copy link
Copy Markdown

aisle-research-bot bot commented Mar 8, 2026

🤖 We're reviewing this PR with Aisle

We're running a security check on the changes in this PR now. This usually takes a few minutes. ⌛
We'll post the results here as soon as they're ready.

Progress:

  • Analysis
  • Triage
  • Finalization

Latest run failed. Keeping previous successful results. Trace ID: 019ccb3a3fb8e619b4e79cf7441d1f2b.

Last updated on: 2026-03-08T02:17:04Z

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Mar 8, 2026

Greptile Summary

This PR adds "tokens per day" as a recognized rate-limit error pattern across four locations (failover-matches.ts, errors.ts, timer.ts, manager-embedding-ops.ts) to fix issue #38822, where AWS Bedrock's daily token-quota message was not being identified as a retryable rate-limit error.

Changes:

  • failover-matches.ts — appends "tokens per day" to the rateLimit string-pattern list, consistent with the existing "tokens per minute" entry
  • errors.ts — extends RATE_LIMIT_HINT_RE with tokens per day, acting as a defence-in-depth guard in isLikelyContextOverflowError (the primary gate already runs via isRateLimitErrorMessage beforehand)
  • timer.ts — adds tokens per day to TRANSIENT_PATTERNS.rate_limit so one-shot cron jobs are retried instead of being permanently disabled
  • manager-embedding-ops.ts — adds tokens per day to isRetryableEmbeddingError so embedding batches are retried on the same error class

Test coverage is thorough: unit tests confirm correct classification and exclusion from context-overflow detection, plus an important guard test that ensures "Context window exceeded: too many tokens per request" is not reclassified as rate-limit. Full integration regression tests cover both the cron retry lifecycle and the embedding batch retry path.

Confidence Score: 5/5

  • This PR is safe to merge — the change is narrowly scoped, well-tested, and carries no risk of false positives for context-overflow or other error classes.
  • All four pattern sites are updated consistently. The new "tokens per day" substring is unambiguous (AWS Bedrock uses it exclusively for daily quota errors). Existing tests for TPM and context-overflow paths are unaffected, and a dedicated guard test confirms "too many tokens per request" (a context overflow phrasing) remains correctly classified. Integration tests validate the full retry lifecycle for both cron jobs and embedding batches.
  • No files require special attention.

Last reviewed commit: 132a457

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 249c5c2382

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@gambletan
Copy link
Copy Markdown
Contributor Author

Addressed the review feedback:

Narrowed "too many tokens" to "too many tokens per" across all 4 files (errors.ts, failover-matches.ts, timer.ts, manager-embedding-ops.ts).

The original "too many tokens" pattern was too broad -- it would also match context-window-exceeded messages like "too many tokens in your request", causing isLikelyContextOverflowError to misclassify them as rate-limit errors (since RATE_LIMIT_HINT_RE is checked before CONTEXT_OVERFLOW_HINT_RE). This would skip compaction/overflow handling and could cause infinite retry loops.

The narrowed "too many tokens per" pattern specifically targets rate-limit messages like "too many tokens per day" / "too many tokens per minute" without false-positiving on context-window errors. The "tokens per day" pattern remains unchanged as it is already specific enough.

Re: the Greptile comments on chat.ts (unused idx, empty autocomplete container, arrow-key nav stub) -- those changes are not part of this PR's commits, so they're out of scope here.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 91ed828484

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@altaywtf altaywtf added the dirty label Mar 8, 2026
@openclaw-barnacle
Copy link
Copy Markdown

Closing this PR because it looks dirty (too many unrelated or unexpected changes). This usually happens when a branch picks up unrelated commits or a merge went sideways. Please recreate the PR from a clean branch.

@openclaw-barnacle openclaw-barnacle bot closed this Mar 8, 2026
@altaywtf altaywtf reopened this Mar 8, 2026
@altaywtf altaywtf force-pushed the fix/38822-rate-limit-tokens-per-day branch from 91ed828 to 9d50b85 Compare March 8, 2026 09:44
@openclaw-barnacle openclaw-barnacle bot removed app: web-ui App: web-ui scripts Repository scripts labels Mar 8, 2026
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9d50b85049

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@altaywtf altaywtf force-pushed the fix/38822-rate-limit-tokens-per-day branch from b87ba2c to 132a457 Compare March 8, 2026 09:50
@altaywtf
Copy link
Copy Markdown
Member

altaywtf commented Mar 8, 2026

@greptileai review

@altaywtf
Copy link
Copy Markdown
Member

altaywtf commented Mar 8, 2026

@codex review

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex Review: Didn't find any major issues. You're on a roll.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@altaywtf altaywtf merged commit 8a20f51 into openclaw:main Mar 8, 2026
29 checks passed
@altaywtf
Copy link
Copy Markdown
Member

altaywtf commented Mar 8, 2026

Merged via squash.

Thanks @gambletan!

Saitop pushed a commit to NomiciAI/openclaw that referenced this pull request Mar 8, 2026
…y' (openclaw#39377)

Merged via squash.

Prepared head SHA: 132a457
Co-authored-by: gambletan <[email protected]>
Co-authored-by: altaywtf <[email protected]>
Reviewed-by: @altaywtf
Saitop pushed a commit to NomiciAI/openclaw that referenced this pull request Mar 8, 2026
GordonSH-oss pushed a commit to GordonSH-oss/openclaw that referenced this pull request Mar 9, 2026
…y' (openclaw#39377)

Merged via squash.

Prepared head SHA: 132a457
Co-authored-by: gambletan <[email protected]>
Co-authored-by: altaywtf <[email protected]>
Reviewed-by: @altaywtf
GordonSH-oss pushed a commit to GordonSH-oss/openclaw that referenced this pull request Mar 9, 2026
jenawant pushed a commit to jenawant/openclaw that referenced this pull request Mar 10, 2026
…y' (openclaw#39377)

Merged via squash.

Prepared head SHA: 132a457
Co-authored-by: gambletan <[email protected]>
Co-authored-by: altaywtf <[email protected]>
Reviewed-by: @altaywtf
jenawant pushed a commit to jenawant/openclaw that referenced this pull request Mar 10, 2026
sauerdaniel pushed a commit to sauerdaniel/openclaw that referenced this pull request Mar 11, 2026
…y' (openclaw#39377)

Merged via squash.

Prepared head SHA: 132a457
Co-authored-by: gambletan <[email protected]>
Co-authored-by: altaywtf <[email protected]>
Reviewed-by: @altaywtf
sauerdaniel pushed a commit to sauerdaniel/openclaw that referenced this pull request Mar 11, 2026
dhoman pushed a commit to dhoman/chrono-claw that referenced this pull request Mar 11, 2026
…y' (openclaw#39377)

Merged via squash.

Prepared head SHA: 132a457
Co-authored-by: gambletan <[email protected]>
Co-authored-by: altaywtf <[email protected]>
Reviewed-by: @altaywtf
dhoman pushed a commit to dhoman/chrono-claw that referenced this pull request Mar 11, 2026
senw-developers pushed a commit to senw-developers/va-openclaw that referenced this pull request Mar 17, 2026
…y' (openclaw#39377)

Merged via squash.

Prepared head SHA: 132a457
Co-authored-by: gambletan <[email protected]>
Co-authored-by: altaywtf <[email protected]>
Reviewed-by: @altaywtf
senw-developers pushed a commit to senw-developers/va-openclaw that referenced this pull request Mar 17, 2026
V-Gutierrez pushed a commit to V-Gutierrez/openclaw-vendor that referenced this pull request Mar 17, 2026
…y' (openclaw#39377)

Merged via squash.

Prepared head SHA: 132a457
Co-authored-by: gambletan <[email protected]>
Co-authored-by: altaywtf <[email protected]>
Reviewed-by: @altaywtf
V-Gutierrez pushed a commit to V-Gutierrez/openclaw-vendor that referenced this pull request Mar 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling dirty size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Rate limit detection missing 'too many tokens per day' pattern (AWS Bedrock)

2 participants