Skip to content

fix(llm): Tolerate trailing punctuation in rate-limit retry delays#581

Merged
JeanMertz merged 1 commit intomainfrom
prr147
Apr 28, 2026
Merged

fix(llm): Tolerate trailing punctuation in rate-limit retry delays#581
JeanMertz merged 1 commit intomainfrom
prr147

Conversation

@JeanMertz
Copy link
Copy Markdown
Collaborator

parse_secs_token stripped only a trailing comma but not other sentence-ending punctuation. This caused the retry delay to be missed when parsing real OpenAI in-stream rate-limit messages, which embed the duration in prose and end it with a period, e.g.:

"Please try again in 2.398s. Visit ..."

The fix strips any trailing sentence punctuation (., ,, ;, :, ), !, ?) before stripping the unit suffix, so "2.398s." now correctly parses to 3 seconds (ceil of 2.398).

`parse_secs_token` stripped only a trailing comma but not other
sentence-ending punctuation. This caused the retry delay to be missed
when parsing real OpenAI in-stream rate-limit messages, which embed the
duration in prose and end it with a period, e.g.:

  "Please try again in 2.398s. Visit ..."

The fix strips any trailing sentence punctuation (`.`, `,`, `;`, `:`,
`)`, `!`, `?`) before stripping the unit suffix, so `"2.398s."` now
correctly parses to 3 seconds (ceil of 2.398).

Signed-off-by: Jean Mertz <git@jeanmertz.com>
@JeanMertz JeanMertz merged commit b445390 into main Apr 28, 2026
13 checks passed
@JeanMertz JeanMertz deleted the prr147 branch April 28, 2026 16:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant