Conversation
`calculateDelay` in core/llm/utils/retry.ts looks for `error.headers["retry-after"]`, `["x-ratelimit-reset"]` and friends so a retry waits exactly as long as the provider asked. Nothing ever put them there: `parseError` builds its error from the response and keeps only the text, so that branch could not fire and every rate limit fell through to exponential backoff — a guess, when the provider had already said the answer. `parseError` now annotates whatever it built with the response's `status` and a lower-cased plain-object copy of its headers. Lower-cased because that is how `Headers` yields them and how the reader spells the names it checks first, and a plain object because the reader uses bracket access, which returns undefined on a `Headers` instance. Headers are left unset when the response carried none: an empty object reads as "the provider answered with no limits", and absent says it never answered. No behaviour changes on its own — this only makes the existing header path reachable. Verified: `jest llm/index.test.ts` — 189 passed, including three new cases.
Contributor
|
I have read the CLA Document and I hereby sign the CLA You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot. |
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.
calculateDelayincore/llm/utils/retry.tslooks forso a retry waits exactly as long as the provider asked rather than guessing.
Nothing ever put them there.
parseErrorbuilds its error from the response and keeps only the text — nostatus, noheaders— so that branch could not fire and every rate limit fell through to exponential backoff.What changed
parseErrornow annotates whatever it built with the response'sstatusand a lower-cased plain-object copy of its headers.Headersyields them, and how the reader spells the names it checks first.undefinedon aHeadersinstance regardless of casing.No behaviour changes on its own. This only makes the existing header path reachable, and puts the limit within reach of anything else that wants it.
Testing
jest llm/index.test.ts— 189 passed, including three new cases covering theRetry-Afterround trip, the lower-casing, and the absent-headers case.