fix: stop misclassifying rate-limit errors as context overflow#10003
Open
maxtongwang wants to merge 1 commit intoopenclaw:mainfrom
Open
fix: stop misclassifying rate-limit errors as context overflow#10003maxtongwang wants to merge 1 commit intoopenclaw:mainfrom
maxtongwang wants to merge 1 commit intoopenclaw:mainfrom
Conversation
Contributor
Additional Comments (1)
This test file defines Prompt To Fix With AIThis is a comment left during a code review.
Path: src/agents/pi-embedded-helpers.islikelycontextoverflowerror.test.ts
Line: 5:11
Comment:
**Broken test helper**
This test file defines `_makeFile` with a `WorkspaceBootstrapFile` type, but neither `WorkspaceBootstrapFile` nor `_makeFile` is used/imported here. In a TS project, this will fail typechecking (`Cannot find name 'WorkspaceBootstrapFile'`) unless it’s a global type, and even then it’s dead code in this test. Removing the helper (and unused imports like `DEFAULT_AGENTS_FILENAME` if no longer needed) will avoid compile/lint failures.
How can I resolve this? If you propose a fix, please make it concise. |
05cbfc6 to
fefbe05
Compare
fefbe05 to
53060bf
Compare
bfc1ccb to
f92900f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The
CONTEXT_OVERFLOW_HINT_REregex (introduced in #1266) was too broad — its third alternative(?:prompt|request|input).*(exceed|over|limit|max)matched Anthropic rate-limit messages like "Number of request tokens has exceeded your per-model limit", causing them to be surfaced as "Context overflow" errors to users.Root cause: When the Anthropic usage quota is nearly exhausted, rate-limit 429 errors are returned. The broad regex in
isLikelyContextOverflowErrormatched these, so the agent runner showed "Context overflow" instead of the actual rate-limit error.Fix:
(prompt|request|input) [is] too (large|long)— genuine overflow messagesTest plan
pnpm test)Fixes a regression from #1266.
🤖 Generated with Claude Code
Greptile Overview
Greptile Summary
This PR narrows
CONTEXT_OVERFLOW_HINT_REinsrc/agents/pi-embedded-helpers/errors.tsto avoid matching rate-limit phrasing (e.g., “request tokens exceeded your per-model limit”), and adds explicit early returns inisLikelyContextOverflowErrorfor rate-limit and billing errors before applying the hint regex. It also adds regression tests insrc/agents/pi-embedded-helpers.islikelycontextoverflowerror.test.tsto ensure rate-limit and billing messages are not misclassified as context overflow.This fits into the existing error-classification pipeline:
formatAssistantErrorTextand related helpers rely onisContextOverflowError/isLikelyContextOverflowErrorto decide whether to present a “Context overflow” user message vs. other provider errors.Confidence Score: 4/5
(3/5) Reply to the agent's comments like "Can you suggest a fix for this @greptileai?" or ask follow-up questions!